Reading and analyzing data with Neo#
Getting started#
Neo is a library for working with neurophysiology data in the Python programming language. One of the big advantages of Neo is that it works with many different file formats: it doesn’t matter which format your data is stored in, Neo provides a standard way to read the data, and then represents it in a standardised way, as a set of Python objects.
The first step in reading data is to import the appropriate Neo input-output (or IO) module for your data.
For this example, we’re going to work with membrane potential traces stored in a text file,
so we use the AsciiSignalIO
module:
In [1]: from neo.io import AsciiSignalIO
In [2]: data = AsciiSignalIO("example_data.txt", delimiter=" ").read()
Note
For a full list of IO modules provided by Neo, see List of implemented IO modules.
In [3]: data
Out[3]:
[Block with [<neo.core.segment.Segment object at 0x7f49e2d82e50>] segments
file_origin: 'example_data.txt'
# segments (N=[<neo.core.segment.Segment object at 0x7f49e2d82e50>])
0: Segment with [<AnalogSignal(array([[-58.46900177, -52.85499954, -58.79000092, -58.81499863],
[-59.06100082, -50.51800156, -52.00299835, -57.24000168],
[-59.00999832, -50.50999832, -51.98799896, -57.19900131],
...,
[-56.53499985, -56.65299988, -56.37400055, -53.6590004 ],
[-56.50099945, -56.61999893, -56.41999817, -53.63999939],
[-56.4679985 , -56.58599854, -56.4640007 , -53.62099838]],
shape=(10001, 4)) * mV, [0.0 s, 10.001 s], sampling rate: 1.0 kHz)>] analogsignals
# analogsignals (N=[<AnalogSignal(array([[-58.46900177, -52.85499954, -58.79000092, -58.81499863],
[-59.06100082, -50.51800156, -52.00299835, -57.24000168],
[-59.00999832, -50.50999832, -51.98799896, -57.19900131],
...,
[-56.53499985, -56.65299988, -56.37400055, -53.6590004 ],
[-56.50099945, -56.61999893, -56.41999817, -53.63999939],
[-56.4679985 , -56.58599854, -56.4640007 , -53.62099838]],
shape=(10001, 4)) * mV, [0.0 s, 10.001 s], sampling rate: 1.0 kHz)>])
0: AnalogSignal with 4 channels of length 10001; units mV; datatype float64
name: 'multichannel'
sampling rate: 1.0 kHz
time: 0.0 s to 10.001 s]
Different data files can contain different amounts of data, from single traces to multiple
recording sessions. To provide consistent behaviour, for all IO modules, the read()
method returns a list of data blocks.
A Block
typically represents a recording session.
Each block contains a list of segments, where each Segment
contains data recorded at the same time.
In this example file, we see a single type of data, the “analog signal”, which represents continuous time series
sampled at a fixed interval. The other types of data that can be contained in a Segment
are discussed below
under Data types.
Note
read()
reads the entire file into memory at once. If you only want to access part of the data,
you can do so using Neo’s “lazy” data loading - see the section on Performance and memory consumption below.
Neo data objects are based on NumPy arrays, and behave very similarly. For example, they can be plotted just like arrays:
In [4]: import matplotlib.pyplot as plt
In [5]: signal = data[0].segments[0].analogsignals[0]
In [6]: plt.plot(signal.times, signal)
Out[6]:
[<matplotlib.lines.Line2D at 0x7f49e4facc10>,
<matplotlib.lines.Line2D at 0x7f49e2da3550>,
<matplotlib.lines.Line2D at 0x7f49e2da3ad0>,
<matplotlib.lines.Line2D at 0x7f49e2da3e10>]
In [7]: plt.xlabel(f"Time ({signal.times.units.dimensionality.string})")
Out[7]: Text(0.5, 0, 'Time (s)')
In [8]: plt.ylabel(f"Membrane potential ({signal.units.dimensionality.string})")
Out[8]: Text(0, 0.5, 'Membrane potential (mV)')
In [9]: plt.savefig("example_plot.png")

