Extracellular Electrophysiology#
Base Recording#
- class BaseRecordingExtractorInterface(verbose: bool = False, es_key: str = 'ElectricalSeries', **source_data)[source]#
Bases:
BaseExtractorInterfaceParent class for all RecordingExtractorInterfaces.
General interface for OpenEphys data. It works for both the legacy and the binary format.
For “legacy” format (.continuous files) the interface redirects to OpenEphysLegacyRecordingInterface. For “binary” format (.dat files) the interface redirects to OpenEphysBinaryRecordingInterface.
- Parameters:
folder_path (DirectoryPath) – 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”)
- keywords: tuple[str] = ('extracellular electrophysiology', 'voltage', 'recording')#
- 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() ndarray | list[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() ndarray | list[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[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: Probe | ProbeGroup, group_mode: Literal['by_shank', 'by_probe'])[source]#
Set the probe information via a ProbeInterface object.
- Parameters:
probe (probeinterface.Probe or probeinterface.ProbeGroup) – The probe object(s). Can be a single Probe or a ProbeGroup containing multiple probes.
group_mode ({‘by_shank’, ‘by_probe’}) – How to group the channels for electrode group assignment in the NWB file:
‘by_probe’: Each probe becomes a separate electrode group. For a ProbeGroup with
multiple probes, each probe gets its own group (group 0, 1, 2, etc.). For a single probe, all channels are assigned to group 0.
‘by_shank’: Each unique combination of probe and shank becomes a separate electrode
group. Requires that shank_ids are defined for all probes. Groups are assigned sequentially for each unique (probe_index, shank_id) pair.
The resulting groups determine how electrode groups and electrodes are organized in the NWB file, with each group corresponding to one ElectrodeGroup.
- 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.
- add_to_nwbfile(nwbfile: NWBFile, metadata: dict | None = None, *, stub_test: bool = False, write_as: Literal['raw', 'lfp', 'processed'] = 'raw', write_electrical_series: bool = True, iterator_type: str | None = 'v2', iterator_options: dict | None = None, iterator_opts: dict | None = 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)
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’, None}, default: ‘v2’) – The type of iterator for chunked data writing. ‘v2’: Uses iterative write with control over chunking and progress bars. None: Loads all data into memory before writing (not recommended for large datasets).
iterator_options (dict, optional) – Options for controlling iterative write when iterator_type=’v2’. See the pynwb tutorial on iterative write for more information on chunked data writing.
Available options:
- buffer_gbfloat, default: 1.0
RAM to use for buffering data chunks in GB. Recommended to be as much free RAM as available.
- buffer_shapetuple, optional
Manual specification of buffer shape. Must be a multiple of chunk_shape along each axis. Cannot be set if buffer_gb is specified.
- display_progressbool, default: False
Enable tqdm progress bar during data write.
- progress_bar_optionsdict, optional
Additional options passed to tqdm progress bar. See tqdm/tqdm for all tqdm options.
Note: To configure chunk size and compression, use the backend configuration system via
get_default_backend_configuration()andconfigure_backend()after calling this method. See the backend configuration documentation for details.iterator_opts (dict, optional) – Deprecated. Use ‘iterator_options’ instead.
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:
BaseExtractorInterfacePrimary class for all SortingExtractor interfaces.
- keywords: tuple[str] = ('extracellular electrophysiology', 'spike sorting')#
- 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() ndarray | list[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[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: DeepDict | None = 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 (DeepDict | None) – 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: DeepDict | None = 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: list[list[int]] | None = 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.
- rename_unit_ids(unit_ids_map: dict)[source]#
Rename unit IDs using a mapping dictionary.
- Parameters:
unit_ids_map (dict) – A dictionary mapping current unit IDs to new unit IDs. Format: {old_unit_id: new_unit_id, …}
- Raises:
ValueError – If any of the old unit IDs in the mapping do not exist in the sorting extractor.
TypeError – If unit_ids_map is not a dictionary.
Examples
>>> sorting_interface = MockSortingInterface() >>> print(sorting_interface.units_ids) # ['0', '1', '2', '3'] >>> sorting_interface.rename_unit_ids({'0': 'unit_a', '1': 'unit_b'}) >>> print(sorting_interface.units_ids) # ['unit_a', 'unit_b', '2', '3']
AlphaOmega#
- class AlphaOmegaRecordingInterface(folder_path: Annotated[pathlib._local.Path, PathType(path_type='dir')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfacePrimary data interface class for converting AlphaOmega recording data.
Uses the
read_alphaomega()reader from SpikeInterface.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: str | None = 'AlphaOmega Recording'#
- associated_suffixes: tuple[str] = ('.mpx',)#
- info: str | None = 'Interface class for converting AlphaOmega recording data.'#
- stream_id = 'RAW'#
- 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
Axon Recording#
- class AxonRecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfaceData interface class for converting extracellular data recorded in Axon Binary Format (ABF) data.
Uses the
read_axon()reader from SpikeInterface.Load and prepare raw data and corresponding metadata from the Axon Binary Format (.abf files).
- Parameters:
file_path (FilePath) – Path to an Axon Binary Format (.abf) file
verbose (bool, default: False) – Verbose
es_key (str, default: “ElectricalSeries”) – The key for the ElectricalSeries in the metadata
- display_name: str | None = 'Axon Recording'#
- keywords: tuple[str] = ('extracellular electrophysiology', 'voltage', 'recording', 'axon', 'abf')#
- associated_suffixes: tuple[str] = ('.abf',)#
- info: str | None = 'Interface for extracellular data recorded in Axon Binary Format (ABF) recordings.'#
- 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_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
Axona Recording#
Collection of Axona interfaces.
- class AxonaRecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfaceDataInterface for converting raw Axona data.
Uses the
read_axona()reader from SpikeInterface.- Parameters:
file_path (FilePath) – Path to .bin file.
verbose (bool, optional, default: True)
es_key (str, default: “ElectricalSeries”)
- display_name: str | None = 'Axona Recording'#
- associated_suffixes: tuple[str] = ('.bin', '.set')#
- info: str | None = 'Interface for Axona 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
- class AxonaUnitRecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], noise_std: float = 3.5)[source]#
Bases:
AxonaRecordingInterfacePrimary 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: str | None = 'Axona Units'#
- associated_suffixes: tuple[str] = ('.bin', '.set')#
- info: str | None = 'Interface for Axona recording data.'#
- class AxonaLFPDataInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')])[source]#
Bases:
BaseLFPExtractorInterfacePrimary data interface class for converting Axona LFP data. Note that this interface is not lazy and will load all data into memory.
General interface for OpenEphys data. It works for both the legacy and the binary format.
For “legacy” format (.continuous files) the interface redirects to OpenEphysLegacyRecordingInterface. For “binary” format (.dat files) the interface redirects to OpenEphysBinaryRecordingInterface.
- Parameters:
folder_path (DirectoryPath) – 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”)
- display_name: str | None = 'Axona LFP'#
- associated_suffixes: tuple[str] = ('.bin', '.set')#
- info: str | None = 'Interface for Axona LFP data.'#
- class AxonaPositionDataInterface(file_path: str)[source]#
Bases:
BaseDataInterfacePrimary data interface class for converting Axona position data.
- Parameters:
file_path (str) – Path to .bin or .set file.
- display_name: str | None = 'Axona Position'#
- keywords: tuple[str] = ('position tracking',)#
- associated_suffixes: tuple[str] = ('.bin', '.set')#
- info: str | None = 'Interface for Axona position data.'#
Biocam Recording#
- class BiocamRecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfacePrimary data interface class for converting Biocam data.
Uses the
read_biocam()reader from SpikeInterface.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: str | None = 'Biocam Recording'#
- associated_suffixes: tuple[str] = ('.bwr',)#
- info: str | None = 'Interface for Biocam recording data.'#
Blackrock Recording#
- class BlackrockRecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], nsx_override: Annotated[pathlib._local.Path, PathType(path_type='file')] | None = None, verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfacePrimary data interface class for converting Blackrock data.
Uses the
read_blackrock()reader from SpikeInterface.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: str | None = 'Blackrock Recording'#
- associated_suffixes: tuple[str] = ('.ns0', '.ns1', '.ns2', '.ns3', '.ns4', '.ns5')#
- info: str | None = 'Interface for Blackrock recording data.'#
- classmethod get_source_schema()[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
- class BlackrockSortingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], sampling_frequency: float | None = None, nsx_to_load: int | list | str | NoneType = None, verbose: bool = False)[source]#
Bases:
BaseSortingExtractorInterfacePrimary data interface class for converting Blackrock spiking data.
- Parameters:
file_path (str, Path) – The file path to the
.nevdatasampling_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.
nsx_to_load (int | list | str, optional) – IDs of nsX file from which to load data, e.g., if set to 5 only data from the ns5 file are loaded. If ‘all’, then all nsX will be loaded. If None, all nsX files will be loaded. If empty list, no nsX files will be loaded.
verbose (bool, default: False) – Enables verbosity
- display_name: str | None = 'Blackrock Sorting'#
- associated_suffixes: tuple[str] = ('.nev',)#
- info: str | None = 'Interface for Blackrock 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
CellExplorer Sorting#
- add_channel_metadata_to_recoder(recording_extractor, folder_path: Annotated[Path, PathType(path_type=dir)])[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: Annotated[Path, PathType(path_type=dir)])[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: Annotated[Path, PathType(path_type=dir)])[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._local.Path, PathType(path_type='dir')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfaceAdds 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: False) – 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: str | None = 'CellExplorer Recording'#
- associated_suffixes: tuple[str] = ('.dat', '.session', '.sessionInfo', '.mat')#
- info: str | None = 'Interface for CellExplorer recording data.'#
- sampling_frequency_key = 'sr'#
- binary_file_extension = 'dat'#
- classmethod get_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
- 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._local.Path, PathType(path_type='dir')], verbose: bool = False, es_key: str = 'ElectricalSeriesLFP')[source]#
Bases:
CellExplorerRecordingInterfaceAdds 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: 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: str | None = 'Interface for CellExplorer LFP recording data.'#
- sampling_frequency_key = 'srLfp'#
- binary_file_extension = 'lfp'#
- add_to_nwbfile(nwbfile: NWBFile, metadata: dict | None = None, stub_test: bool = False, starting_time: float | None = None, write_as: Literal['raw', 'lfp', 'processed'] = 'lfp', write_electrical_series: bool = True, compression: str | None = 'gzip', compression_opts: int | None = None, iterator_type: str = 'v2', iterator_opts: dict | None = 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)
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’, None}, default: ‘v2’) – The type of iterator for chunked data writing. ‘v2’: Uses iterative write with control over chunking and progress bars. None: Loads all data into memory before writing (not recommended for large datasets).
iterator_options (dict, optional) – Options for controlling iterative write when iterator_type=’v2’. See the pynwb tutorial on iterative write for more information on chunked data writing.
Available options:
- buffer_gbfloat, default: 1.0
RAM to use for buffering data chunks in GB. Recommended to be as much free RAM as available.
- buffer_shapetuple, optional
Manual specification of buffer shape. Must be a multiple of chunk_shape along each axis. Cannot be set if buffer_gb is specified.
- display_progressbool, default: False
Enable tqdm progress bar during data write.
- progress_bar_optionsdict, optional
Additional options passed to tqdm progress bar. See tqdm/tqdm for all tqdm options.
Note: To configure chunk size and compression, use the backend configuration system via
get_default_backend_configuration()andconfigure_backend()after calling this method. See the backend configuration documentation for details.iterator_opts (dict, optional) – Deprecated. Use ‘iterator_options’ instead.
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._local.Path, PathType(path_type='file')], verbose: bool = False)[source]#
Bases:
BaseSortingExtractorInterfacePrimary 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: str | None = 'CellExplorer Sorting'#
- associated_suffixes: tuple[str] = ('.mat', '.sessionInfo', '.spikes', '.cellinfo')#
- info: str | None = 'Interface for CellExplorer sorting data.'#
- classmethod get_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
- 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._local.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries', channels_to_skip: list | None = None)[source]#
Bases:
BaseRecordingExtractorInterfaceData interface class for converting European Data Format (EDF) data.
Uses the
read_edf()reader from SpikeInterface.Not supported 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: False) – 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: str | None = 'EDF Recording'#
- keywords: tuple[str] = ('extracellular electrophysiology', 'voltage', 'recording', 'European Data Format')#
- associated_suffixes: tuple[str] = ('.edf',)#
- info: str | None = 'Interface for European Data Format (EDF) 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_available_channel_ids(file_path: Annotated[Path, PathType(path_type=file)]) list[source]#
Get all available channel names from an EDF file.
- Parameters:
file_path (FilePath) – Path to the EDF file
- Returns:
List of all channel names in the EDF file
- Return type:
list
Intan Amplifier#
- class IntanRecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries', ignore_integrity_checks: bool = False)[source]#
Bases:
BaseRecordingExtractorInterfacePrimary data interface for converting Intan amplifier data from .rhd or .rhs files.
This interface is used for data that comes from the RHD2000/RHS2000 amplifier channels, which are the primary neural recording channels.
If you have other data streams from your Intan system (e.g., analog inputs, auxiliary inputs, DC amplifiers), you should use the
IntanAnalogInterface.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: str | None = 'Intan Amplifier'#
- keywords: tuple[str] = ('intan', 'amplifier', 'rhd', 'rhs', 'extracellular electrophysiology', 'recording')#
- associated_suffixes: tuple[str] = ('.rhd', '.rhs')#
- info: str | None = 'Interface for converting Intan amplifier 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
- classmethod get_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
Intan Analog#
- class IntanAnalogInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], stream_name: str, verbose: bool = False, metadata_key: str = 'TimeSeriesAnalogIntan')[source]#
Bases:
BaseDataInterfacePrimary data interface for converting non-amplifier analog data streams from Intan .rhd or .rhs files.
This interface handles several types of analog signals that are not the primary neural recording channels, including auxiliary inputs, ADC inputs, and DC amplifier signals.
If your data consists of the main amplifier channels (neural data), you should use the
IntanRecordingInterface.Load and prepare analog data from Intan format (.rhd or .rhs files).
- Parameters:
file_path (FilePath) – Path to either a rhd or a rhs file
stream_name (str) – The stream name to load. Valid options include: - “RHD2000 auxiliary input channel”: Auxiliary input channels (e.g., accelerometer data) - “RHD2000 supply voltage channel”: Supply voltage channels - “USB board ADC input channel”: ADC input channels (analog signals -10V to +10V) - “USB board ADC output channel”: ADC output channels (analog signals -10V to +10V) - “DC Amplifier channel”: DC amplifier channels (RHS system only)
verbose (bool, default: False) – Verbose output
metadata_key (str, default: “TimeSeriesAnalogIntan”) – Key for the TimeSeries metadata in the metadata dictionary.
- display_name: str | None = 'Intan Analog'#
- keywords: tuple[str] = ('intan', 'analog', 'auxiliary', 'ADC', 'DC amplifier', 'rhd', 'rhs')#
- associated_suffixes: tuple[str] = ('.rhd', '.rhs')#
- info: str | None = 'Interface for converting Intan non-amplifier analog 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() DeepDict[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 analog recording.
- Return type:
list of str
- add_to_nwbfile(nwbfile: NWBFile, metadata: dict | None = None, stub_test: bool = False, iterator_type: str | None = 'v2', iterator_opts: dict | None = None, always_write_timestamps: bool = False)[source]#
Add analog channel data to an NWB file.
- Parameters:
nwbfile (NWBFile) – The NWB file to which the analog data will be added
metadata (dict, optional) – 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
iterator_type (str, optional, default: “v2”) – Type of iterator to use for data streaming
iterator_opts (dict, optional) – Additional options for the iterator
always_write_timestamps (bool, default: False) – If True, always writes timestamps instead of using sampling rate
KiloSort Sorting#
- class KiloSortSortingInterface(folder_path: Annotated[pathlib._local.Path, PathType(path_type='dir')], keep_good_only: bool = False, verbose: bool = False)[source]#
Bases:
BaseSortingExtractorInterfacePrimary 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: str | None = 'KiloSort Sorting'#
- associated_suffixes: tuple[str] = ('.npy',)#
- info: str | None = 'Interface for KiloSort 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
MaxOne Recording#
- class MaxOneRecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], hdf5_plugin_path: Annotated[pathlib._local.Path, PathType(path_type='dir')] | None = None, download_plugin: bool = True, verbose: bool = False, es_key: str = 'ElectricalSeries') None[source]#
Bases:
BaseRecordingExtractorInterfacePrimary data interface class for converting MaxOne data.
Uses the
read_maxwell()reader from SpikeInterface.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: str | None = 'MaxOne Recording'#
- associated_suffixes: tuple[str] = ('.raw', '.h5')#
- info: str | None = 'Interface for MaxOne recording data.'#
- classmethod get_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
- static auto_install_maxwell_hdf5_compression_plugin(hdf5_plugin_path: Annotated[Path, PathType(path_type=dir)] | None = 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._local.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfacePrimary data interface class for converting MEArec recording data.
Uses the
read_mearec()from SpikeInterface.Load and prepare data for MEArec.
- Parameters:
folder_path (str or Path) – Path to the MEArec .h5 file.
verbose (bool, default: False) – Allows verbose.
es_key (str, default: “ElectricalSeries”)
- display_name: str | None = 'MEArec Recording'#
- associated_suffixes: tuple[str] = ('.h5',)#
- info: str | None = 'Interface for MEArec recording data.'#
- classmethod get_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
Neuralynx Recording & Sorting#
- class NeuralynxRecordingInterface(folder_path: Annotated[pathlib._local.Path, PathType(path_type='dir')], stream_name: str | None = None, verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfacePrimary data interface for converting Neuralynx data.
Uses
read_neuralynx()from SpikeInterface.Initialize reading of OpenEphys binary recording.
- Parameters:
folder_path (DirectoryPath) – 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: str | None = 'Neuralynx Recording'#
- associated_suffixes: tuple[str] = ('.ncs', '.nse', '.ntt', '.nse', '.nev')#
- info: str | None = 'Interface for Neuralynx recording data.'#
- classmethod get_stream_names(folder_path: Annotated[Path, PathType(path_type=dir)]) list[str][source]#
- 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
- class NeuralynxSortingInterface(folder_path: Annotated[pathlib._local.Path, PathType(path_type='dir')], sampling_frequency: float | None = None, verbose: bool = False, stream_id: str | None = None)[source]#
Bases:
BaseSortingExtractorInterfacePrimary data interface for converting Neuralynx sorting data. Uses
read_neuralynx_sorting()._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: str | None = 'Neuralynx Sorting'#
- associated_suffixes: tuple[str] = ('.nse', '.ntt', '.nse', '.nev')#
- info: 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: float | None = None)[source]#
Automatically add properties to RecordingExtractor object.
- class NeuroScopeRecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], gain: float | None = None, xml_file_path: Annotated[pathlib._local.Path, PathType(path_type='file')] | None = None, verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfacePrimary data interface for converting a NeuroScope data. Uses
read_neuroscope_recording().Load and prepare raw acquisition data and corresponding metadata from the Neuroscope format (.dat files).
- Parameters:
file_path (FilePath) – Path to .dat file.
gain (float | None, 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: str | None = 'NeuroScope Recording'#
- associated_suffixes: tuple[str] = ('.dat', '.xml')#
- info: str | None = 'Interface for converting NeuroScope recording data.'#
- classmethod get_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
- 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() DeepDict[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._local.Path, PathType(path_type='file')], gain: float | None = None, xml_file_path: Annotated[pathlib._local.Path, PathType(path_type='file')] | None = None, verbose: bool = False)[source]#
Bases:
BaseLFPExtractorInterfacePrimary 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 (FilePath | None, 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.
verbose (bool, default: False) – If True, enables verbose mode for detailed logging.
- display_name: str | None = 'NeuroScope LFP'#
- associated_suffixes: tuple[str] = ('.lfp', '.eeg', '.xml')#
- info: str | None = 'Interface for converting NeuroScope LFP data.'#
- classmethod get_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
- class NeuroScopeSortingInterface(folder_path: Annotated[pathlib._local.Path, PathType(path_type='dir')], keep_mua_units: bool = True, exclude_shanks: list[int] | None = None, xml_file_path: Annotated[pathlib._local.Path, PathType(path_type='file')] | None = None, verbose: bool = False)[source]#
Bases:
BaseSortingExtractorInterfacePrimary 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 (DirectoryPath) – 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: str | None = 'NeuroScope Sorting'#
- associated_suffixes: tuple[str] = ('.res', '.clu', '.res.*', '.clu.*', '.xml')#
- info: 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
OpenEphys Recording#
- class OpenEphysRecordingInterface(verbose: bool = False, es_key: str = 'ElectricalSeries', **source_data)[source]#
Bases:
BaseRecordingExtractorInterfaceAbstract class that defines which interface class to use for a given Open Ephys recording.
General interface for OpenEphys data. It works for both the legacy and the binary format.
For “legacy” format (.continuous files) the interface redirects to OpenEphysLegacyRecordingInterface. For “binary” format (.dat files) the interface redirects to OpenEphysBinaryRecordingInterface.
- Parameters:
folder_path (DirectoryPath) – 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”)
- display_name: str | None = 'OpenEphys Recording'#
- associated_suffixes: tuple[str] = ('.dat', '.oebin', '.npy')#
- info: str | None = 'Interface for converting any OpenEphys recording data.'#
- classmethod get_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
- 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: Annotated[Path, PathType(path_type=dir)]) 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.
Phy Sorting#
- class PhySortingInterface(folder_path: Annotated[pathlib._local.Path, PathType(path_type='dir')], exclude_cluster_groups: list[str] | None = None, verbose: bool = False)[source]#
Bases:
BaseSortingExtractorInterfacePrimary data interface class for converting Phy data.
Uses
read_phy()from SpikeInterface.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: False)
- display_name: str | None = 'Phy Sorting'#
- associated_suffixes: tuple[str] = ('.npy',)#
- info: 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
Plexon Recording & Sorting#
- class PlexonRecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries', stream_name: str = 'WB-Wideband')[source]#
Bases:
BaseRecordingExtractorInterfacePrimary data interface class for converting Plexon data.
Uses
read_plexon()from SpikeInterface.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, 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: str | None = 'Plexon Recording'#
- associated_suffixes: tuple[str] = ('.plx',)#
- info: str | None = 'Interface for Plexon recording data.'#
- classmethod get_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
- class PlexonLFPInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeriesLF', stream_name: str = 'FPl-Low Pass Filtered')[source]#
Bases:
BaseLFPExtractorInterfacePrimary data interface class for converting Plexon LFP data.
Uses
read_plexon().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: str | None = 'Plexon LFP Recording'#
- associated_suffixes: tuple[str] = ('.plx',)#
- info: str | None = 'Interface for Plexon low pass filtered data.'#
- classmethod get_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
- class Plexon2RecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfacePrimary data interface class for converting Plexon2 data.
Uses
read_plexon2()from SpikeInterface.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: str | None = 'Plexon2 Recording'#
- associated_suffixes: tuple[str] = ('.pl2',)#
- info: str | None = 'Interface for Plexon2 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
- class PlexonSortingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], verbose: bool = False)[source]#
Bases:
BaseSortingExtractorInterfacePrimary data interface class for converting Plexon spiking data.
Uses
read_plexon_sorting()from SpikeInterface.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: str | None = 'Plexon Sorting'#
- associated_suffixes: tuple[str] = ('.plx',)#
- info: str | None = 'Interface for Plexon 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
Spike2#
- class Spike2RecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfaceData interface class for converting Spike2 data from CED (Cambridge Electronic Design)
Uses
read_ced()from SpikeInterface.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: str | None = 'Spike2 Recording'#
- keywords: tuple[str] = ('extracellular electrophysiology', 'voltage', 'recording', 'CED')#
- associated_suffixes: tuple[str] = ('.smrx',)#
- info: str | None = 'Interface for Spike2 recording data from CED (Cambridge Electronic Design).'#
- classmethod get_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
- 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_all_channels_info(file_path: Annotated[Path, PathType(path_type=file)])[source]#
Retrieve and inspect necessary channel information prior to initialization.
- Parameters:
file_path (FilePath) – Path to .smr or .smrx file.
- Returns:
Dictionary containing information about all channels in the Spike2 file.
- Return type:
dict
Spikegadgets Recording#
- class SpikeGadgetsRecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], stream_id: str = 'trodes', gains: list | numpy.ndarray | None = None, verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfaceData interface class for converting data in the SpikeGadgets format.
Uses the
read_spikegadgets()reader from SpikeInterface.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: str | None = 'SpikeGadgets Recording'#
- associated_suffixes: tuple[str] = ('.rec',)#
- info: str | None = 'Interface for SpikeGadgets recording data.'#
SpikeGLX Recording#
- class SpikeGLXConverterPipe(folder_path: Annotated[pathlib._local.Path, PathType(path_type='dir')], streams: list[str] | None = None, verbose: bool = False)[source]#
Bases:
ConverterPipeThe 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: 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: 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: Annotated[Path, PathType(path_type=dir)]) 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: Annotated[pathlib._local.Path, PathType(path_type='file')] | None = None, verbose: bool = False, es_key: str | None = None, folder_path: Annotated[pathlib._local.Path, PathType(path_type='dir')] | None = None, stream_id: str | None = None)[source]#
Bases:
BaseRecordingExtractorInterfacePrimary SpikeGLX interface for converting raw SpikeGLX data.
Uses the
read_spikeglx()reader from SpikeInterface.- 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: str | None = 'SpikeGLX Recording'#
- keywords: tuple[str] = ('extracellular electrophysiology', 'voltage', 'recording', 'Neuropixels')#
- associated_suffixes: tuple[str] = ('.imec{probe_index}', '.ap', '.lf', '.meta', '.bin')#
- info: str | None = 'Interface for SpikeGLX 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
- classmethod get_extractor_class()[source]#
Get the extractor class for this interface.
This classmethod must be implemented by each concrete interface to specify which extractor class to use.
- Returns:
The extractor class or function to use for initialization.
- Return type:
type or callable
- get_metadata() DeepDict[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: Annotated[pathlib._local.Path, PathType(path_type='file')] | None = None, verbose: bool = False, es_key: str = 'ElectricalSeriesNIDQ', folder_path: Annotated[pathlib._local.Path, PathType(path_type='dir')] | None = None, metadata_key: str = 'SpikeGLXNIDQ')[source]#
Bases:
BaseDataInterfacePrimary data interface class for converting the high-pass (ap) SpikeGLX format.
Read analog and digital channel data from the NIDQ board for the SpikeGLX recording.
The NIDQ stream records both analog and digital (usually non-neural) signals. XD channels are converted to events directly. XA, MA and MD channels are all written together to a single TimeSeries at the moment. Note that the multiplexed channels MA and MD are written multiplexed at the moment.
- 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”)
metadata_key (str, default: “SpikeGLXNIDQ”) – Key used to organize metadata in the metadata dictionary. This is especially useful when multiple NIDQ interfaces are used in the same conversion. The metadata_key is used to organize TimeSeries and Events metadata.
- display_name: str | None = 'NIDQ Recording'#
- keywords: tuple[str] = ('Neuropixels', 'nidq', 'NIDQ', 'SpikeGLX')#
- associated_suffixes: tuple[str] = ('.nidq', '.meta', '.bin')#
- info: 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() DeepDict[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: dict | None = None, stub_test: bool = False, iterator_type: str | None = 'v2', iterator_opts: dict | None = 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 (dict | None, 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
iterator_type (str | None, default: “v2”) – Type of iterator to use for data streaming
iterator_opts (dict | None, 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._local.Path, PathType(path_type='dir')], gain: float, stream_id: str = '0', verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfacePrimary 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: False) – Allows verbose.
es_key (str, optional)
Notes
Stream “0” corresponds to LFP for gin data. Other streams seem non-electrical.
- display_name: str | None = 'TDT Recording'#
- associated_suffixes: tuple[str] = ('.tbk', '.tbx', '.tev', '.tsq')#
- info: str | None = 'Interface for TDT recording data.'#
White Matter Recording#
- class WhiteMatterRecordingInterface(file_path: Annotated[pathlib._local.Path, PathType(path_type='file')], sampling_frequency: float, num_channels: int, channel_ids: list | None = None, is_filtered: bool | None = None, verbose: bool = False, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterfacePrimary data interface for converting binary WhiteMatter data (.bin files).
Uses the
read_whitematter()reader from SpikeInterface.Initialize reading of OpenEphys binary recording.
- Parameters:
file_path (Path) – Path to the binary file.
sampling_frequency (float) – The sampling frequency.
num_channels (int) – Number of channels in the recording.
channel_ids (list or None, default: None) – A list of channel ids. If None, channel_ids = list(range(num_channels)).
is_filtered (bool or None, default: None) – If True, the recording is assumed to be filtered. If None, is_filtered is not set.
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.
- display_name: str | None = 'WhiteMatter Recording'#
- associated_suffixes: tuple[str] = ('.bin',)#
- info: str | None = 'Interface for converting binary WhiteMatter recording data.'#