Recording & Sorting#
Base Recording#
- class BaseRecordingExtractorInterface(verbose: bool = False, es_key: str = 'ElectricalSeries', **source_data)[source]#
Bases:
BaseExtractorInterface
Parent class for all RecordingExtractorInterfaces.
- Parameters
verbose (bool, default: False) – If True, will print out additional information.
es_key (str, default: “ElectricalSeries”) – The key of this ElectricalSeries in the metadata dictionary.
source_data (dict) – The key-value pairs of extractor-specific arguments.
- keywords: tuple[str] = ('extracellular electrophysiology', 'voltage', 'recording')#
- ExtractorModuleName: Optional[str] = 'spikeinterface.extractors'#
- get_metadata_schema() dict [source]#
Compile metadata schema for the RecordingExtractor.
- Returns
The metadata schema dictionary containing definitions for Device, ElectrodeGroup, Electrodes, and optionally ElectricalSeries.
- Return type
dict
- get_metadata() DeepDict [source]#
Child DataInterface classes should override this to match their metadata.
- Returns
The metadata dictionary containing basic NWBFile metadata.
- Return type
- property channel_ids#
Gets the channel ids of the data.
- get_original_timestamps() Union[ndarray, list[numpy.ndarray]] [source]#
Retrieve the original unaltered timestamps for the data in this interface.
This function should retrieve the data on-demand by re-initializing the IO.
- Returns
timestamps – The timestamps for the data stream; if the recording has multiple segments, then a list of timestamps is returned.
- Return type
numpy.ndarray or list of numpy.ndarray
- get_timestamps() Union[ndarray, list[numpy.ndarray]] [source]#
Retrieve the timestamps for the data in this interface.
- Returns
timestamps – The timestamps for the data stream; if the recording has multiple segments, then a list of timestamps is returned.
- Return type
numpy.ndarray or list of numpy.ndarray
- set_aligned_timestamps(aligned_timestamps: ndarray)[source]#
Replace all timestamps for this interface with those aligned to the common session start time.
Must be in units seconds relative to the common ‘session_start_time’.
- Parameters
aligned_timestamps (numpy.ndarray) – The synchronized timestamps for data in this interface.
- set_aligned_segment_timestamps(aligned_segment_timestamps: list[numpy.ndarray])[source]#
Replace all timestamps for all segments in this interface with those aligned to the common session start time.
Must be in units seconds relative to the common ‘session_start_time’.
- Parameters
aligned_segment_timestamps (list of numpy.ndarray) – The synchronized timestamps for segment of data in this interface.
- set_aligned_starting_time(aligned_starting_time: float)[source]#
Align the starting time for this interface relative to the common session start time.
Must be in units seconds relative to the common ‘session_start_time’.
- Parameters
aligned_starting_time (float) – The starting time for all temporal data in this interface.
- set_aligned_segment_starting_times(aligned_segment_starting_times: list[float])[source]#
Align the starting time for each segment in this interface relative to the common session start time.
Must be in units seconds relative to the common ‘session_start_time’.
- Parameters
aligned_segment_starting_times (list of floats) – The starting time for each segment of data in this interface.
- set_probe(probe, group_mode: Literal['by_shank', 'by_probe'])[source]#
Set the probe information via a ProbeInterface object.
- Parameters
probe (probeinterface.Probe) – The probe object.
group_mode ({‘by_shank’, ‘by_probe’}) – How to group the channels. If ‘by_shank’, channels are grouped by the shank_id column. If ‘by_probe’, channels are grouped by the probe_id column. This is a required parameter to avoid the pitfall of using the wrong mode.
- has_probe() bool [source]#
Check if the recording extractor has probe information.
- Returns
True if the recording extractor has probe information, False otherwise.
- Return type
bool
- align_by_interpolation(unaligned_timestamps: ndarray, aligned_timestamps: ndarray)[source]#
Interpolate the timestamps of this interface using a mapping from some unaligned time basis to its aligned one.
Use this method if the unaligned timestamps of the data in this interface are not directly tracked by a primary system, but are known to occur between timestamps that are tracked, then align the timestamps of this interface by interpolating between the two.
An example could be a metronomic TTL pulse (e.g., every second) from a secondary data stream to the primary timing system; if the time references of this interface are recorded within the relative time of the secondary data stream, then their exact time in the primary system is inferred given the pulse times.
Must be in units seconds relative to the common ‘session_start_time’.
- Parameters
unaligned_timestamps (numpy.ndarray) – The timestamps of the unaligned secondary time basis.
aligned_timestamps (numpy.ndarray) – The timestamps aligned to the primary time basis.
- subset_recording(stub_test: bool = False)[source]#
Subset a recording extractor according to stub and channel subset options.
- Parameters
stub_test (bool, default: False) – If True, only a subset of frames will be included.
- Returns
The subsetted recording extractor.
- Return type
- add_to_nwbfile(nwbfile: NWBFile, metadata: Optional[dict] = None, stub_test: bool = False, starting_time: Optional[float] = None, write_as: Literal['raw', 'lfp', 'processed'] = 'raw', write_electrical_series: bool = True, iterator_type: Optional[str] = 'v2', iterator_opts: Optional[dict] = None, always_write_timestamps: bool = False)[source]#
Primary function for converting raw (unprocessed) RecordingExtractor data to the NWB standard.
- Parameters
nwbfile (NWBFile) – NWBFile to which the recording information is to be added
metadata (dict, optional) – metadata info for constructing the NWB file. Should be of the format:
metadata['Ecephys']['ElectricalSeries'] = dict(name=my_name, description=my_description)
starting_time (float, optional) – Sets the starting time of the ElectricalSeries to a manually set value.
stub_test (bool, default: False) – If True, will truncate the data to run the conversion faster and take up less memory.
write_as ({‘raw’, ‘processed’, ‘lfp’}, default=’raw’) – Specifies how to save the trace data in the NWB file. Options are: - ‘raw’: Save the data in the acquisition group. - ‘processed’: Save the data as FilteredEphys in a processing module. - ‘lfp’: Save the data as LFP in a processing module.
write_electrical_series (bool, default: True) – Electrical series are written in acquisition. If False, only device, electrode_groups, and electrodes are written to NWB.
iterator_type ({‘v2’}) – The type of DataChunkIterator to use. ‘v2’ is the locally developed RecordingExtractorDataChunkIterator, which offers full control over chunking
iterator_opts (dict, optional) – Dictionary of options for the RecordingExtractorDataChunkIterator (iterator_type=’v2’). Valid options are:
- buffer_gbfloat, default: 1.0
In units of GB. Recommended to be as much free RAM as available. Automatically calculates suitable buffer shape.
- buffer_shapetuple, optional
Manual specification of buffer shape to return on each iteration. Must be a multiple of chunk_shape along each axis. Cannot be set if buffer_gb is specified.
- chunk_mbfloat. default: 1.0
Should be below 1 MB. Automatically calculates suitable chunk shape.
- chunk_shapetuple, optional
Manual specification of the internal chunk shape for the HDF5 dataset. Cannot be set if chunk_mb is also specified.
- display_progressbool, default: False
Display a progress bar with iteration rate and estimated completion time.
- progress_bar_optionsdict, optional
Dictionary of keyword arguments to be passed directly to tqdm. See tqdm/tqdm for options.
always_write_timestamps (bool, default: False) – Set to True to always write timestamps. By default (False), the function checks if the timestamps are uniformly sampled, and if so, stores the data using a regular sampling rate instead of explicit timestamps. If set to True, timestamps will be written explicitly, regardless of whether the sampling rate is uniform.
Base Sorting#
- class BaseSortingExtractorInterface(verbose: bool = False, **source_data)[source]#
Bases:
BaseExtractorInterface
Primary class for all SortingExtractor interfaces.
- keywords: tuple[str] = ('extracellular electrophysiology', 'spike sorting')#
- ExtractorModuleName: Optional[str] = 'spikeinterface.extractors'#
- get_metadata_schema() dict [source]#
Compile metadata schema for the RecordingExtractor.
- Returns
The metadata schema dictionary containing definitions for Device, ElectrodeGroup, Electrodes, and UnitProperties.
- Return type
dict
- property units_ids#
Gets the units ids of the data.
- register_recording(recording_interface: BaseRecordingExtractorInterface)[source]#
- get_original_timestamps() ndarray [source]#
Retrieve the original unaltered timestamps for the data in this interface.
This function should retrieve the data on-demand by re-initializing the IO.
- Returns
timestamps – The timestamps for the data stream.
- Return type
numpy.ndarray
- get_timestamps() Union[ndarray, list[numpy.ndarray]] [source]#
Retrieve the timestamps for the data in this interface.
- Returns
timestamps – The timestamps for the data stream.
- Return type
numpy.ndarray
- set_aligned_timestamps(aligned_timestamps: ndarray)[source]#
Replace all timestamps for the attached interface with those aligned to the common session start time.
Must be in units seconds relative to the common ‘session_start_time’. Must have a single-segment RecordingInterface attached; call .register_recording(recording_interface=…) to accomplish this.
When a SortingInterface has a recording attached, it infers the timing via the frame indices of the timestamps from the corresponding recording segment. This method aligns the timestamps of that recording so that the SortingExtractor can automatically infer the timing from the frames.
- Parameters
aligned_timestamps (numpy.ndarray or list of numpy.ndarray) – The synchronized timestamps for data in this interface. If there is more than one segment in the sorting/recording pair, then
- set_aligned_segment_timestamps(aligned_segment_timestamps: list[numpy.ndarray])[source]#
Replace all timestamps for all segments in this interface with those aligned to the common session start time.
Must be in units seconds relative to the common ‘session_start_time’. Must have a multi-segment RecordingInterface attached by calling .register_recording(recording_interface=…).
- Parameters
aligned_segment_timestamps (list of numpy.ndarray) – The synchronized timestamps for segment of data in this interface.
- set_aligned_starting_time(aligned_starting_time: float)[source]#
Align the starting time for this interface relative to the common session start time.
Must be in units seconds relative to the common ‘session_start_time’.
- Parameters
aligned_starting_time (float) – The starting time for all temporal data in this interface.
- set_aligned_segment_starting_times(aligned_segment_starting_times: list[float])[source]#
Align the starting time for each segment in this interface relative to the common session start time.
Must be in units seconds relative to the common ‘session_start_time’.
- Parameters
aligned_segment_starting_times (list of floats) – The starting time for each segment of data in this interface.
- subset_sorting()[source]#
Generate a subset of the sorting extractor based on spike timing data.
This method identifies the earliest spike time across all units in the sorting extractor and creates a subset of the sorting data up to 110% of the earliest spike time. If the sorting extractor is associated with a recording, the subset is further limited by the total number of samples in the recording.
- Returns
A new SortingExtractor object representing the subset of the original sorting data, sliced from the start frame to the calculated end frame.
- Return type
SortingExtractor
- add_channel_metadata_to_nwb(nwbfile: NWBFile, metadata: Optional[DeepDict] = None)[source]#
Add channel metadata to an NWBFile object using information extracted from a SortingExtractor and optional metadata.
This function attempts to add devices, electrode groups, and electrodes to the NWBFile. If a recording is associated with the SortingExtractor, it is used for metadata addition. Otherwise, it attempts to create a dummy NumpyRecording based on the provided metadata. If neither is available, the function warns the user and skips the metadata addition.
- Parameters
nwbfile (NWBFile) – The NWBFile object to which the metadata is added.
metadata (Optional[DeepDict]) – Optional metadata to use for the addition of electrode-related data. If it’s provided, it should contain an “Ecephys” field with a nested “Electrodes” field.
- Return type
None
- Raises
Warning – If there’s no recording in the sorting extractor and no electrodes metadata in the provided metadata, a warning is raised and the function returns None.
Notes
This function adds metadata to the nwbfile in-place, meaning the nwbfile object is modified directly.
- add_to_nwbfile(nwbfile: NWBFile, metadata: Optional[DeepDict] = None, stub_test: bool = False, write_ecephys_metadata: bool = False, write_as: Literal['units', 'processing'] = 'units', units_name: str = 'units', units_description: str = 'Autogenerated by neuroconv.', unit_electrode_indices: Optional[list[list[int]]] = None)[source]#
Primary function for converting the data in a SortingExtractor to NWB format.
- Parameters
nwbfile (NWBFile) – Fill the relevant fields within the NWBFile object.
metadata (DeepDict) – Information for constructing the NWB file (optional) and units table descriptions. Should be of the format:
metadata["Ecephys"]["UnitProperties"] = dict(name=my_name, description=my_description)
stub_test (bool, default: False) – If True, will truncate the data to run the conversion faster and take up less memory.
write_ecephys_metadata (bool, default: False) – Write electrode information contained in the metadata.
write_as ({‘units’, ‘processing’}) – How to save the units table in the nwb file. Options: - ‘units’ will save it to the official NWBFile.Units position; recommended only for the final form of the data. - ‘processing’ will save it to the processing module to serve as a historical provenance for the official table.
units_name (str, default: ‘units’) – The name of the units table. If write_as==’units’, then units_name must also be ‘units’.
units_description (str, default: ‘Autogenerated by neuroconv.’)
unit_electrode_indices (list of lists of int, optional) – A list of lists of integers indicating the indices of the electrodes that each unit is associated with. The length of the list must match the number of units in the sorting extractor.
AlphaOmega#
- class AlphaOmegaRecordingInterface(folder_path: Annotated[pathlib.Path, PathType(path_type='dir')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
Primary data interface class for converting AlphaOmega recording data.
Uses the
AlphaOmegaRecordingExtractor
.Load and prepare data for AlphaOmega.
- Parameters
folder_path (string or Path) – Path to the folder of .mpx files.
verbose (boolean) – Allows verbose. Default is False.
es_key (str, default: “ElectricalSeries”)
- display_name: Union[str, None] = 'AlphaOmega Recording'#
- associated_suffixes: tuple[str] = ('.mpx',)#
- info: Union[str, None] = 'Interface class for converting AlphaOmega recording data.'#
- stream_id = 'RAW'#
Axona Recording#
Collection of Axona interfaces.
- class AxonaRecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
DataInterface for converting raw Axona data using a
AxonaRecordingExtractor
.- Parameters
file_path (FilePath) – Path to .bin file.
verbose (bool, optional, default: True)
es_key (str, default: “ElectricalSeries”)
- display_name: Union[str, None] = 'Axona Recording'#
- associated_suffixes: tuple[str] = ('.bin', '.set')#
- info: Union[str, None] = 'Interface for Axona recording data.'#
- class AxonaUnitRecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], noise_std: float = 3.5)[source]#
Bases:
AxonaRecordingInterface
Primary data interface class for converting a AxonaRecordingExtractor.
- Parameters
file_path (FilePath) – Path to .bin file.
verbose (bool, optional, default: True)
es_key (str, default: “ElectricalSeries”)
- display_name: Union[str, None] = 'Axona Units'#
- associated_suffixes: tuple[str] = ('.bin', '.set')#
- info: Union[str, None] = 'Interface for Axona recording data.'#
- class AxonaLFPDataInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')])[source]#
Bases:
BaseLFPExtractorInterface
Primary data interface class for converting Axona LFP data. Note that this interface is not lazy and will load all data into memory.
- Parameters
verbose (bool, default: False) – If True, will print out additional information.
es_key (str, default: “ElectricalSeries”) – The key of this ElectricalSeries in the metadata dictionary.
source_data (dict) – The key-value pairs of extractor-specific arguments.
- display_name: Union[str, None] = 'Axona LFP'#
- associated_suffixes: tuple[str] = ('.bin', '.set')#
- info: Union[str, None] = 'Interface for Axona LFP data.'#
- ExtractorName: Optional[str] = 'NumpyRecording'#
- class AxonaPositionDataInterface(file_path: str)[source]#
Bases:
BaseDataInterface
Primary data interface class for converting Axona position data.
- Parameters
file_path (str) – Path to .bin or .set file.
- display_name: Union[str, None] = 'Axona Position'#
- keywords: tuple[str] = ('position tracking',)#
- associated_suffixes: tuple[str] = ('.bin', '.set')#
- info: Union[str, None] = 'Interface for Axona position data.'#
Biocam Recording#
- class BiocamRecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
Primary data interface class for converting Biocam data.
Using the
BiocamRecordingExtractor
.Load and prepare data for Biocam.
- Parameters
file_path (string or Path) – Path to the .bwr file.
verbose (bool, default: False) – Allows verbose.
es_key (str, default: “ElectricalSeries”)
- display_name: Union[str, None] = 'Biocam Recording'#
- associated_suffixes: tuple[str] = ('.bwr',)#
- info: Union[str, None] = 'Interface for Biocam recording data.'#
Blackrock Recording#
- class BlackrockRecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], nsx_override: Optional[Annotated[pathlib.Path, PathType(path_type='file')]] = None, verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
Primary data interface class for converting Blackrock data using a
BlackrockRecordingExtractor
.Load and prepare data corresponding to Blackrock interface.
- Parameters
file_path (FilePath) – Path to the Blackrock file with suffix being .ns1, .ns2, .ns3, .ns4m .ns4, or .ns6
verbose (bool, default: True)
es_key (str, default: “ElectricalSeries”)
- display_name: Union[str, None] = 'Blackrock Recording'#
- associated_suffixes: tuple[str] = ('.ns0', '.ns1', '.ns2', '.ns3', '.ns4', '.ns5')#
- info: Union[str, None] = 'Interface for Blackrock recording data.'#
- class BlackrockSortingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], sampling_frequency: Optional[float] = None, verbose: bool = False)[source]#
Bases:
BaseSortingExtractorInterface
Primary data interface class for converting Blackrock spiking data.
- Parameters
file_path (str, Path) – The file path to the
.nev
datasampling_frequency (float, optional) – The sampling frequency for the sorting extractor. When the signal data is available (.ncs) those files will be used to extract the frequency automatically. Otherwise, the sampling frequency needs to be specified for this extractor to be initialized.
verbose (bool, default: False) – Enables verbosity
- display_name: Union[str, None] = 'Blackrock Sorting'#
- associated_suffixes: tuple[str] = ('.nev',)#
- info: Union[str, None] = 'Interface for Blackrock sorting data.'#
CellExplorer Sorting#
- add_channel_metadata_to_recoder(recording_extractor, folder_path: Path)[source]#
Main function to add channel metadata to a recording extractor from a CellExplorer session. The metadata is added as channel properties to the recording extractor.
- Parameters
recording_extractor (BaseRecording from spikeinterface) – The recording extractor to which the metadata will be added.
folder_path (str or Path) – The path to the directory containing the CellExplorer session.
- Returns
The same recording extractor passed in the recording_extractor argument, but with added metadata as channel properties.
- Return type
RecordingExtractor
Notes
The metadata for the channels is extracted from the basename.session.mat file. The logic of the extraction is described on the function:
add_channel_metadata_to_recorder_from_session_file.
Note that, while all the new data produced by CellExplorer should have a session.mat file, it is not clear if all the channel metadata is always available.
Besides, the current implementation also supports extracting channel metadata from the chanMap.mat file used by Kilosort. The logic of the extraction is described on the function:
add_channel_metadata_to_recorder_from_channel_map_file.
Bear in mind that this file is not always available for all datasets.
From the documentation we also know that channel data can also be found in the following files: * basename.ChannelName.channelinfo.mat: general data container for channel-wise dat * basename.chanCoords.channelinfo.mat: contains the coordinates of the electrodes in the probe * basename.ccf.channelinfo.mat: Allen Institute’s Common Coordinate Framework (CCF)
Detailed information can be found in the following link https://cellexplorer.org/datastructure/data-structure-and-format/#channels
Future versions of this function will support the extraction of this metadata from these files as well
- add_channel_metadata_to_recorder_from_session_file(recording_extractor, folder_path: Path)[source]#
Extracts channel metadata from the CellExplorer’s session.mat file and adds it to the given recording extractor as properties.
The metadata includes electrode groups, channel locations, and brain regions. The function will skip addition if the session.mat file is not found in the given session path. This is done to support calling the when using files produced by the old cellexplorer format (Buzcode) which does not have a session.mat file.
- Parameters
recording_extractor (BaseRecording from spikeinterface) – The recording extractor to which the metadata will be added.
folder_path (str or Path) – The path to the directory containing the CellExplorer session.
- Returns
The same recording extractor passed in the recording_extractor argument, but with added metadata as channel properties.
- Return type
RecordingExtractor
Notes
1. The channel locations are retrieved from the chanCoords field in the extracellular section of the session.mat file. They are set in the recording extractor using the set_channel_locations method.
2. The electrode group information is extracted from the electrodeGroups field in the extracellular section of the session.mat file. The groups are set in the recording extractor using the set_property method with the group key.
3. The brain region data is fetched from the brainRegions section of the session.mat file. The brain regions are set in the recording extractor using the set_property method with the brain_region key.
- add_channel_metadata_to_recorder_from_channel_map_file(recording_extractor, folder_path: Path)[source]#
Extracts channel metadata from the chanMap.mat file used by Kilosort and adds the properties to the given recording extractor as channel properties.
The metadata includes channel groups, channel locations, and channel names. The function will skip addition of properties if the chanMap.mat file is not found in the given session path.
- Parameters
recording_extractor (BaseRecording from spikeinterface) – The recording extractor to which the metadata will be added.
folder_path (Path or str) – The path to the directory containing the session.
- Returns
The same recording extractor passed in the recording_extractor argument, but with added metadata.
- Return type
RecordingExtractor
Notes
1. The channel locations are retrieved from the xcoords and ycoords fields in the chanMap.mat file. They are set in the recording extractor using the set_channel_locations method.
2. The channel groups are extracted from the connected field in the chanMap.mat file. The groups are set in the recording extractor using the set_property method with the group key.
3. The channel names are composed of the channel index and group, and are set in the recording extractor using the set_property method with the channel_name key.
4. Channel group names are created based on the group index and are set in the recording extractor using the set_property method with the group_name key.
- class CellExplorerRecordingInterface(folder_path: Annotated[pathlib.Path, PathType(path_type='dir')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
Adds raw and lfp data from binary files with the new CellExplorer format:
- Parameters
folder_path (Path or str) – The folder where the session data is located. It should contain a {folder.name}.session.mat file and the binary files {folder.name}.dat or {folder.name}.lfp for the LFP interface.
verbose (bool, default: Falsee) – Whether to output verbose text.
es_key (str, default: “ElectricalSeries” and “ElectricalSeriesLFP” for the LFP interface)
Notes
CellExplorer’s new format contains a basename.session.mat file containing rich metadata about the session. basename is the name of the session folder / directory and works as a session identifier.
Link to the documentation detailing the basename.session.mat structure: https://cellexplorer.org/datastructure/data-structure-and-format/#session-metadata
Specifically, we can use the following fields from basename.session.mat to create a recording extractor using BinaryRecordingExtractor from spikeinterface:
Sampling frequency
Gains
Dtype
Where the binary file is named basename.dat for the raw data and basename.lfp for lfp data.
The extraction of channel metadata is described in the function: add_channel_metadata_to_recoder
- Parameters
folder_path (str) – Folder containing the .session.mat file.
verbose (bool, default=True)
es_key (str, default=”ElectricalSeries”)
- display_name: Union[str, None] = 'CellExplorer Recording'#
- associated_suffixes: tuple[str] = ('.dat', '.session', '.sessionInfo', '.mat')#
- info: Union[str, None] = 'Interface for CellExplorer recording data.'#
- sampling_frequency_key = 'sr'#
- binary_file_extension = 'dat'#
- classmethod get_source_schema() dict [source]#
Infer the JSON schema for the source_data from the method signature (annotation typing).
- Returns
The JSON schema for the source_data.
- Return type
dict
- get_original_timestamps()[source]#
Retrieve the original unaltered timestamps for the data in this interface.
This function should retrieve the data on-demand by re-initializing the IO.
- Returns
timestamps – The timestamps for the data stream; if the recording has multiple segments, then a list of timestamps is returned.
- Return type
numpy.ndarray or list of numpy.ndarray
- class CellExplorerLFPInterface(folder_path: Annotated[pathlib.Path, PathType(path_type='dir')], verbose: bool = False, es_key: str = 'ElectricalSeriesLFP')[source]#
Bases:
CellExplorerRecordingInterface
Adds lfp data from binary files with the new CellExplorer format:
See the CellExplorerRecordingInterface class for more information.
- Parameters
folder_path (str) – Folder containing the .session.mat file.
verbose (bool, default=True)
es_key (str, default=”ElectricalSeries”)
- display_name: Union[str, None] = 'CellExplorer LFP'#
- keywords: tuple[str] = ('extracellular electrophysiology', 'voltage', 'recording', 'extracellular electrophysiology', 'LFP', 'local field potential', 'LF')#
- associated_suffixes: tuple[str] = ('.lfp', '.session', '.mat')#
- info: Union[str, None] = 'Interface for CellExplorer LFP recording data.'#
- sampling_frequency_key = 'srLfp'#
- binary_file_extension = 'lfp'#
- add_to_nwbfile(nwbfile: NWBFile, metadata: Optional[dict] = None, stub_test: bool = False, starting_time: Optional[float] = None, write_as: Literal['raw', 'lfp', 'processed'] = 'lfp', write_electrical_series: bool = True, compression: Optional[str] = 'gzip', compression_opts: Optional[int] = None, iterator_type: str = 'v2', iterator_opts: Optional[dict] = None)[source]#
Primary function for converting raw (unprocessed) RecordingExtractor data to the NWB standard.
- Parameters
nwbfile (NWBFile) – NWBFile to which the recording information is to be added
metadata (dict, optional) – metadata info for constructing the NWB file. Should be of the format:
metadata['Ecephys']['ElectricalSeries'] = dict(name=my_name, description=my_description)
starting_time (float, optional) – Sets the starting time of the ElectricalSeries to a manually set value.
stub_test (bool, default: False) – If True, will truncate the data to run the conversion faster and take up less memory.
write_as ({‘raw’, ‘processed’, ‘lfp’}, default=’raw’) – Specifies how to save the trace data in the NWB file. Options are: - ‘raw’: Save the data in the acquisition group. - ‘processed’: Save the data as FilteredEphys in a processing module. - ‘lfp’: Save the data as LFP in a processing module.
write_electrical_series (bool, default: True) – Electrical series are written in acquisition. If False, only device, electrode_groups, and electrodes are written to NWB.
iterator_type ({‘v2’}) – The type of DataChunkIterator to use. ‘v2’ is the locally developed RecordingExtractorDataChunkIterator, which offers full control over chunking
iterator_opts (dict, optional) – Dictionary of options for the RecordingExtractorDataChunkIterator (iterator_type=’v2’). Valid options are:
- buffer_gbfloat, default: 1.0
In units of GB. Recommended to be as much free RAM as available. Automatically calculates suitable buffer shape.
- buffer_shapetuple, optional
Manual specification of buffer shape to return on each iteration. Must be a multiple of chunk_shape along each axis. Cannot be set if buffer_gb is specified.
- chunk_mbfloat. default: 1.0
Should be below 1 MB. Automatically calculates suitable chunk shape.
- chunk_shapetuple, optional
Manual specification of the internal chunk shape for the HDF5 dataset. Cannot be set if chunk_mb is also specified.
- display_progressbool, default: False
Display a progress bar with iteration rate and estimated completion time.
- progress_bar_optionsdict, optional
Dictionary of keyword arguments to be passed directly to tqdm. See tqdm/tqdm for options.
always_write_timestamps (bool, default: False) – Set to True to always write timestamps. By default (False), the function checks if the timestamps are uniformly sampled, and if so, stores the data using a regular sampling rate instead of explicit timestamps. If set to True, timestamps will be written explicitly, regardless of whether the sampling rate is uniform.
- class CellExplorerSortingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], verbose: bool = False)[source]#
Bases:
BaseSortingExtractorInterface
Primary data interface class for converting Cell Explorer spiking data.
Initialize read of Cell Explorer file.
- Parameters
file_path (FilePath) – Path to .spikes.cellinfo.mat file.
verbose (bool, default: True)
- display_name: Union[str, None] = 'CellExplorer Sorting'#
- associated_suffixes: tuple[str] = ('.mat', '.sessionInfo', '.spikes', '.cellinfo')#
- info: Union[str, None] = 'Interface for CellExplorer sorting data.'#
- generate_recording_with_channel_metadata()[source]#
Generate a dummy recording extractor with channel metadata from session data.
This method reads session data from a .session.mat file (if available) and generates a dummy recording extractor. The recording extractor is then populated with channel metadata extracted from the session file.
- Returns
A NumpyRecording object representing the dummy recording extractor, containing the channel metadata.
- Return type
NumpyRecording
Notes
The method reads the .session.mat file using pymatreader and extracts extracellular data.
It creates a dummy recording extractor using spikeinterface.core.numpyextractors.NumpyRecording.
The generated extractor includes channel IDs and other relevant metadata such as number of channels,
number of samples, and sampling frequency. - Channel metadata is added to the dummy extractor using the add_channel_metadata_to_recoder function. - If the .session.mat file is not found, no extractor is returned.
Warning
Ensure that the .session.mat file is correctly located in the expected session path, or the method will not generate a recording extractor. The expected session is self.session_path / f”{self.session_id}.session.mat”
European Data Format (EDF) Recording#
- class EDFRecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries', channels_to_skip: Optional[list] = None)[source]#
Bases:
BaseRecordingExtractorInterface
Data interface class for converting European Data Format (EDF) data using the
EDFRecordingExtractor
.Not supported for Python 3.8 and 3.9 on M1 macs.
Load and prepare data for EDF. Currently, only continuous EDF+ files (EDF+C) and original EDF files (EDF) are supported
- Parameters
file_path (str or Path) – Path to the edf file
verbose (bool, default: Falseeeeee) – Allows verbose.
es_key (str, default: “ElectricalSeries”) – Key for the ElectricalSeries metadata
channels_to_skip (list, default: None) – Channels to skip when adding the data to the nwbfile. These parameter can be used to skip non-neural channels that are present in the EDF file.
- display_name: Union[str, None] = 'EDF Recording'#
- keywords: tuple[str] = ('extracellular electrophysiology', 'voltage', 'recording', 'European Data Format')#
- associated_suffixes: tuple[str] = ('.edf',)#
- info: Union[str, None] = 'Interface for European Data Format (EDF) recording data.'#
Intan Recording#
- class IntanRecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries', ignore_integrity_checks: bool = False)[source]#
Bases:
BaseRecordingExtractorInterface
Primary data interface class for converting Intan data using the
IntanRecordingExtractor
.Load and prepare raw data and corresponding metadata from the Intan format (.rhd or .rhs files).
- Parameters
file_path (FilePath) – Path to either a rhd or a rhs file
verbose (bool, default: False) – Verbose
es_key (str, default: “ElectricalSeries”)
ignore_integrity_checks, bool, default (False.) – If True, data that violates integrity assumptions will be loaded. At the moment the only integrity check performed is that timestamps are continuous. If False, an error will be raised if the check fails.
- display_name: Union[str, None] = 'Intan Recording'#
- associated_suffixes: tuple[str] = ('.rhd', '.rhs')#
- info: Union[str, None] = 'Interface for Intan recording data.'#
- stream_id = '0'#
- classmethod get_source_schema() dict [source]#
Infer the JSON schema for the source_data from the method signature (annotation typing).
- Returns
The JSON schema for the source_data.
- Return type
dict
KiloSort Sorting#
- class KiloSortSortingInterface(folder_path: Annotated[pathlib.Path, PathType(path_type='dir')], keep_good_only: bool = False, verbose: bool = False)[source]#
Bases:
BaseSortingExtractorInterface
Primary data interface class for converting a KiloSortingExtractor from spikeinterface.
Load and prepare sorting data for kilosort
- Parameters
folder_path (str or Path) – Path to the output Phy folder (containing the params.py)
keep_good_only (bool, default: False) – If True, only Kilosort-labeled ‘good’ units are returned
verbose (bool, default: True)
- display_name: Union[str, None] = 'KiloSort Sorting'#
- associated_suffixes: tuple[str] = ('.npy',)#
- info: Union[str, None] = 'Interface for KiloSort sorting data.'#
MaxOne Recording#
- class MaxOneRecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], hdf5_plugin_path: Optional[Annotated[pathlib.Path, PathType(path_type='dir')]] = None, download_plugin: bool = True, verbose: bool = False, es_key: str = 'ElectricalSeries') None [source]#
Bases:
BaseRecordingExtractorInterface
Primary data interface class for converting MaxOne data.
Using the
MaxwellRecordingExtractor
.Load and prepare data for MaxOne.
- Parameters
file_path (string or Path) – Path to the .raw.h5 file.
hdf5_plugin_path (string or Path, optional) – Path to your systems HDF5 plugin library. Uses the home directory by default.
download_plugin (boolean, default: True) – Whether to force download of the decompression plugin. It’s a very lightweight install but does require an internet connection. This is left as True for seamless passive usage and should not impact performance.
verbose (boolean, default: True) – Allows verbosity.
es_key (str, default: “ElectricalSeries”) – The key of this ElectricalSeries in the metadata dictionary.
- display_name: Union[str, None] = 'MaxOne Recording'#
- associated_suffixes: tuple[str] = ('.raw', '.h5')#
- info: Union[str, None] = 'Interface for MaxOne recording data.'#
- ExtractorName: Optional[str] = 'MaxwellRecordingExtractor'#
- static auto_install_maxwell_hdf5_compression_plugin(hdf5_plugin_path: Optional[Path] = None, download_plugin: bool = True) None [source]#
If you do not yet have the Maxwell compression plugin installed, this function will automatically install it.
- Parameters
hdf5_plugin_path (string or Path, optional) – Path to your systems HDF5 plugin library. Uses the home directory by default.
download_plugin (boolean, default: True) – Whether to force download of the decompression plugin. It’s a very lightweight install but does require an internet connection. This is left as True for seamless passive usage and should not impact performance.
MEArec Recording#
- class MEArecRecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
Primary data interface class for converting MEArec recording data.
Uses the
MEArecRecordingExtractor
.Load and prepare data for MEArec.
- Parameters
folder_path (str or Path) – Path to the MEArec .h5 file.
verbose (bool, default: Falsee) – Allows verbose.
es_key (str, default: “ElectricalSeries”)
- display_name: Union[str, None] = 'MEArec Recording'#
- associated_suffixes: tuple[str] = ('.h5',)#
- info: Union[str, None] = 'Interface for MEArec recording data.'#
Neuralynx Recording & Sorting#
- class NeuralynxRecordingInterface(folder_path: Annotated[pathlib.Path, PathType(path_type='dir')], stream_name: Optional[str] = None, verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
Primary data interface for converting Neuralynx data. Uses
NeuralynxRecordingExtractor
.Initialize reading of OpenEphys binary recording.
- Parameters
folder_path (FolderPathType) – Path to Neuralynx directory.
stream_name (str, optional) – The name of the recording stream to load; only required if there is more than one stream detected. Call NeuralynxRecordingInterface.get_stream_names(folder_path=…) to see what streams are available.
verbose (bool, default: False)
es_key (str, default: “ElectricalSeries”)
- display_name: Union[str, None] = 'Neuralynx Recording'#
- associated_suffixes: tuple[str] = ('.ncs', '.nse', '.ntt', '.nse', '.nev')#
- info: Union[str, None] = 'Interface for Neuralynx recording data.'#
- class NeuralynxSortingInterface(folder_path: Annotated[pathlib.Path, PathType(path_type='dir')], sampling_frequency: Optional[float] = None, verbose: bool = False, stream_id: Optional[str] = None)[source]#
Bases:
BaseSortingExtractorInterface
Primary data interface for converting Neuralynx sorting data. Uses
NeuralynxSortingExtractor
._summary_
- Parameters
folder_path (str, Path) – The path to the folder/directory containing the data files for the session (nse, ntt, nse, nev)
sampling_frequency (float, optional) – If a specific sampling_frequency is desired it can be set with this argument.
verbose (bool, default: False) – Enables verbosity
stream_id (str, optional) – Used by Spikeinterface and neo to calculate the t_start, if not provided and the stream is unique it will be chosen automatically
- display_name: Union[str, None] = 'Neuralynx Sorting'#
- associated_suffixes: tuple[str] = ('.nse', '.ntt', '.nse', '.nev')#
- info: Union[str, None] = 'Interface for Neuralynx sorting data.'#
- extract_neo_header_metadata(neo_reader) dict [source]#
Extract the session metadata from a NeuralynxRawIO object
- Parameters
neo_reader (NeuralynxRawIO object) – Neo IO to extract the metadata from
- Returns
dictionary containing the session metadata across channels Uses the mu character, which may cause problems for downstream things that expect ASCII.
- Return type
dict
NeuroScope Recording & Sorting#
- filter_non_neural_channels(recording_extractor, xml_file_path: str)[source]#
Subsets the recording extractor to only use channels corresponding to neural data.
- Parameters
recording_extractor (BaseExtractor from spikeinterface) – The original recording extractor object.
xml_file_path (str) – Path to the XML file containing the Neuroscope metadata.
- Returns
The subset recording extractor object.
- Return type
BaseExtractor from spikeinterface
Notes
This function subsets the given recording extractor to include only channels that correspond to neural data, filtering out auxiliary channels.
To identify the neural channels, it relies on the get_neural_channels function in the neuroscope_utils.py module. Please refer to that function for more details and warnings.
If no neural channels are found o during the process, the original recording extractor is returned unchanged. If all the channels in the original recording extractor are neural channels, then the original recording extractor is returned unchanged as well.
- add_recording_extractor_properties(recording_extractor, gain: Optional[float] = None)[source]#
Automatically add properties to RecordingExtractor object.
- class NeuroScopeRecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], gain: Optional[float] = None, xml_file_path: Optional[Annotated[pathlib.Path, PathType(path_type='file')]] = None, verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
Primary data interface for converting a NeuroScope data. Uses
NeuroScopeRecordingExtractor
.Load and prepare raw acquisition data and corresponding metadata from the Neuroscope format (.dat files).
- Parameters
file_path (FilePath) – Path to .dat file.
gain (Optional[float], optional) – Conversion factors from int16 to Volts are not contained in xml_file_path; set them explicitly here. Most common value is 0.195 for an intan recording system. The default is None.
xml_file_path (FilePath, optional) – Path to .xml file containing device and electrode configuration. If unspecified, it will be automatically set as the only .xml file in the same folder as the .dat file. The default is None.
es_key (str, default: “ElectricalSeries”)
- display_name: Union[str, None] = 'NeuroScope Recording'#
- associated_suffixes: tuple[str] = ('.dat', '.xml')#
- info: Union[str, None] = 'Interface for converting NeuroScope recording data.'#
- classmethod get_source_schema() dict [source]#
Infer the JSON schema for the source_data from the method signature (annotation typing).
- Returns
The JSON schema for the source_data.
- Return type
dict
- static get_ecephys_metadata(xml_file_path: str) dict [source]#
Auto-populates ecephys metadata from the xml_file_path.
- Parameters
xml_file_path (str) – Path to the XML file containing device and electrode configuration.
- Returns
Dictionary containing metadata for ElectrodeGroup and Electrodes. Includes group names, descriptions, and electrode properties.
- Return type
dict
- get_metadata() dict [source]#
Child DataInterface classes should override this to match their metadata.
- Returns
The metadata dictionary containing basic NWBFile metadata.
- Return type
- get_original_timestamps() ndarray [source]#
Retrieve the original unaltered timestamps for the data in this interface.
This function should retrieve the data on-demand by re-initializing the IO.
- Returns
timestamps – The timestamps for the data stream; if the recording has multiple segments, then a list of timestamps is returned.
- Return type
numpy.ndarray or list of numpy.ndarray
- class NeuroScopeLFPInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], gain: Optional[float] = None, xml_file_path: Optional[Annotated[pathlib.Path, PathType(path_type='file')]] = None)[source]#
Bases:
BaseLFPExtractorInterface
Primary data interface class for converting Neuroscope LFP data.
Load and prepare lfp data and corresponding metadata from the Neuroscope format (.eeg or .lfp files).
- Parameters
file_path (FilePath) – Path to .lfp or .eeg file.
gain (float, optional) – Conversion factors from int16 to Volts are not contained in xml_file_path; set them explicitly here. Most common value is 0.195 for an intan recording system. The default is None.
xml_file_path (OptionalFilePath, optional) – Path to .xml file containing device and electrode configuration. If unspecified, it will be automatically set as the only .xml file in the same folder as the .dat file. The default is None.
- display_name: Union[str, None] = 'NeuroScope LFP'#
- associated_suffixes: tuple[str] = ('.lfp', '.eeg', '.xml')#
- info: Union[str, None] = 'Interface for converting NeuroScope LFP data.'#
- ExtractorName: Optional[str] = 'NeuroScopeRecordingExtractor'#
- class NeuroScopeSortingInterface(folder_path: Annotated[pathlib.Path, PathType(path_type='dir')], keep_mua_units: bool = True, exclude_shanks: Optional[list[int]] = None, xml_file_path: Optional[Annotated[pathlib.Path, PathType(path_type='file')]] = None, verbose: bool = False)[source]#
Bases:
BaseSortingExtractorInterface
Primary data interface class for converting a NeuroscopeSortingExtractor.
Load and prepare spike sorted data and corresponding metadata from the Neuroscope format (.res/.clu files).
- Parameters
folder_path (FolderPathType) – Path to folder containing .clu and .res files.
keep_mua_units (bool, default: True) – Optional. Whether to return sorted spikes from multi-unit activity.
exclude_shanks (list of integers, optional) – List of indices to ignore. The set of all possible indices is chosen by default, extracted as the final integer of all the .res.%i and .clu.%i pairs.
xml_file_path (FilePath, optional) – Path to .xml file containing device and electrode configuration. If unspecified, it will be automatically set as the only .xml file in the same folder as the .dat file. The default is None.
- display_name: Union[str, None] = 'NeuroScope Sorting'#
- associated_suffixes: tuple[str] = ('.res', '.clu', '.res.*', '.clu.*', '.xml')#
- info: Union[str, None] = 'Interface for converting NeuroScope recording data.'#
OpenEphys Recording#
- class OpenEphysRecordingInterface(verbose: bool = False, es_key: str = 'ElectricalSeries', **source_data)[source]#
Bases:
BaseRecordingExtractorInterface
Abstract class that defines which interface class to use for a given Open Ephys recording.
- Parameters
verbose (bool, default: False) – If True, will print out additional information.
es_key (str, default: “ElectricalSeries”) – The key of this ElectricalSeries in the metadata dictionary.
source_data (dict) – The key-value pairs of extractor-specific arguments.
- display_name: Union[str, None] = 'OpenEphys Recording'#
- associated_suffixes: tuple[str] = ('.dat', '.oebin', '.npy')#
- info: Union[str, None] = 'Interface for converting any OpenEphys recording data.'#
- ExtractorName: Optional[str] = 'OpenEphysBinaryRecordingExtractor'#
- classmethod get_source_schema() dict [source]#
Infer the JSON schema for the source_data from the method signature (annotation typing).
- Returns
The JSON schema for the source_data.
- Return type
dict
- classmethod get_stream_names(folder_path: Path) list[str] [source]#
Get the names of available recording streams in the OpenEphys folder.
- Parameters
folder_path (DirectoryPath) – Path to OpenEphys directory (.continuous or .dat files).
- Returns
The names of the available recording streams.
- Return type
list of str
- Raises
AssertionError – If the data is neither in ‘legacy’ (.continuous) nor ‘binary’ (.dat) format.
- static __new__(cls, folder_path: Path, stream_name: Optional[str] = None, block_index: Optional[int] = None, verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Abstract class that defines which interface class to use for a given Open Ephys recording.
For “legacy” format (.continuous files) the interface redirects to OpenEphysLegacyRecordingInterface. For “binary” format (.dat files) the interface redirects to OpenEphysBinaryRecordingInterface.
- Parameters
folder_path (FolderPathType) – Path to OpenEphys directory (.continuous or .dat files).
stream_name (str, optional) – The name of the recording stream. When the recording stream is not specified the channel stream is chosen if available. When channel stream is not available the name of the stream must be specified.
block_index (int, optional, default: None) – The index of the block to extract from the data.
verbose (bool, default: False)
es_key (str, default: “ElectricalSeries”)
Phy Sorting#
- class PhySortingInterface(folder_path: Annotated[pathlib.Path, PathType(path_type='dir')], exclude_cluster_groups: Optional[list[str]] = None, verbose: bool = False)[source]#
Bases:
BaseSortingExtractorInterface
Primary data interface class for converting Phy data. Uses
PhySortingExtractor
.Initialize a PhySortingInterface.
- Parameters
folder_path (str or Path) – Path to the output Phy folder (containing the params.py).
exclude_cluster_groups (str or list of str, optional) – Cluster groups to exclude (e.g. “noise” or [“noise”, “mua”]).
verbose (bool, default: Falsee)
- display_name: Union[str, None] = 'Phy Sorting'#
- associated_suffixes: tuple[str] = ('.npy',)#
- info: Union[str, None] = 'Interface for Phy sorting data.'#
- classmethod get_source_schema() dict [source]#
Infer the JSON schema for the source_data from the method signature (annotation typing).
- Returns
The JSON schema for the source_data.
- Return type
dict
- add_to_nwbfile(nwbfile: NWBFile, metadata: Optional[DeepDict] = None, stub_test: bool = False, write_ecephys_metadata: bool = False, write_as: Literal['units', 'processing'] = 'units', units_name: str = 'units', units_description: str = 'Imported from Phy', include_max_channel: bool = True)[source]#
Primary function for converting the data in a SortingExtractor to NWB format.
- Parameters
nwbfile (NWBFile) – Fill the relevant fields within the NWBFile object.
metadata (DeepDict) – Information for constructing the NWB file (optional) and units table descriptions. Should be of the format:
metadata["Ecephys"]["UnitProperties"] = dict(name=my_name, description=my_description)
stub_test (bool, default: False) – If True, will truncate the data to run the conversion faster and take up less memory.
write_ecephys_metadata (bool, default: False) – Write electrode information contained in the metadata.
write_as ({‘units’, ‘processing’}) – How to save the units table in the nwb file. Options: - ‘units’ will save it to the official NWBFile.Units position; recommended only for the final form of the data. - ‘processing’ will save it to the processing module to serve as a historical provenance for the official table.
units_name (str, default: ‘units’) – The name of the units table. If write_as==’units’, then units_name must also be ‘units’.
units_description (str, default: ‘Autogenerated by neuroconv.’)
unit_electrode_indices (list of lists of int, optional) – A list of lists of integers indicating the indices of the electrodes that each unit is associated with. The length of the list must match the number of units in the sorting extractor.
Plexon Recording & Sorting#
- class PlexonRecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries', stream_name: str = 'WB-Wideband')[source]#
Bases:
BaseRecordingExtractorInterface
Primary data interface class for converting Plexon data.
Uses the
PlexonRecordingExtractor
.Load and prepare data for Plexon.
- Parameters
file_path (str or Path) – Path to the .plx file.
verbose (bool, default: Falsee) – Allows verbosity.
es_key (str, default: “ElectricalSeries”)
stream_name (str, optional) – Only pass a stream if you modified the channel prefixes in the Plexon file and you know the prefix of the wideband data.
- display_name: Union[str, None] = 'Plexon Recording'#
- associated_suffixes: tuple[str] = ('.plx',)#
- info: Union[str, None] = 'Interface for Plexon recording data.'#
- class PlexonLFPInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeriesLF', stream_name: str = 'FPl-Low Pass Filtered')[source]#
Bases:
BaseLFPExtractorInterface
Primary data interface class for converting Plexon LFP data.
Uses the
PlexonRecordingExtractor
.Load and prepare data for Plexon.
- Parameters
file_path (str or Path) – Path to the .plx file.
verbose (bool, default: False) – Allows verbosity.
es_key (str, default: “ElectricalSeries”)
stream_name (str, default: “FPl-Low Pass Filtered””) – Only pass a stream if you modified the channel prefixes in the Plexon file and you know the prefix of the FPllow pass filtered data.
- display_name: Union[str, None] = 'Plexon LFP Recording'#
- associated_suffixes: tuple[str] = ('.plx',)#
- info: Union[str, None] = 'Interface for Plexon low pass filtered data.'#
- ExtractorName: Optional[str] = 'PlexonRecordingExtractor'#
- class Plexon2RecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
Primary data interface class for converting Plexon2 data.
Uses the
Plexon2RecordingExtractor
.Load and prepare data for Plexon.
- Parameters
file_path (str or Path) – Path to the .plx file.
verbose (bool, default: False) – Allows verbosity.
es_key (str, default: “ElectricalSeries”)
- display_name: Union[str, None] = 'Plexon2 Recording'#
- associated_suffixes: tuple[str] = ('.pl2',)#
- info: Union[str, None] = 'Interface for Plexon2 recording data.'#
- class PlexonSortingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], verbose: bool = False)[source]#
Bases:
BaseSortingExtractorInterface
Primary data interface class for converting Plexon spiking data.
Uses
PlexonSortingExtractor
.Load and prepare data for Plexon.
- Parameters
file_path (FilePath) – Path to the plexon spiking data (.plx file).
verbose (bool, default: True) – Allows verbosity.
- display_name: Union[str, None] = 'Plexon Sorting'#
- associated_suffixes: tuple[str] = ('.plx',)#
- info: Union[str, None] = 'Interface for Plexon sorting data.'#
Spike2#
- class Spike2RecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
Data interface class for converting Spike2 data from CED (Cambridge Electronic Design) using the
CedRecordingExtractor
.Initialize reading of Spike2 file.
- Parameters
file_path (FilePath) – Path to .smr or .smrx file.
verbose (bool, default: False)
es_key (str, default: “ElectricalSeries”)
- display_name: Union[str, None] = 'Spike2 Recording'#
- keywords: tuple[str] = ('extracellular electrophysiology', 'voltage', 'recording', 'CED')#
- associated_suffixes: tuple[str] = ('.smrx',)#
- info: Union[str, None] = 'Interface for Spike2 recording data from CED (Cambridge Electronic Design).'#
- ExtractorName: Optional[str] = 'CedRecordingExtractor'#
Spikegadgets Recording#
- class SpikeGadgetsRecordingInterface(file_path: Annotated[pathlib.Path, PathType(path_type='file')], stream_id: str = 'trodes', gains: Union[list, numpy.ndarray, NoneType] = None, verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
Data interface class for converting data in the SpikeGadgets format. Uses
SpikeGadgetsRecordingExtractor
.Recording Interface for the SpikeGadgets Format.
- Parameters
file_path (FilePath) – Path to the .rec file.
gains (array_like, optional) – The early versions of SpikeGadgets do not automatically record the conversion factor (‘gain’) of the acquisition system. Thus, it must be specified either as a single value (if all channels have the same gain) or an array of values for each channel.
es_key (str, default: “ElectricalSeries”)
- display_name: Union[str, None] = 'SpikeGadgets Recording'#
- associated_suffixes: tuple[str] = ('.rec',)#
- info: Union[str, None] = 'Interface for SpikeGadgets recording data.'#
SpikeGLX Recording#
- class SpikeGLXConverterPipe(folder_path: Annotated[pathlib.Path, PathType(path_type='dir')], streams: Optional[list[str]] = None, verbose: bool = False)[source]#
Bases:
ConverterPipe
The simplest, easiest to use class for converting all SpikeGLX data in a folder.
Primary conversion class for handling multiple SpikeGLX data streams.
Read all data from multiple streams stored in the SpikeGLX format.
- This can include…
single-probe but multi-band such as AP+LF streams
multi-probe with multi-band
with or without the associated NIDQ channels
- Parameters
folder_path (DirectoryPath) – Path to folder containing the NIDQ stream and subfolders containing each IMEC stream.
streams (list of strings, optional) – A specific list of streams you wish to load. To see which streams are available, run SpikeGLXConverter.get_streams(folder_path=”path/to/spikeglx”). By default, all available streams are loaded.
verbose (bool, default: False) – Whether to output verbose text.
- display_name: Union[str, None] = 'SpikeGLX Converter'#
- keywords: tuple[str] = ('extracellular electrophysiology', 'voltage', 'recording', 'Neuropixels', 'Neuropixels', 'nidq', 'NIDQ', 'SpikeGLX')#
- associated_suffixes: tuple[str] = ('.imec{probe_index}', '.ap', '.lf', '.meta', '.bin', '.nidq', '.meta', '.bin')#
- info: Union[str, None] = 'Converter for multi-stream SpikeGLX recording data.'#
- classmethod get_source_schema() dict [source]#
Get the schema for the source arguments.
- Returns
The schema dictionary containing input parameters and descriptions for initializing the SpikeGLX converter.
- Return type
dict
- classmethod get_streams(folder_path: Path) list[str] [source]#
Get the stream IDs available in the folder.
- Parameters
folder_path (DirectoryPath) – Path to the folder containing SpikeGLX streams.
- Returns
The IDs of all available streams in the folder.
- Return type
list of str
- get_conversion_options_schema() dict [source]#
Compile conversion option schemas from each of the data interface classes.
- Returns
The compiled conversion options schema containing: - root: True - id: “conversion_options.schema.json” - title: “Conversion options schema” - description: “Schema for the conversion options” - version: “0.1.0” - properties: Dictionary mapping interface names to their unrooted schemas
- Return type
dict
DataInterfaces for SpikeGLX.
- class SpikeGLXRecordingInterface(file_path: Optional[Annotated[pathlib.Path, PathType(path_type='file')]] = None, verbose: bool = False, es_key: Optional[str] = None, folder_path: Optional[Annotated[pathlib.Path, PathType(path_type='dir')]] = None, stream_id: Optional[str] = None)[source]#
Bases:
BaseRecordingExtractorInterface
Primary SpikeGLX interface for converting raw SpikeGLX data using a
SpikeGLXRecordingExtractor
.- Parameters
folder_path (DirectoryPath) – Folder path containing the binary files of the SpikeGLX recording.
stream_id (str, optional) – Stream ID of the SpikeGLX recording. Examples are ‘imec0.ap’, ‘imec0.lf’, ‘imec1.ap’, ‘imec1.lf’, etc.
file_path (FilePath) – Path to .bin file. Point to .ap.bin for SpikeGLXRecordingInterface and .lf.bin for SpikeGLXLFPInterface.
verbose (bool, default: False) – Whether to output verbose text.
es_key (str, the key to access the metadata of the ElectricalSeries.)
- display_name: Union[str, None] = 'SpikeGLX Recording'#
- keywords: tuple[str] = ('extracellular electrophysiology', 'voltage', 'recording', 'Neuropixels')#
- associated_suffixes: tuple[str] = ('.imec{probe_index}', '.ap', '.lf', '.meta', '.bin')#
- info: Union[str, None] = 'Interface for SpikeGLX recording data.'#
- ExtractorName: Optional[str] = 'SpikeGLXRecordingExtractor'#
- classmethod get_source_schema() dict [source]#
Infer the JSON schema for the source_data from the method signature (annotation typing).
- Returns
The JSON schema for the source_data.
- Return type
dict
- get_metadata() dict [source]#
Child DataInterface classes should override this to match their metadata.
- Returns
The metadata dictionary containing basic NWBFile metadata.
- Return type
- get_original_timestamps() ndarray [source]#
Retrieve the original unaltered timestamps for the data in this interface.
This function should retrieve the data on-demand by re-initializing the IO.
- Returns
timestamps – The timestamps for the data stream; if the recording has multiple segments, then a list of timestamps is returned.
- Return type
numpy.ndarray or list of numpy.ndarray
- class SpikeGLXNIDQInterface(file_path: Optional[Annotated[pathlib.Path, PathType(path_type='file')]] = None, verbose: bool = False, load_sync_channel: Optional[bool] = None, es_key: str = 'ElectricalSeriesNIDQ', folder_path: Optional[Annotated[pathlib.Path, PathType(path_type='dir')]] = None)[source]#
Bases:
BaseDataInterface
Primary data interface class for converting the high-pass (ap) SpikeGLX format.
Read channel data from the NIDQ board for the SpikeGLX recording.
Useful for synchronizing multiple data streams into the common time basis of the SpikeGLX system.
- Parameters
folder_path (DirectoryPath) – Path to the folder containing the .nidq.bin file.
file_path (FilePath) – Path to .nidq.bin file.
verbose (bool, default: False) – Whether to output verbose text.
es_key (str, default: “ElectricalSeriesNIDQ”)
- display_name: Union[str, None] = 'NIDQ Recording'#
- keywords: tuple[str] = ('Neuropixels', 'nidq', 'NIDQ', 'SpikeGLX')#
- associated_suffixes: tuple[str] = ('.nidq', '.meta', '.bin')#
- info: Union[str, None] = 'Interface for NIDQ board recording data.'#
- classmethod get_source_schema() dict [source]#
Infer the JSON schema for the source_data from the method signature (annotation typing).
- Returns
The JSON schema for the source_data.
- Return type
dict
- get_metadata() dict [source]#
Child DataInterface classes should override this to match their metadata.
- Returns
The metadata dictionary containing basic NWBFile metadata.
- Return type
- get_channel_names() list[str] [source]#
Get a list of channel names from the recording extractor.
- Returns
The names of all channels in the NIDQ recording.
- Return type
list of str
- add_to_nwbfile(nwbfile: NWBFile, metadata: Optional[dict] = None, stub_test: bool = False, starting_time: Optional[float] = None, write_as: Literal['raw', 'lfp', 'processed'] = 'raw', write_electrical_series: bool = True, iterator_type: Optional[str] = 'v2', iterator_opts: Optional[dict] = None, always_write_timestamps: bool = False)[source]#
Add NIDQ board data to an NWB file, including both analog and digital channels if present.
- Parameters
nwbfile (NWBFile) – The NWB file to which the NIDQ data will be added
metadata (Optional[dict], default: None) – Metadata dictionary with device information. If None, uses default metadata
stub_test (bool, default: False) – If True, only writes a small amount of data for testing
starting_time (Optional[float], default: None) – DEPRECATED: Will be removed in June 2025. Starting time offset for the TimeSeries
write_as (Literal[“raw”, “lfp”, “processed”], default: “raw”) – DEPRECATED: Will be removed in June 2025. Specifies how to write the data
write_electrical_series (bool, default: True) – DEPRECATED: Will be removed in June 2025. Whether to write electrical series data
iterator_type (Optional[str], default: “v2”) – Type of iterator to use for data streaming
iterator_opts (Optional[dict], default: None) – Additional options for the iterator
always_write_timestamps (bool, default: False) – If True, always writes timestamps instead of using sampling rate
- get_event_times_from_ttl(channel_name: str) ndarray [source]#
Return the start of event times from the rising part of TTL pulses on one of the NIDQ channels.
- Parameters
channel_name (str) – Name of the channel in the .nidq.bin file.
- Returns
rising_times – The times of the rising TTL pulses.
- Return type
numpy.ndarray
Tucker-Davis Technologies (TDT) Recording#
- class TdtRecordingInterface(folder_path: Annotated[pathlib.Path, PathType(path_type='dir')], gain: float, stream_id: str = '0', verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
Primary data interface class for converting Tucker-Davis Technologies (TDT) data.
Initialize reading of a TDT recording.
- Parameters
folder_path (str or Path) – Path to the directory with the corresponding files (TSQ, TBK, TEV, SEV)
stream_id (str, “0” by default) – Select from multiple streams.
gain (float) – The conversion factor from int16 to microvolts.
verbose (bool, default: Falsee) – Allows verbose.
es_key (str, optional)
Notes
Stream “0” corresponds to LFP for gin data. Other streams seem non-electrical.
- display_name: Union[str, None] = 'TDT Recording'#
- associated_suffixes: tuple[str] = ('.tbk', '.tbx', '.tev', '.tsq')#
- info: Union[str, None] = 'Interface for TDT recording data.'#