You now know enough to start using Neo. For more examples, see Examples. If you want to know more, read on.
NumPy#
Neo is based on NumPy. All Neo data classes behave like NumPy arrays, but have extra functionality.
The first addition is support for units.
In contrast to a plain NumPy array, an AnalogSignal
knows the units of the data it contains, e.g.:
In [10]: signal.units
Out[10]: array(1.) * mV
This helps avoid errors like adding signals with different units, lets you auto-generate figure axis labels, and makes it easy to change units, like here from millivolts to volts e.g.:
In [11]: signal.magnitude[:5]
Out[11]:
array([[-58.46900177, -52.85499954, -58.79000092, -58.81499863],
[-59.06100082, -50.51800156, -52.00299835, -57.24000168],
[-59.00999832, -50.50999832, -51.98799896, -57.19900131],
[-58.95999908, -50.50299835, -51.97299957, -57.15800095],
[-58.9109993 , -50.49499893, -51.95800018, -57.11700058]])
In [12]: signal.rescale("V").magnitude[:5]
Out[12]:
array([[-0.058469, -0.052855, -0.05879 , -0.058815],
[-0.059061, -0.050518, -0.052003, -0.05724 ],
[-0.05901 , -0.05051 , -0.051988, -0.057199],
[-0.05896 , -0.050503, -0.051973, -0.057158],
[-0.058911, -0.050495, -0.051958, -0.057117]])
The second addition is support for structured metadata.
Some of these metadata are required.
For example, an AnalogSignal
must always have a sampling_rate
attribute,
and Neo will produce an Exception if you try to add two signals with different sampling rates:
In [13]: signal.sampling_rate
Out[13]: array(1.) * kHz
Some of these metadata are recommended but optional, like a name for each signal. Such metadata appear as attributes of the data objects:
In [14]: signal.name
Out[14]: 'multichannel'
And finally, some metadata are fully optional.
These are stored in the annotations
and array_annotations
attributes:
In [15]: signal.array_annotations
Out[15]: {'channel_index': array([0, 1, 2, 3])}
For more information about this, see Annotations.
Most NumPy array methods also work on Neo data objects, e.g.:
In [16]: signal.mean()
Out[16]: array(-56.33598084) * mV
Data objects can be sliced like arrays (array annotations are automatically sliced appropriately):
In [17]: signal[100:110, 1:3]
Out[17]:
AnalogSignal with 2 channels of length 10; units mV; datatype float64
name: 'multichannel'
sampling rate: 1.0 kHz
time: 0.1 s to 0.11 s
In [18]: signal[100:110, 1:3].array_annotations
Out[18]: {'channel_index': array([1, 2])}
To convert a Neo data object to a plain NumPy array, use the magnitude
attribute:
In [19]: signal[100:110, 1:3].magnitude
Out[19]:
array([[-60.65399933, -60. ],
[-60.72399902, -60. ],
[-60.79199982, -60. ],
[-60.85900116, -60. ],
[-60.92399979, -60. ],
[-60.98899841, -60. ],
[-61.05199814, -60. ],
[-61.11399841, -60. ],
[-61.17499924, -60. ],
[-61.23400116, -60. ]])
Data types#
The following classes directly represent data as arrays of numerical values with associated metadata (units, sampling frequency, etc.).
AnalogSignal
: A regular sampling of a single- or multi-channel continuous analog signal.
IrregularlySampledSignal
: A non-regular sampling of a single- or multi-channel continuous analog signal.
SpikeTrain
: A set of action potentials (spikes) emitted by the same unit in a period of time (with optional waveforms).
Event
: An array of time points representing one or more events in the data.
Epoch
: An array of time intervals representing one or more periods of time in the data.
ImageSequence
: A three dimensional array representing a sequence of images.
AnalogSignal#
We have already met the AnalogSignal
, which represents continuous time series
sampled at a fixed interval.
In addition to reading data from a file, as above, it is also possible to create new signal objects directly, e.g.:
In [20]: import numpy as np
In [21]: from quantities import mV, kHz
In [22]: from neo import AnalogSignal
In [23]: signal = AnalogSignal(np.random.normal(-65.0, 5.0, size=(100, 5)),
....: units=mV, sampling_rate=1 * kHz)
....:
In [24]: signal
Out[24]:
AnalogSignal with 5 channels of length 100; units mV; datatype float64
sampling rate: 1.0 kHz
time: 0.0 s to 0.1 s
IrregularlySampledSignal#
IrregularlySampledSignal
represents continuous time series sampled at non-regular time points.
This means that instead of specifying the sampling rate or sampling interval, you must
specify the array of times at which the signal was sampled.
In [25]: from quantities import ms, nA
In [26]: from neo import IrregularlySampledSignal
In [27]: isignal = IrregularlySampledSignal(
....: times=[0.0, 1.11, 4.27, 16.38, 19.33] * ms,
....: signal=[0.5, 0.8, 0.5, 0.7, 0.2] * nA,
....: description="input current")
....:
In [28]: isignal
Out[28]:
IrregularlySampledSignal with 1 channels of length 5; units nA; datatype float64
description: 'input current'
sample times: [ 0. 1.11 4.27 16.38 19.33] ms
Note
in case of multi-channel data, samples are assumed to have been taken at the same time points in all channels. If you need to specify different time points for different channels, use one signal object per channel.
SpikeTrain#
A SpikeTrain
represents the times of occurrence of action potentials (spikes).
In [29]: from neo import SpikeTrain
In [30]: spike_train = SpikeTrain([3, 4, 5], units='sec', t_stop=10.0)
In [31]: spike_train
Out[31]:
SpikeTrain containing 3 spikes; units s; datatype float64
time: 0.0 s to 10.0 s
It may also contain the waveforms of the action potentials, stored as AnalogSignals
within the spike train object - see the reference documentation for more on this.
Event#
It is common in electrophysiology experiments to record the times of specific events,
such as the times at which stimuli are presented.
An Event
contains an array of times at which events occurred,
together with an optional array of labels for the events, e.g.:
In [32]: from neo import Event
In [33]: events = Event(np.array([5, 15, 25]), units="second",
....: labels=["apple", "rock", "elephant"],
....: name="stimulus onset")
....:
In [34]: events
Out[34]:
Event containing 3 events with labels; time units s; datatype int64
name: 'stimulus onset'
Epoch#
A variation of events is where something occurs over a certain period of time,
in which case we need to know both the start time and the duration.
An Epoch
contains an array of start or onset times together with an
array of durations (or a single value if all epochs have the same duration),
and an optional array of labels.
In [35]: from neo import Epoch
In [36]: epochs = Epoch(times=np.array([5, 15, 25]),
....: durations=2.0,
....: units="second",
....: labels=["apple", "rock", "elephant"],
....: name="stimulus presentations")
....:
In [37]: epochs
Out[37]:
Epoch containing 3 epochs with labels; time units s; datatype int64
name: 'stimulus presentations'
ImageSequence#
In addition to electrophysiology, neurophysiology signals may be obtained through functional microscopy.
The ImageSequence
class represents a sequence of images, as a 3D array organized as [frame][row][column].
It behaves similarly to AnalogSignal
, but in 3D rather than 2D.
In [38]: from quantities import Hz, micrometer
In [39]: from neo import ImageSequence
In [40]: img_sequence_array = [[[column for column in range(20)]for row in range(20)]
....: for frame in range(10)]
....:
In [41]: image_sequence = ImageSequence(img_sequence_array, units='dimensionless',
....: sampling_rate=1 * Hz,
....: spatial_scale=1 * micrometer)
....:
In [42]: image_sequence
Out[42]:
ImageSequence 10 frames with width 20 px and height 20 px; units dimensionless; datatype int64
sampling rate: 1.0 Hz
spatial_scale: 1.0 um
Annotations#
Neo objects have certain required metadata, such as the sampling_rate
for AnalogSignals
.
There are also certain recommended metadata, such as a name and description.
For any metadata not covered by the required or recommended fields, additional annotations can be added, e.g.:
In [43]: from quantities import um as µm
In [44]: signal.annotate(pipette_tip_diameter=1.5 * µm)
In [45]: signal.annotations
Out[45]: {'pipette_tip_diameter': array(1.5) * um}
For those IO modules that support writing data to file, annotations will also be written, provided they can be serialized to JSON format.
Array annotations#
Since certain Neo objects contain array data, it is sometimes necessary to annotate individual array elements, or individual columns.
For 1D arrays, the array annotations should have the same length as the array, e.g.
In [46]: events.shape
Out[46]: (3,)
In [47]: events.array_annotate(secondary_labels=["red", "green", "blue"])
For 2D arrays, the array annotations should match the shape of the channel dimension, e.g.
In [48]: signal.shape
Out[48]: (100, 5)
In [49]: signal.array_annotate(quality=["good", "good", "noisy", "good", "noisy"])
Dataset structure#
The overall structure of a Neo dataset is shown in this figure:

