Previous topic

Examples

Next topic

Release notes

This Page

API Reference

Classes:

class neo.core.Block(name=None, description=None, file_origin=None, file_datetime=None, rec_datetime=None, index=None, **annotations)

Main container gathering all the data, whether discrete or continous, for a given recording session.

A block is not necessarily temporally homogeneous, in contrast to Segment.

Usage:

TODO

Required attributes/properties:
None
Recommended attributes/properties:
name:A label for the dataset
description:text description
file_origin:filesystem path or URL of the original data file.
file_datetime:the creation date and time of the original data file.
rec_datetime:the date and time of the original recording
index:integer. You can use this to define an ordering of your Block. It is not used by Neo in any way.
Container of:
Segment RecordingChannelGroup
Properties
list_units : descends through hierarchy and returns a list of
Unit existing in the block. This shortcut exists because a common analysis case is analyzing all neurons that you recorded in a session.
list_recordingchannels: descends through hierarchy and returns
a list of RecordingChannel existing in the block.
class neo.core.Segment(name=None, description=None, file_origin=None, file_datetime=None, rec_datetime=None, index=None, **annotations)

A Segment is a heterogeneous container for discrete or continous data sharing a common clock (time basis) but not necessary the same sampling rate, start or end time.

Usage:

TODO

Required attributes/properties:
None
Recommended attributes/properties:
name:A label for the dataset
description:text description
file_origin:filesystem path or URL of the original data file.
file_datetime:the creation date and time of the original data file.
rec_datetime:the date and time of the original recording
index:integer. You can use this to define a temporal ordering of your Segment. For instance you could use this for trial numbers.
Container of:
Epoch EpochArray Event EventArray AnalogSignal AnalogSignalArray IrregularlySampledSignal Spike SpikeTrain
class neo.core.RecordingChannelGroup(channel_names=None, channel_indexes=None, name=None, description=None, file_origin=None, **annotations)
This container have sereval purpose:

Usage 1 multi segment recording with 2 electrode array:

bl = Block()
# create a block with 3 Segment and 2 RecordingChannelGroup
for s in range(3):
    seg = Segment(name = 'segment %d' %s, index = s)
    bl.segments.append(seg)

for r in range(2):
    rcg = RecordingChannelGroup('Array probe %d' % r, channel_indexes =
                                arange(64) )
    bl.recordingchannelgroups.append(rcg)

# populating AnalogSignalArray
for s in range(3):
    for r in range(2):
        a = AnalogSignalArray( randn(10000, 64), sampling_rate =
                              10*pq.kHz )
        bl.recordingchannelgroups[r].append(a)
        bl.segments[s].append(a)

Usage 2 grouping channel:

bl = Block()
# Create a new RecordingChannelGroup and add to current block
rcg = RecordingChannelGroup(channel_names=['ch0', 'ch1', 'ch2'])
rcg.channel_indexes = [0, 1, 2]
bl.recordingchannelgroups.append(rcg)

for i in range(3):
    rc = RecordingChannel(index=i)
    rcg.recordingchannels.append(rc) # <- many to many relationship
    rc.recordingchannelgroups.append(rcg) # <- many to many
                                               relationship

Usage 3 dealing with Units:

bl = Block()
rcg = RecordingChannelGroup( name = 'octotrode A')
bl.recordingchannelgroups.append(rcg)

# create several Units
for i in range(5):
    u = Unit(name = 'unit %d' % i, description =
             'after a long and hard spike sorting')
    rcg.append(u)
Required attributes:
None
Recommended attributes:
channel_names:List of strings naming each channel
channel_indexes:
 List of integer indexes of each channel
name:string
description:string
file_origin:string
Container of:
RecordingChannel AnalogSignalArray Unit
class neo.core.RecordingChannel(index=0, coordinate=None, name=None, description=None, file_origin=None, **annotations)

A RecordingChannel is a container for AnalogSignal objects that come from the same logical and/or physical channel inside a Block.

Note that a RecordingChannel can belong to several RecordingChannelGroup.

Usage one Block with 3 Segment and 16 RecordingChannel and 48 AnalogSignal:

