Recording & Sorting#
Base Recording#
- class BaseRecordingExtractorInterface(verbose: bool = True, es_key: str = 'ElectricalSeries', **source_data)[source]#
Bases:
BaseExtractorInterface
Parent class for all RecordingExtractorInterfaces.
- Parameters
verbose (bool, default: True) – 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.
- get_metadata() DeepDict [source]#
Child DataInterface classes should override this to match their metadata.
- get_electrode_table_json() List[Dict[str, Any]] [source]#
A convenience function for collecting and organizing the property values of the underlying recording extractor.
Uses the structure of the Handsontable (list of dict entries) component of the NWB GUIDE.
- get_original_timestamps() Union[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() Union[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, 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
has_probe – True if the recording extractor has probe information.
- 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)
- 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, 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)
The default is False (append mode).
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’, ‘lfp’, ‘processed’})
write_electrical_series (bool, default: True) – Electrical series are written in acquisition. If False, only device, electrode_groups, and electrodes are written to NWB.
compression ({‘gzip’, ‘lzf’, None}) – Type of compression to use. Set to None to disable all compression.
compression_opts (int, default: 4) – Only applies to compression=”gzip”. Controls the level of the GZIP.
iterator_type ({‘v2’, ‘v1’}) – The type of DataChunkIterator to use. ‘v1’ is the original DataChunkIterator of the hdmf data_utils. ‘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.
Base Sorting#
- class BaseSortingExtractorInterface(verbose=True, **source_data)[source]#
Bases:
BaseExtractorInterface
Primary class for all SortingExtractor interfaces.
- 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[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.
- 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.')[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.’)
Axona Recording#
- class AxonaRecordingInterface(file_path: FilePathType, verbose: bool = True, es_key: str = 'ElectricalSeries')[source]#
Bases:
BaseRecordingExtractorInterface
DataInterface for converting raw Axona data using a
AxonaRecordingExtractor
.- Parameters
file_path (FilePathType) – Path to .bin file.
verbose (bool, optional, default: True)
es_key (str, default: “ElectricalSeries”)
- class AxonaUnitRecordingInterface(file_path: FilePathType, noise_std: float = 3.5)[source]#
Bases:
AxonaRecordingInterface
Primary data interface class for converting a AxonaRecordingExtractor
- Parameters
file_path (FilePathType) – Path to .bin file.
verbose (bool, optional, default: True)
es_key (str, default: “ElectricalSeries”)
- class AxonaLFPDataInterface(file_path: FilePathType)[source]#
Bases:
BaseLFPExtractorInterface
- Parameters
verbose (bool, default: True) – 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.
- class AxonaPositionDataInterface(file_path: str)[source]#
Bases:
BaseDataInterface
Primary data interface class for converting Axona position data
Biocam Recording#
- class BiocamRecordingInterface(file_path: FilePathType, verbose: bool = True, 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: True) – Allows verbose.
es_key (str, default: “ElectricalSeries”)
Blackrock Recording#
- class BlackrockRecordingInterface(file_path: FilePathType, nsx_override: Optional[FilePathType] = None, verbose: bool = True, 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 (FilePathType) – The path to the Blackrock with suffix being .ns1, .ns2, .ns3, .ns4m .ns4, or .ns6
verbose (bool, default: True)
es_key (str, default: “ElectricalSeries”)
- class BlackrockSortingInterface(file_path: FilePathType, sampling_frequency: float = None, verbose: bool = True)[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: True) – Enables verbosity
CellExplorer Sorting#
- add_channel_metadata_to_recoder(recording_extractor, folder_path: FolderPathType)[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: FolderPathType)[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: FolderPathType)[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: FolderPathType, verbose: bool = True, 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: True) – 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
verbose (bool, default: True) – 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.
- 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: FolderPathType, verbose: bool = True, es_key: str = 'ElectricalSeriesLFP')[source]#
Bases:
CellExplorerRecordingInterface
- Parameters
verbose (bool, default: True) – 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.
- 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)
The default is False (append mode).
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’, ‘lfp’, ‘processed’})
write_electrical_series (bool, default: True) – Electrical series are written in acquisition. If False, only device, electrode_groups, and electrodes are written to NWB.
compression ({‘gzip’, ‘lzf’, None}) – Type of compression to use. Set to None to disable all compression.
compression_opts (int, default: 4) – Only applies to compression=”gzip”. Controls the level of the GZIP.
iterator_type ({‘v2’, ‘v1’}) – The type of DataChunkIterator to use. ‘v1’ is the original DataChunkIterator of the hdmf data_utils. ‘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.
- class CellExplorerSortingInterface(file_path: FilePathType, verbose: bool = True)[source]#
Bases:
BaseSortingExtractorInterface
Primary data interface class for converting Cell Explorer spiking data.
Initialize read of Cell Explorer file.
- Parameters
file_path (FilePathType) – Path to .spikes.cellinfo.mat file.
verbose (bool, default: True)
European Data Format (EDF) Recording#
- class EDFRecordingInterface(file_path: FilePathType, verbose: bool = True, es_key: str = 'ElectricalSeries')[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: True) – Allows verbose.
es_key (str, default: “ElectricalSeries”)
Intan Recording#
- class IntanRecordingInterface(file_path: FilePathType, stream_id: str = '0', verbose: bool = True, es_key: str = 'ElectricalSeries')[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 (FilePathType) – Path to either a rhd or a rhs file
stream_id (str, optional) – The stream of the data for spikeinterface, “0” by default.
verbose (bool, default: True) – Verbose
es_key (str, default: “ElectricalSeries”)
KiloSort Sorting#
- class KiloSortSortingInterface(folder_path: FolderPathType, keep_good_only: bool = False, verbose: bool = True)[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)
MaxOne Recording#
- class MaxOneRecordingInterface(file_path: FilePathType, hdf5_plugin_path: Optional[FolderPathType] = None, download_plugin: bool = True, verbose: bool = True, 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.
- static auto_install_maxwell_hdf5_compression_plugin(hdf5_plugin_path: Optional[FolderPathType] = 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: FilePathType, verbose: bool = True, 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: True) – Allows verbose.
es_key (str, default: “ElectricalSeries”)
Neuralynx Recording & Sorting#
- class NeuralynxRecordingInterface(folder_path: FolderPathType, 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 OpenEphys 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”)
- class NeuralynxSortingInterface(folder_path: FolderPathType, sampling_frequency: float = None, verbose: bool = True)[source]#
Bases:
BaseSortingExtractorInterface
_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: True) – Enables verbosity
- 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: FilePathType, gain: Optional[float] = None, xml_file_path: Optional[FilePathType] = None, verbose: bool = True, 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 (FilePathType) – 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 (FilePathType, 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”)
- static get_ecephys_metadata(xml_file_path: str) dict [source]#
Auto-populates ecephys metadata from the xml_file_path.
- get_metadata() dict [source]#
Child DataInterface classes should override this to match their metadata.
- 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: FilePathType, gain: Optional[float] = None, xml_file_path: Optional[FilePathType] = 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 (FilePathType) – Path to .dat 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 (OptionalFilePathType, 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.
- class NeuroScopeSortingInterface(folder_path: FolderPathType, keep_mua_units: bool = True, exclude_shanks: Optional[list] = None, xml_file_path: Optional[FilePathType] = None, verbose: bool = True)[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. The default is True.
exclude_shanks (list, 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 (FilePathType, 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.
OpenEphys Recording#
- class OpenEphysRecordingInterface(verbose: bool = True, 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: True) – 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.
- static __new__(cls, folder_path: FolderPathType, stream_name: Optional[str] = None, block_index: Optional[int] = None, verbose: bool = True, 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: True)
es_key (str, default: “ElectricalSeries”)
Phy Sorting#
- class PhySortingInterface(folder_path: FolderPathType, exclude_cluster_groups: Optional[list] = None, verbose: bool = True)[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: True)
Plexon Recording & Sorting#
- class PlexonRecordingInterface(file_path: FilePathType, verbose: bool = True, es_key: str = 'ElectricalSeries')[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: True) – Allows verbosity.
es_key (str, default: “ElectricalSeries”)
- class PlexonSortingInterface(file_path: FilePathType, verbose: bool = True)[source]#
Bases:
BaseSortingExtractorInterface
Primary data interface class for converting Plexon spiking data.
Uses
PlexonSortingExtractor
.Load and prepare data for Plexon.
- Parameters
file_path (FilePathType) – Path to the plexon spiking data (.plx file).
verbose (bool, default: True) – Allows verbosity.
Spike2#
- class Spike2RecordingInterface(file_path: FilePathType, verbose: bool = True, 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. CEDRecordingInterface will soon be deprecated. Please use Spike2RecordingInterface instead.
- Parameters
file_path (FilePathType) – Path to .smr or .smrx file.
verbose (bool, default: True)
es_key (str, default: “ElectricalSeries”)
Spikegadgets Recording#
- class SpikeGadgetsRecordingInterface(file_path: FilePathType, stream_id: str = 'trodes', gains: Union[list, numpy.ndarray, NoneType] = None, verbose: bool = True, 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 (FilePathType) – 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”)
SpikeGLX Recording#
- class SpikeGLXConverterPipe(folder_path: FolderPathType, 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.
DataInterfaces for SpikeGLX.
- add_recording_extractor_properties(recording_extractor) None [source]#
Automatically add shankgroup_name and shank_electrode_number for spikeglx.
- class SpikeGLXRecordingInterface(file_path: FilePathType, verbose: bool = True, es_key: Optional[str] = None)[source]#
Bases:
BaseRecordingExtractorInterface
- Parameters
file_path (FilePathType) – Path to .bin file. Point to .ap.bin for SpikeGLXRecordingInterface and .lf.bin for SpikeGLXLFPInterface.
verbose (bool, default: True) – Whether to output verbose text.
es_key (str, default: “ElectricalSeries”)
- classmethod get_source_schema() dict [source]#
Infer the JSON schema for the source_data from the method signature (annotation typing).
- get_metadata() dict [source]#
Child DataInterface classes should override this to match their metadata.
- 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 SpikeGLXLFPInterface(file_path: FilePathType, verbose: bool = True, es_key: str = 'ElectricalSeriesLF')[source]#
Bases:
SpikeGLXRecordingInterface
Primary data interface class for converting the low-pass (lf) SpikeGLX format.
- Parameters
file_path (FilePathType) – Path to .bin file. Point to .ap.bin for SpikeGLXRecordingInterface and .lf.bin for SpikeGLXLFPInterface.
verbose (bool, default: True) – Whether to output verbose text.
es_key (str, default: “ElectricalSeries”)
- class SpikeGLXNIDQInterface(file_path: FilePathType, verbose: bool = True, load_sync_channel: bool = False, es_key: str = 'ElectricalSeriesNIDQ')[source]#
Bases:
BaseRecordingExtractorInterface
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
file_path (FilePathType) – Path to .nidq.bin file.
verbose (bool, default: True) – Whether to output verbose text.
load_sync_channel (bool, default: False) – Whether to load the last channel in the stream, which is typically used for synchronization. If True, then the probe is not loaded.
es_key (str, default: “ElectricalSeriesNIDQ”)
- classmethod get_source_schema() dict [source]#
Infer the JSON schema for the source_data from the method signature (annotation typing).
- get_metadata() dict [source]#
Child DataInterface classes should override this to match their metadata.
- get_channel_names() List[str] [source]#
Return a list of channel names as set in the recording extractor.
- 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: FolderPathType, gain: float, stream_id: str = '0', verbose: bool = True, 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: True) – Allows verbose.
es_key (str, optional)
Notes
Stream “0” corresponds to LFP for gin data. Other streams seem non-electrical.