Beyond the core data classes, Neo has various classes for grouping and structuring different data objects.
We have already met two of them, the Block
and Segment
.
Tree structure#
Block
and Segment
provide a basic two-level hierarchical structure:
Blocks
contain Segments
, which contain data objects.
Segments
are used to group data that have a common time basis, i.e. that were recorded at the same time.
A Segment
can be considered as equivalent to a “trial”, “episode”, “run”, “recording”, etc.,
depending on the experimental context.
Segments
have the following attributes, used to access lists of data objects:
analogsignals
epochs
events
imagesequences
irregularlysampledsignals
spiketrains
Block
is the top-level container gathering all of the data, discrete and continuous, for a given recording session.
It contains Segment
and Group
(see next section) objects in the attributes segments
and groups
.
Grouping and linking objects#
Sometimes your data have a structure that goes beyond a simple two-level hierarchy. For example, suppose that you wish to group together signals that were recorded from the same tetrode in multi-tetrode recording setup.
For this, Neo provides a Group
class:
In [50]: from neo import Group
In [51]: signal1 = AnalogSignal(np.random.normal(-65.0, 5.0, size=(100, 5)), units=mV, sampling_rate=1 * kHz)
In [52]: signal2 = AnalogSignal(np.random.normal(-65.0, 5.0, size=(1000, 5)), units=nA, sampling_rate=10 * kHz)
In [53]: group = Group(objects=(signal1, signal2))
In [54]: group
Out[54]:
Group with [<AnalogSignal(array([[-67.26436158, -63.28337586, -68.708668 , -62.11429791,
-65.70780493],
[-69.21915253, -58.83063598, -60.52761022, -64.22388331,
-68.8506461 ],
[-68.91795734, -76.17173349, -69.00955258, -56.62840857,
-58.9236684 ],
[-67.88373308, -66.71872131, -56.94705264, -64.86835319,
-61.57740049],
[-62.88476103, -58.65319325, -56.39920258, -62.75797539,
-61.73371167],
[-57.81462643, -70.37028182, -61.51152968, -64.30116422,
-77.73933409],
[-58.22903149, -65.04676145, -64.04956841, -59.09303282,
-61.62337151],
[-73.33707898, -64.08514902, -60.50333293, -61.28442962,
-63.17806493],
[-67.51085243, -67.40651687, -63.78798837, -70.37283908,
-68.93194272],
[-61.44578707, -67.85976925, -60.3212767 , -63.84261921,
-67.21709754],
[-63.60549611, -53.95313189, -69.94366801, -62.05314511,
-72.60059363],
[-67.73637938, -60.73911638, -68.87396671, -62.99467819,
-56.85686086],
[-63.48122648, -56.42695555, -67.79920918, -70.48551317,
-57.7658971 ],
[-77.5450167 , -67.14135526, -59.96369944, -68.63614511,
-58.18621531],
[-64.07939716, -74.39032616, -59.28119406, -68.06442157,
-62.62146896],
[-65.7345612 , -57.59208175, -67.8732067 , -71.6159429 ,
-60.38526807],
[-62.13780065, -64.14214344, -57.94875412, -59.26663204,
-62.18143148],
[-61.20554655, -72.82058796, -67.26804878, -58.77157158,
-68.07965583],
[-61.32624674, -64.65904027, -69.50404885, -68.38070591,
-63.14725387],
[-68.26374654, -68.03876015, -66.22093338, -80.43908942,
-69.18800534],
[-69.07463991, -74.44734887, -62.97547943, -70.14850096,
-69.42463301],
[-68.04929881, -61.79753362, -71.66133888, -71.91191104,
-67.59880698],
[-64.06637325, -68.05777563, -65.03028967, -59.17884857,
-63.0505445 ],
[-63.12274935, -55.29097148, -53.36128522, -66.94969502,
-60.98361379],
[-67.73203889, -63.63096026, -65.05502532, -65.402428 ,
-60.94716493],
[-69.96895667, -65.22034478, -63.50678087, -69.28117514,
-64.31580285],
[-66.6373939 , -63.6005441 , -61.97606728, -57.24153384,
-67.16987572],
[-64.57064382, -60.28316306, -62.76899767, -65.74987775,
-58.26665072],
[-64.27699646, -65.76601637, -65.67659739, -63.01238502,
-70.6660922 ],
[-67.68242476, -66.27087257, -67.35161621, -74.80650906,
-69.201637 ],
[-61.04178972, -66.22890786, -71.24455469, -71.11295766,
-54.35076354],
[-64.79001429, -65.427282 , -68.40315586, -58.68397007,
-58.81260181],
[-52.65556798, -63.53188543, -63.74022238, -63.31323634,
-67.51363975],
[-61.54693631, -72.88076957, -69.13080241, -72.82297411,
-59.6158363 ],
[-69.66211149, -55.4691959 , -64.72564409, -69.62121322,
-72.4563239 ],
[-66.46310333, -69.42924536, -72.50537461, -61.58499387,
-71.37879475],
[-63.86762316, -65.28177778, -65.79612099, -54.47331493,
-62.36486248],
[-56.7473805 , -57.05021209, -73.25542168, -71.0237581 ,
-73.04586609],
[-64.83584712, -66.54226927, -63.79929562, -67.19535509,
-59.14546137],
[-68.19935454, -62.09465645, -58.75132537, -58.69446936,
-69.71885545],
[-61.37432888, -68.63208871, -71.87522013, -58.60885815,
-65.62875009],
[-70.10809188, -69.72495586, -62.43529562, -67.03855329,
-57.28733766],
[-66.65945047, -60.7421013 , -59.64148091, -67.31379776,
-61.49492421],
[-67.30199985, -62.93461843, -64.20371837, -59.66580464,
-63.49820175],
[-64.3661035 , -66.30868952, -63.09578787, -68.46070972,
-59.35540117],
[-65.06593105, -77.9979389 , -59.90708167, -69.98010894,
-55.94027225],
[-53.21114224, -67.99001473, -54.47601063, -57.50489976,
-62.79646074],
[-69.06222344, -63.60993974, -65.31336235, -65.91532232,
-61.13188103],
[-55.1785023 , -62.91586587, -63.48898849, -69.15458629,
-63.65156359],
[-60.02555887, -66.42131313, -62.53409559, -61.80664896,
-63.47599319],
[-60.025848 , -66.10730179, -70.02968044, -66.50086434,
-65.6975272 ],
[-66.32128205, -59.85068278, -68.4740642 , -69.69603035,
-64.37740456],
[-64.31168353, -69.4435551 , -63.69397736, -67.70613149,
-58.75179459],
[-69.23173287, -66.15784116, -61.7373839 , -65.07935575,
-53.41225762],
[-64.81293146, -54.8948751 , -71.74697472, -69.62996531,
-63.10361831],
[-65.21903149, -61.18180204, -70.10302143, -64.49900785,
-72.79649196],
[-67.07150589, -63.09650855, -64.13170821, -69.30116879,
-60.25333308],
[-69.12573298, -63.77655377, -58.94718084, -60.14105241,
-58.19608617],
[-54.6838396 , -62.51002907, -63.79371621, -67.64228655,
-69.46370119],
[-73.61401146, -67.40676254, -62.41728935, -64.17556984,
-59.54353496],
[-61.99239329, -74.88519148, -65.15683744, -61.99720803,
-53.73345448],
[-64.22701629, -62.07108315, -64.10314768, -69.25804813,
-67.96453705],
[-63.79500002, -65.6103585 , -64.0522586 , -65.56512634,
-61.55388511],
[-64.93236197, -65.78611499, -63.50892896, -58.95273309,
-65.13251406],
[-56.18086286, -68.8681917 , -75.35748034, -70.04523316,
-58.38864984],
[-62.71874394, -63.6508974 , -67.0928775 , -65.06276516,
-69.37451321],
[-68.39516727, -71.83797832, -65.22580775, -67.49477168,
-71.34470542],
[-74.06040565, -69.67440097, -62.35374062, -67.96838964,
-62.09942302],
[-61.06910377, -65.00923197, -70.10903798, -62.5719758 ,
-55.03569321],
[-62.73382606, -67.82884616, -68.82071624, -59.33866399,
-67.01088228],
[-69.50148909, -63.97329881, -70.79113826, -54.9559771 ,
-67.31713967],
[-63.36873853, -60.63951385, -58.03557808, -60.88274621,
-70.93151406],
[-65.47262644, -55.76303604, -76.61390627, -64.18739352,
-67.02973371],
[-66.62030165, -64.18279215, -65.97348742, -64.11886304,
-57.46214372],
[-71.21848081, -56.64897115, -68.98690637, -62.81036066,
-60.44839124],
[-73.87490724, -78.78538166, -66.89179245, -64.38024844,
-61.66809035],
[-66.35312942, -73.11205866, -74.87496893, -74.7410211 ,
-67.36647537],
[-59.18028885, -66.62926769, -68.21518842, -62.51241814,
-69.78957458],
[-66.84822251, -62.63658278, -56.76934494, -61.89288835,
-63.2591074 ],
[-57.39641723, -60.25170528, -64.76608239, -79.3614301 ,
-60.6315156 ],
[-68.20673938, -66.72046277, -60.18321123, -55.79294926,
-60.75459502],
[-68.04161257, -76.86186453, -63.8113867 , -70.38341939,
-62.85407922],
[-61.35461699, -63.22020593, -63.10213566, -67.4974073 ,
-75.92850328],
[-60.42229933, -65.58636815, -64.48130702, -68.61901355,
-60.08736656],
[-71.28539599, -60.57934205, -63.52956528, -65.61042364,
-65.35614404],
[-63.40861101, -69.33668508, -61.91859115, -68.83156146,
-62.2449264 ],
[-65.65947189, -61.84450967, -61.85459531, -65.64867604,
-64.16094122],
[-56.69156493, -71.95769498, -69.53874311, -63.09450476,
-68.23017828],
[-67.6474065 , -64.1005991 , -71.84136091, -64.29427689,
-58.58528256],
[-59.09267683, -68.80266343, -74.55344113, -70.36610984,
-70.11656784],
[-60.06803034, -65.29607342, -60.97918148, -55.72979875,
-66.5441961 ],
[-66.06660025, -65.27961698, -66.23233398, -58.24020052,
-70.61013767],
[-58.89532887, -60.24419224, -58.93047089, -65.8514343 ,
-62.96427402],
[-65.04496667, -65.63547766, -68.15976818, -68.37669105,
-72.82514065],
[-67.27853063, -53.48009558, -68.97975545, -69.43723258,
-67.60501641],
[-69.00695168, -63.26144588, -63.06728814, -62.03448123,
-65.68681415],
[-66.13567683, -67.04818455, -57.78702818, -65.19572949,
-68.39881616],
[-72.10041241, -67.44710377, -60.92882561, -58.39410148,
-58.73825935],
[-70.14158983, -64.54718691, -59.11617537, -57.0304193 ,
-63.643312 ],
[-70.9786209 , -64.24241632, -65.93284082, -61.07583229,
-69.60412624]]) * mV, [0.0 s, 0.1 s], sampling rate: 1.0 kHz)>, <AnalogSignal(array([[-64.26741518, -67.77534203, -66.57578715, -59.09100716,
-61.0007225 ],
[-62.98313657, -65.45763602, -63.29038229, -69.09389383,
-58.41202265],
[-65.75981953, -59.14921093, -58.98172455, -56.87962166,
-67.5499593 ],
...,
[-67.23610154, -70.0893392 , -68.42759677, -64.54915741,
-64.97977997],
[-61.18272884, -69.75241421, -53.8490009 , -74.31415993,
-66.10925834],
[-69.06829154, -65.83488383, -66.22752474, -71.6394647 ,
-64.3258971 ]], shape=(1000, 5)) * nA, [0.0 s, 0.1 s], sampling rate: 10.0 kHz)>] analogsignals
Since AnalogSignals
can contain data from multiple channels,
sometimes we wish to include only a subset of channels in a group.
For this, Neo provides the ChannelView
class, e.g.:
In [55]: from neo import ChannelView
In [56]: channel_of_interest = ChannelView(obj=signal1, index=[2])
In [57]: signal_with_spikes = Group(objects=(channel_of_interest, spike_train))
In [58]: signal_with_spikes
Out[58]: Group with [<SpikeTrain(array([3., 4., 5.]) * s, [0.0 s, 10.0 s])>] spiketrains, [<neo.core.view.ChannelView object at 0x7f49e2a3dcd0>] channelviews
Performance and memory consumption#
In some cases you may not wish to load everything in memory, because it could be too big, or you know you only need to access a subset of the data in a file.
For this scenario, some IO modules provide an optional argument to their read()
methods: lazy=True/False
.
With lazy=True
all data objects (AnalogSignal
/SpikeTrain
/Event
/Epoch
/ImageSequence
)
are replaced by proxy objects (AnalogSignalProxy
/SpikeTrainProxy
/EventProxy
/EpochProxy
/ImageSequenceProxy
).
By default (if not specified), lazy=False
, i.e. all data are loaded.
These proxy objects contain metadata (name
, sampling_rate
, …) so they can be inspected,
but they do not contain any array-like data.
When you want to load the actual data from a proxy object, use the load()
method
to return a real data object of the appropriate type.
Furthermore load()
has a time_slice
argument, which allows you to load only a slice of data from the file.
In this way the consumption of memory can be finely controlled.
Examples#
For more examples of using Neo, see Examples.
Citing Neo#
If you use Neo in your work, please mention the use of Neo in your Methods section,
using our RRID: RRID:SCR_000634
.
If you wish to cite Neo in publications, please use:
Garcia S., Guarino D., Jaillet F., Jennings T.R., Pröpper R., Rautenberg P.L., Rodgers C., Sobolev A.,Wachtler T., Yger P. and Davison A.P. (2014) Neo: an object model for handling electrophysiology data in multiple formats. Frontiers in Neuroinformatics 8:10: doi:10.3389/fninf.2014.00010
A BibTeX entry for LaTeX users is:
@article{neo14,
author = {Garcia S. and Guarino D. and Jaillet F. and Jennings T.R. and Pröpper R. and
Rautenberg P.L. and Rodgers C. and Sobolev A. and Wachtler T. and Yger P.
and Davison A.P.},
doi = {10.3389/fninf.2014.00010},
full_text = {https://www.frontiersin.org/articles/10.3389/fninf.2014.00010/full},
journal = {Frontiers in Neuroinformatics},
month = {February},
title = {Neo: an object model for handling electrophysiology data in multiple formats},
volume = {8:10},
year = {2014}
}