bl = Block()
# Create a new RecordingChannelGroup and add to current block
rcg = RecordingChannelGroup(name = 'all channels)
bl.recordingchannelgroups.append(rcg)

for c in range(16):
    rc = RecordingChannel(index=c)
    rcg.recordingchannels.append(rc) # <- many to many relationship
    rc.recordingchannelgroups.append(rcg) # <- many to many
                                               relationship

for s in range(3):
    seg = Segment(name = 'segment %d' %s, index = s)
    bl.segments.append(seg)

for c in range(16):
    for s in range(3):
        anasig = AnalogSignal( np.rand(100000), sampling_rate =
                               20*pq.Hz)
        bl.segments[s].analogsignals.append(anasig)
        rcg.recordingchannels[c].analogsignals.append(anasig)
Required attributes/properties:
index:(int) Index of the channel
Recommended attributes/properties:
coordinate:(Quantity) x, y, z
name:string
description:string
file_origin:string
Container of:
AnalogSignal IrregularlySampledSignal
class neo.core.AnalogSignal(signal, units=None, dtype=None, copy=True, t_start=array(0.0) * s, sampling_rate=None, sampling_period=None, name=None, file_origin=None, description=None, channel_index=None, **annotations)

A representation of a continuous, analog signal acquired at time t_start at a certain sampling rate.

Inherits from quantities.Quantity, which in turn inherits from :py:class:numpy.ndarray.

Usage:

>>> from quantities import ms, kHz, nA, uV
>>> import numpy as np
>>> a = AnalogSignal([1,2,3], sampling_rate=0.42*kHz, units='mV')
>>> b = AnalogSignal([4,5,6]*nA, sampling_period=42*ms)
>>> c = AnalogSignal(np.array([1.0, 2.0, 3.0]), t_start=42*ms,
...                  sampling_rate=0.42*kHz, units=uV)
Required attributes/properties:
signal:the data itself, as a Quantity array, NumPy array or list
units:required if the signal is a list or NumPy array, not if it is a Quantity
sampling_rate:or :sampling_period: Quantity, number of samples per unit time or interval between two samples. If both are specified, they are checked for consistency.
Recommended attributes/properties:
t_start:Quantity, time when signal begins. Default: 0.0 seconds

Note that the length of the signal array and the sampling rate are used to calculate t_stop and duration.

name:string
description:string
file_origin:string
Optional arguments:
dtype:
copy:(bool) True by default

Any other additional arguments are assumed to be user-specific metadata and stored in annotations:

>>> a = AnalogSignal([1,2,3], day='Monday')
>>> print a.annotations['day']
Monday
Properties available on this object:
sampling_rate, sampling_period, t_stop, duration
Operations available on this object:
== != + * /
class neo.core.AnalogSignalArray(signal, units=None, dtype=None, copy=True, t_start=array(0.0) * s, sampling_rate=None, sampling_period=None, name=None, file_origin=None, description=None, channel_index=None, **annotations)

A representation of several continuous, analog signals that have the same duration, sampling rate and start time. Basically, it is a 2D array like AnalogSignal: dim 0 is time, dim 1 is channel index

Inherits from quantities.Quantity, which in turn inherits from numpy.ndarray.

Usage:
TODO
Required attributes/properties:
t_start:time when signal begins
sampling_rate:or :sampling_period: Quantity, number of samples per unit time or interval between two samples. If both are specified, they are checked for consistency.
Properties:
sampling_period:
 interval between two samples (1/sampling_rate)
duration:signal duration (size * sampling_period)
t_stop:time when signal ends (t_start + duration)
Recommended attributes/properties:
name:
description:
file_origin:
class neo.core.IrregularlySampledSignal(times, signal, units=None, time_units=None, dtype=None, copy=True, name=None, description=None, file_origin=None, **annotations)

A representation of a continuous, analog signal acquired at time t_start with a varying sampling interval.

Usage:

>>> from quantities import ms, nA, uV
>>> import numpy as np
>>> a = IrregularlySampledSignal([0.0, 1.23, 6.78], [1,2,3], units='mV', time_units='ms')
>>> b = IrregularlySampledSignal([0.01, 0.03, 0.12]*s, [4,5,6]*nA)
Required attributes/properties:
times:NumPy array, Quantity array or list
signal:Numpy array, Quantity array or list of the same size as times
units:required if the signal is a list or NumPy array, not if it is a Quantity
time_units:required if times is a list or NumPy array, not if it is a Quantity
Optional arguments:
dtype:Data type of the signal (times are always floats)
Recommended attributes/properties:
name:
description:
file_origin:
class neo.core.Event(time, label, name=None, description=None, file_origin=None, **annotations)

Object to represent an event occurring at a particular time. Useful for managing trigger, stimulus, ...

Usage:

Required attributes/properties:
time:(quantity):
label:(str):
Recommended attributes/properties:
name:
description:
file_origin:
EventArray(times=array([], dtype=float64) * s, labels=array([],
dtype='|S1'), name=None, description=None, file_origin=None, **annotations)

Array of events. Introduced for performance reasons. An EventArray is prefered to a list of Event objects.

Usage:
TODO
Required attributes/properties:
times:(quantity array 1D)
labels:(numpy.array 1D dtype=’S’)
Recommended attributes/properties:
name:
description:
file_origin:
class neo.core.Epoch(time, duration, label, name=None, description=None, file_origin=None, **annotations)

Similar to Event but with a duration. Useful for describing a period, the state of a subject, ...

Usage:
TODO
Required attributes/properties:
time:(quantity)
duration:(quantity)
label:(str)
Recommended attributes/properties:
name:
description:
file_origin:
EpochArray(times=array([], dtype=float64) * s, durations=array([], dtype=float64) * s, labels=array([],
dtype='|S1'), name=None, description=None, file_origin=None, **annotations)

Array of epochs. Introduced for performance reason. An EpochArray is prefered to a list of Epoch objects.

Usage:
TODO
Required attributes/properties:
times:(quantity array 1D)
durations:(quantity array 1D)
labels:(numpy.array 1D dtype=’S’) )
Recommended attributes/properties:
name:
description:
file_origin:
class neo.core.Unit(name=None, description=None, file_origin=None, channel_indexes=None, **annotations)

