experanto.interpolators.SpikeInterpolator
- class SpikeInterpolator(root_folder, cache_data=False, interpolation_window=0.3, interpolation_align='center', smoothing_sigma=0.0)[source]
Bases:
InterpolatorInterpolator for spike train data.
This interpolator reads raw spike times and computes spike counts within specified time windows around queried timestamps.
Data Storage Format:
The spike data must be stored in a flat 1D binary file named spikes.npy or spikes.mem (dtype: float64) inside the root_folder.
The array contains the actual continuous spike timings (e.g., in seconds). The timings must be blocked by neuron, and within each neuron’s block, the spike times must be sorted in ascending chronological order.
A meta.yml file in the same folder must provide a spike_indices list. This list defines the start and end indices for each neuron’s block in the flat array. For example, if neuron 0 has 50 spikes and neuron 1 has 30 spikes, spike_indices should be [0, 50, 80].
Parameters:
- root_folderstr
Path to the directory containing spikes.npy and meta.yml.
- cache_databool, optional
If True, eagerly loads the entire spike array into RAM (np.load) for faster access. If False, memory-maps the data from disk (np.memmap). Default is False.
- interpolation_windowfloat, optional
The size of the time window used to count spikes, in the same time units as the spike data. Default is 0.3.
- interpolation_alignstr, optional
Alignment of the interpolation window relative to the queried time t. - “center”: window is [t - window/2, t + window/2) - “left”: window is [t, t + window) - “right”: window is [t - window, t) Default is “center”.
- smoothing_sigmafloat, optional
Standard deviation for a Gaussian filter applied to the resulting spike counts along the time axis. The unit is in number of time steps (array indices), not physical time. If your times are 30Hz (33ms) and you want 100ms smoothing, sigma should be ~3. Set to 0.0 to disable smoothing. Default is 0.0.
Methods
__init__(root_folder[, cache_data, ...])close()create(root_folder[, cache_data])Factory method to create the appropriate interpolator for a modality.
interpolate(times[, return_valid])Map an array of time points to interpolated data values.
valid_times(times)- __init__(root_folder, cache_data=False, interpolation_window=0.3, interpolation_align='center', smoothing_sigma=0.0)[source]
- static create(root_folder, cache_data=False, **kwargs)
Factory method to create the appropriate interpolator for a modality.
Reads the
meta.ymlfile in the folder to determine the modality type and instantiates the corresponding interpolator subclass.- Parameters:
- Returns:
An instance of the appropriate interpolator subclass.
- Return type:
- Raises:
ValueError – If the modality type is not supported.
- load_meta()
- valid_times(times)