nept Objects

Objects in nept represent neural electrophysiology and behavioral data.

AnalogSignal

class nept.AnalogSignal(data, time)[source]

Bases: object

A continuous analog timestamped signal.

Parameters:

data : np.array

time : np.array

Attributes

data (np.array) With shape (n_samples, dimensionality).
time (np.array) With shape (n_samples,).
dimensions

(int) Dimensionality of data attribute.

isempty

(bool) Empty AnalogSignal.

n_samples

(int) Number of samples.

time_slice(t_starts, t_stops)[source]

Creates a new object corresponding to the time slice of the original between (and including) times t_start and t_stop. Setting either parameter to None uses infinite endpoints for the time interval.

Parameters:

analogsignal : nept.AnalogSignal

t_starts : float or list or None

t_stops : float or list or None

Returns:

sliced_analogsignal : nept.AnalogSignal

LocalFieldPotential

class nept.LocalFieldPotential(data, time)[source]

Bases: nept.core.analogsignal.AnalogSignal

Subclass of AnalogSignal.

Parameters:

data : np.array

time : np.array

Attributes

data (np.array) With shape (n_samples, 1).
time (np.array) With shape (n_samples,).

Position

class nept.Position(data, time)[source]

Bases: nept.core.analogsignal.AnalogSignal

Subclass of AnalogSignal. Handles both 1D and 2d positions.

Parameters:

data : np.array

time : np.array

Attributes

data (np.array) With shape (n_samples, dimensionality).
time (np.array) With shape (n_samples,).
distance(pos)[source]

Return the euclidean distance from this position to the given ‘pos’.

Parameters:pos : nept.Position
Returns:dist : np.array
linearize(ideal_path, zone)[source]

Projects 2D positions into an ‘ideal’ linear trajectory.

Parameters:

ideal_path : shapely.LineString

zone : shapely.Polygon

Returns:

pos : nept.Position

1D position.

speed(t_smooth=None)[source]

Finds the speed of the animal from position.

Parameters:

pos : nept.Position

t_smooth : float or None

Range over which smoothing occurs in seconds. Default is None (no smoothing).

Returns:

speed : nept.AnalogSignal

x

(np.array) The ‘x’ position attribute.

y

(np.array) The ‘y’ position attribute for 2D position data.

Epoch

class nept.Epoch(time, duration=None)[source]

Bases: object

An array of epochs, where each epoch has a start and stop time.

Parameters:

time : np.array

If shape (n_epochs, 1) or (n_epochs,), the start time for each epoch. If shape (n_epochs, 2), the start and stop times for each epoch.

duration : np.array or None, optional

The length of the epoch.

Attributes

time (np.array) The start and stop times for each epoch. With shape (n_epochs, 2).
centers

(np.array) The center of each epoch.

contains(value)[source]

Checks whether value is in any epoch.

Parameters:

epochs: nept.Epoch

value: float or int

Returns:

boolean

copy()[source]
durations

(np.array) The duration of each epoch.

expand(amount, direction='both')[source]

Expands epoch by the given amount.

Parameters:

amount : float

Amount (in time) to expand each epoch.

direction : str

Can be ‘both’, ‘start’, or ‘stop’. This specifies which direction to resize epoch.

Returns:

expanded_epochs : nept.Epoch

intersect(epoch)[source]

Finds intersection between two sets of epochs.

Parameters:epoch : nept.Epoch
Returns:intersect_epochs : nept.Epoch
isempty

(boolean) Whether the epoch array is empty.

join(epoch)[source]

Combines two sets of epochs.

Parameters:epoch : nept.Epoch
Returns:joined_epochs : nept.Epoch
merge(gap=0.0)[source]

Merges epochs that are close or overlapping.

Parameters:

gap : float, optional

Amount (in time) to consider epochs close enough to merge. Defaults to 0.0 (no gap).

Returns:

merged_epochs : nept.Epoch

n_epochs

(int) The number of epochs.

overlaps(epoch)[source]

Finds overlap between template epochs and epoch of interest.

Parameters:epoch : nept.Epoch
Returns:overlaps_epochs : nept.Epoch
shrink(amount, direction='both')[source]

Shrinks epoch by the given amount.

Parameters:

amount : float

Amount (in time) to shrink each epoch.

direction : str

Can be ‘both’, ‘start’, or ‘stop’. This specifies which direction to resize epoch.

Returns:

shrinked_epochs : nept.Epoch

start

(np.array) The start of the first epoch.

starts

(np.array) The start of each epoch.

stop

(np.array) The stop of the last epoch.

stops

(np.array) The stop of each epoch.

SpikeTrain

class nept.SpikeTrain(time, label=None)[source]

Bases: object

A set of spike times associated with an individual putative neuron.

Parameters:

time : np.array

label : str or None, optional

Information pertaining to the source of the spiketrain.

Attributes

time (np.array) With shape (n_samples,).
label (str or None) Information pertaining to the source of the spiketrain.
time_slice(t_starts, t_stops)[source]

Creates a new object corresponding to the time slice of the original between (and including) times t_start and t_stop. Setting either parameter to None uses infinite endpoints for the time interval.

Parameters:

spiketrain : nept.SpikeTrain

t_starts : float or list or None

t_stops : float or list or None

Returns:

sliced_spiketrain : nept.SpikeTrain