A Unit regroups all the SpikeTrain objects that were emitted by a neuron during a Block. The spikes may come from different Segment objects within the Block, so this object is not contained in the usual Block/Segment /SpikeTrain hierarchy.

A Unit is linked to RecordingChannelGroup objects from which it was detected. With tetrodes, for instance, multiple channels may record the same unit.

This replaces the Neuron class in the previous version of Neo.

Usage:

# Store the spike times from a pyramidal neuron recorded on channel 0
u = neo.Unit(name='pyramidal neuron')

# first segment
st1 = neo.SpikeTrain(times=[.01, 3.3, 9.3], units='sec')
u.spiketrains.append(st1)

# second segment
st2 = neo.SpikeTrain(times=[100.01, 103.3, 109.3], units='sec')
u.spiketrains.append(st2)
Required attributes/properties:
None
Recommended attributes/properties:
name:
description:
file_origin:
Container of:
SpikeTrain Spike
class neo.core.Spike(time=array(0.0) * s, waveform=None, sampling_rate=None, left_sweep=None, name=None, description=None, file_origin=None, **annotations)

Object to represent one spike emitted by a Unit and represented by its time occurence and optional waveform.

Usage:
TODO
Required attributes/properties:
time:(quantity)
Recommended attributes/properties:
waveform:(quantity 2D (channel_index X time))
sampling_rate:
left_sweep:
name:
description:
file_origin:
Properties:
right_sweep:
duration:
class neo.core.SpikeTrain(times, t_stop, units=None, dtype=<type 'float'>, copy=True, sampling_rate=array(1.0) * Hz, t_start=array(0.0) * s, waveforms=None, left_sweep=None, name=None, file_origin=None, description=None, **annotations)

SpikeTrain is a Quantity array of spike times.

It is an ensemble of action potentials (spikes) emitted by the same unit in a period of time.

Required arguments:
times:a list, 1d numpy array, or quantity array, containing the times of each spike.
t_stop:time at which SpikeTrain ends. This will be converted to the same units as the data. This argument is required because it specifies the period of time over which spikes could have occurred. Note that t_start is highly recommended for the same reason.

Your spike times must have units. Preferably, times is a Quantity array with units of time. Otherwise, you must specify the keyword argument units.

If times contains values outside of the range [t_start, t_stop], an Exception is raised.

Recommended arguments:
t_start:time at which SpikeTrain began. This will be converted to the same units as the data. Default is zero seconds.
waveforms:the waveforms of each spike
sampling_rate:the sampling rate of the waveforms
left_sweep:Quantity, in units of time. Time from the beginning of the waveform to the trigger time of the spike.
sort:if True, the spike train will be sorted
name:string
description:string
file_origin:string

Any other keyword arguments are stored in the self.annotations dict.

Other arguments relating to implementation

dtype : data type (float32, float64, etc) copy : boolean, whether to copy the data or use a view.

These arguments, as well as units, are simply passed to the Quantity constructor.

Note that copy must be True when you request a change of units or dtype.

Slicing:
SpikeTrain objects can be sliced. When this occurs, a new SpikeTrain (actually a view) is returned, with the same metadata, except that waveforms is also sliced in the same way. Note that t_start and t_stop are not changed automatically, though you can still manually change them.
Example::
>>> st = SpikeTrain([3,4,5] * pq.s, t_stop=10.0)
>>> st2 = st[1:3]
>>> st.t_start
array(0.0) * s
>>> st2
<SpikeTrain(array([ 4.,  5.]) * s, [0.0 s, 10.0 s])>