Spike Interface#
Interface with spikeinterface#
- add_devices_to_nwbfile(nwbfile: NWBFile, metadata: Optional[DeepDict] = None)[source]#
Add device information to nwbfile object.
Will always ensure nwbfile has at least one device, but multiple devices within the metadata list will also be created.
- Parameters
nwbfile (NWBFile) – nwb file to which the recording information is to be added
metadata (DeepDict) – metadata info for constructing the nwb file (optional). Should be of the format:
metadata['Ecephys']['Device'] = [ { 'name': my_name, 'description': my_description }, ... ]
Missing keys in an element of metadata[‘Ecephys’][‘Device’] will be auto-populated with defaults.
- add_electrode_groups_to_nwbfile(recording: BaseRecording, nwbfile: NWBFile, metadata: Optional[dict] = None)[source]#
Add electrode group information to nwbfile object.
Will always ensure nwbfile has at least one electrode group. Will auto-generate a linked device if the specified name does not exist in the nwbfile.
- Parameters
recording (spikeinterface.BaseRecording)
nwbfile (pynwb.NWBFile) – nwb file to which the recording information is to be added
metadata (dict) – metadata info for constructing the nwb file (optional). Should be of the format:
metadata['Ecephys']['ElectrodeGroup'] = [ { 'name': my_name, 'description': my_description, 'location': electrode_location, 'device': my_device_name }, ... ]
Missing keys in an element of
metadata['Ecephys']['ElectrodeGroup']
will be auto-populated with defaults. Group names set by RecordingExtractor channel properties will also be included with passed metadata, but will only use default description and location.
- add_electrodes_to_nwbfile(recording: BaseRecording, nwbfile: NWBFile, metadata: Optional[dict] = None, exclude: tuple = (), null_values_for_properties: Optional[dict] = None)[source]#
Build an electrode_table from the recording information and it to the nwbfile object.
- Parameters
recording (spikeinterface.BaseRecording)
nwbfile (NWBFile) – nwb file to which the recording information is to be added
metadata (dict) – metadata info for constructing the nwb file (optional). Should be of the format:
metadata['Ecephys']['Electrodes'] = [ { 'name': my_name, 'description': my_description }, ... ]
Note that data intended to be added to the electrodes table of the NWBFile should be set as channel properties in the RecordingExtractor object. Missing keys in an element of metadata[‘Ecephys’][‘ElectrodeGroup’] will be auto-populated with defaults whenever possible. If ‘my_name’ is set to one of the required fields for nwbfile electrodes (id, x, y, z, imp, location, filtering, group_name), then the metadata will override their default values. Setting ‘my_name’ to metadata field ‘group’ is not supported as the linking to nwbfile.electrode_groups is handled automatically; please specify the string ‘group_name’ in this case. If no group information is passed via metadata, automatic linking to existing electrode groups, possibly including the default, will occur.
exclude (tuple) – An iterable containing the string names of channel properties in the RecordingExtractor object to ignore when writing to the NWBFile.
- check_if_recording_traces_fit_into_memory(recording: BaseRecording, segment_index: int = 0) None [source]#
Raises an error if the full traces of a recording extractor are larger than psutil.virtual_memory().available.
- Parameters
recording (spikeinterface.BaseRecording) – A recording extractor object from spikeinterface.
segment_index (int, optional) – The segment index of the recording extractor object, by default 0
- Raises
MemoryError –
- add_electrical_series_to_nwbfile(recording: BaseRecording, nwbfile: NWBFile, metadata: dict = None, segment_index: int = 0, starting_time: Optional[float] = None, write_as: Literal['raw', 'processed', 'lfp'] = 'raw', es_key: str = None, write_scaled: bool = False, iterator_type: Optional[str] = 'v2', iterator_opts: Optional[dict] = None, always_write_timestamps: bool = False)[source]#
Adds traces from recording object as ElectricalSeries to an NWBFile object.
- Parameters
recording (SpikeInterfaceRecording) – A recording extractor from spikeinterface
nwbfile (NWBFile) – nwb file 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 )
segment_index (int, default: 0) – The recording segment to add to the NWBFile.
starting_time (float, optional) – Sets the starting time of the ElectricalSeries to a manually set value.
write_as ({‘raw’, ‘processed’, ‘lfp’}) – How to save the traces data in the nwb file. Options: - ‘raw’: save it in acquisition - ‘processed’: save it as FilteredEphys, in a processing module - ‘lfp’: save it as LFP, in a processing module
es_key (str, optional) – Key in metadata dictionary containing metadata info for the specific electrical series
write_scaled (bool, default: False) – If True, writes the traces in uV with the right conversion. If False , the data is stored as it is and the right conversions factors are added to the nwbfile.
iterator_type ({“v2”, None}, default: ‘v2’) – The type of DataChunkIterator to use. ‘v2’ is the locally developed SpikeInterfaceRecordingDataChunkIterator, which offers full control over chunking. None: write the TimeSeries with no memory chunking.
iterator_opts (dict, optional) – Dictionary of options for the iterator. See https://hdmf.readthedocs.io/en/stable/hdmf.data_utils.html#hdmf.data_utils.GenericDataChunkIterator for the full list of options.
always_write_timestamps (bool, default: False) – Set to True to always write timestamps. By default (False), the function checks if the timestamps are uniformly sampled, and if so, stores the data using a regular sampling rate instead of explicit timestamps. If set to True, timestamps will be written explicitly, regardless of whether the sampling rate is uniform.
Notes
Missing keys in an element of metadata[‘Ecephys’][‘ElectrodeGroup’] will be auto-populated with defaults whenever possible.
- add_electrodes_info_to_nwbfile(recording: BaseRecording, nwbfile: NWBFile, metadata: dict = None)[source]#
Add device, electrode_groups, and electrodes info to the nwbfile.
- Parameters
recording (SpikeInterfaceRecording)
nwbfile (NWBFile) – NWB file 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']['Electrodes'] = [ { 'name': my_name, 'description': my_description }, ... ]
Note that data intended to be added to the electrodes table of the
NWBFile
should be set as channel properties in theRecordingExtractor
object. Missing keys in an element ofmetadata['Ecephys']['ElectrodeGroup']
will be auto-populated with defaults whenever possible. If'my_name'
is set to one of the required fields for nwbfile electrodes (id, x, y, z, imp, location, filtering, group_name), then the metadata will override their default values. Setting'my_name'
to metadata field'group'
is not supported as the linking tonwbfile.electrode_groups
is handled automatically; please specify the string'group_name'
in this case. If no group information is passed via metadata, automatic linking to existing electrode groups, possibly including the default, will occur.
- add_recording_to_nwbfile(recording: BaseRecording, nwbfile: NWBFile, metadata: Optional[dict] = None, starting_time: Optional[float] = None, write_as: Literal['raw', 'processed', 'lfp'] = 'raw', es_key: Optional[str] = None, write_electrical_series: bool = True, write_scaled: bool = False, iterator_type: str = 'v2', iterator_opts: Optional[dict] = None, always_write_timestamps: bool = False)[source]#
Add traces from a recording object as an ElectricalSeries to an NWBFile object. Also adds device, electrode_groups, and electrodes to the NWBFile.
- Parameters
recording (BaseRecording) – A recording extractor from SpikeInterface.
nwbfile (pynwb.NWBFile) – The NWBFile object to which the recording information is to be added.
metadata (dict, optional) – Metadata information for constructing the NWBFile. This should include:
- metadata[‘Ecephys’][‘ElectricalSeries’]dict
Dictionary with metadata for the ElectricalSeries, such as:
- namestr
Name of the ElectricalSeries.
- descriptionstr
Description of the ElectricalSeries.
starting_time (float, optional) – Manually set the starting time of the ElectricalSeries. If not provided, the starting time is taken from the recording extractor.
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.
es_key (str, optional) – Key in the metadata dictionary containing metadata information for the specific ElectricalSeries.
write_electrical_series (bool, default=True) – If True, writes the ElectricalSeries to the NWBFile. If False, no ElectricalSeries is written.
write_scaled (bool, default=False) – If True, writes the traces in microvolts (uV) with the appropriate conversion. If False, the data is stored as-is, and the correct conversion factors are added to the NWBFile.
iterator_type ({‘v2’, None}, default=’v2’) – The type of DataChunkIterator to use when writing data in chunks. Options are:
‘v2’: The SpikeInterfaceRecordingDataChunkIterator, which offers full control over chunking.
None: Write the TimeSeries with no memory chunking.
iterator_opts (dict, optional) – Dictionary of options for the iterator. Refer to the documentation at https://hdmf.readthedocs.io/en/stable/hdmf.data_utils.html#hdmf.data_utils.GenericDataChunkIterator for a full list of available options.
always_write_timestamps (bool, default: False) – Set to True to always write timestamps. By default (False), the function checks if the timestamps are uniformly sampled, and if so, stores the data using a regular sampling rate instead of explicit timestamps. If set to True, timestamps will be written explicitly, regardless of whether the sampling rate is uniform.
Notes
Missing keys in an element of metadata[‘Ecephys’][‘ElectrodeGroup’] will be auto-populated with defaults whenever possible. Ensure that the provided metadata dictionary is correctly structured to avoid unintended behavior.
- write_recording_to_nwbfile(recording: BaseRecording, nwbfile_path: Optional[Path] = None, nwbfile: Optional[NWBFile] = None, metadata: Optional[dict] = None, overwrite: bool = False, verbose: bool = False, starting_time: Optional[float] = None, write_as: Optional[str] = 'raw', es_key: Optional[str] = None, write_electrical_series: bool = True, write_scaled: bool = False, iterator_type: Optional[str] = 'v2', iterator_opts: Optional[dict] = None) NWBFile [source]#
Primary method for writing a RecordingExtractor object to an NWBFile.
- Parameters
recording (spikeinterface.BaseRecording)
nwbfile_path (FilePath, optional) – Path for where to write or load (if overwrite=False) the NWBFile. If specified, the context will always write to this location.
nwbfile (NWBFile, optional) – If passed, this function will fill the relevant fields within the NWBFile object. E.g., calling:
write_recording(recording=my_recording_extractor, nwbfile=my_nwbfile)
will result in the appropriate changes to the my_nwbfile object. If neither ‘nwbfile_path’ nor ‘nwbfile’ are specified, an NWBFile object will be automatically generated and returned by the function.
metadata (dict, optional) – metadata info for constructing the nwb file (optional). Should be of the format:
metadata['Ecephys'] = { 'Device': [ { 'name': my_name, 'description': my_description }, ... ] 'ElectrodeGroup': [ { 'name': my_name, 'description': my_description, 'location': electrode_location, 'device': my_device_name }, ... ] 'Electrodes': [ { 'name': my_name, 'description': my_description }, ... ] 'ElectricalSeries' = { 'name': my_name, 'description': my_description }
Note that data intended to be added to the electrodes table of the NWBFile should be set as channel properties in the RecordingExtractor object.
overwrite (bool, default: False) – Whether to overwrite the NWBFile if one exists at the nwbfile_path.
verbose (bool, default: False) – If ‘nwbfile_path’ is specified, informs user after a successful write operation.
starting_time (float, optional) – Sets the starting time of the ElectricalSeries to a manually set value.
write_as ({‘raw’, ‘processed’, ‘lfp’}, optional) – How to save the traces data in the nwb file. - ‘raw’ will save it in acquisition - ‘processed’ will save it as FilteredEphys, in a processing module - ‘lfp’ will save it as LFP, in a processing module
es_key (str, optional) – Key in metadata dictionary containing metadata info for the specific electrical series
write_electrical_series (bool, default: True) – If True, electrical series are written in acquisition. If False, only device, electrode_groups, and electrodes are written to NWB.
write_scaled (bool, default: True) – If True, writes the scaled traces (return_scaled=True)
iterator_type ({“v2”, None}) – The type of DataChunkIterator to use. ‘v2’ is the locally developed SpikeInterfaceRecordingDataChunkIterator, which offers full control over chunking. None: write the TimeSeries with no memory 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.
- add_units_table_to_nwbfile(sorting: BaseSorting, nwbfile: NWBFile, unit_ids: Optional[list[Union[str, int]]] = None, property_descriptions: Optional[dict] = None, skip_properties: Optional[list[str]] = None, units_table_name: str = 'units', unit_table_description: Optional[str] = None, write_in_processing_module: bool = False, waveform_means: Optional[ndarray] = None, waveform_sds: Optional[ndarray] = None, unit_electrode_indices: Optional[list[list[int]]] = None, null_values_for_properties: Optional[dict] = None)[source]#
Add sorting data to a NWBFile object as a Units table.
This function extracts unit properties from a SortingExtractor object and writes them to an NWBFile Units table, either in the primary units interface or the processing module (for intermediate/historical data). It handles unit selection, property customization, waveform data, and electrode mapping.
- Parameters
sorting (spikeinterface.BaseSorting) – The SortingExtractor object containing unit data.
nwbfile (pynwb.NWBFile) – The NWBFile object to write the unit data into.
unit_ids (list of int or str, optional) – The specific unit IDs to write. If None, all units are written.
property_descriptions (dict, optional) – Custom descriptions for unit properties. Keys should match property names in sorting, and values will be used as descriptions in the Units table.
skip_properties (list of str, optional) – Unit properties to exclude from writing.
units_table_name (str, default: ‘units’) – Name of the Units table. Must be ‘units’ if write_in_processing_module is False.
unit_table_description (str, optional) – Description for the Units table (e.g., sorting method, curation details).
write_in_processing_module (bool, default: False) – If True, write to the processing module (intermediate data). If False, write to the primary NWBFile.units table.
waveform_means (np.ndarray, optional) – Waveform mean (template) for each unit. Shape: (num_units, num_samples, num_channels).
waveform_sds (np.ndarray, optional) – Waveform standard deviation for each unit. Shape: (num_units, num_samples, num_channels).
unit_electrode_indices (list of lists of int, optional) – For each unit, a list of electrode indices corresponding to waveform data.
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.
- add_sorting_to_nwbfile(sorting: BaseSorting, nwbfile: Optional[NWBFile] = None, unit_ids: Optional[Union[list[str], list[int]]] = None, property_descriptions: Optional[dict] = None, skip_properties: Optional[list[str]] = None, write_as: Literal['units', 'processing'] = 'units', units_name: str = 'units', units_description: str = 'Autogenerated by neuroconv.', waveform_means: Optional[ndarray] = None, waveform_sds: Optional[ndarray] = None, unit_electrode_indices: Optional[list[list[int]]] = None)[source]#
Add sorting data (units and their properties) to an NWBFile.
This function serves as a convenient wrapper around add_units_table to match Spikeinterface’s SortingExtractor
- Parameters
sorting (BaseSorting) – The SortingExtractor object containing unit data.
nwbfile (pynwb.NWBFile, optional) – The NWBFile object to write the unit data into.
unit_ids (list of int or str, optional) – The specific unit IDs to write. If None, all units are written.
property_descriptions (dict, optional) – Custom descriptions for unit properties. Keys should match property names in sorting, and values will be used as descriptions in the Units table.
skip_properties (list of str, optional) – Unit properties to exclude from writing.
write_as ({‘units’, ‘processing’}, default: ‘units’) –
- Where to write the unit data:
‘units’: Write to the primary NWBFile.units table.
‘processing’: Write to the processing module (intermediate data).
units_name (str, default: ‘units’) – Name of the Units table. Must be ‘units’ if write_as is ‘units’.
units_description (str, optional) – Description for the Units table (e.g., sorting method, curation details).
waveform_means (np.ndarray, optional) – Waveform mean (template) for each unit. Shape: (num_units, num_samples, num_channels).
waveform_sds (np.ndarray, optional) – Waveform standard deviation for each unit. Shape: (num_units, num_samples, num_channels).
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.
- write_sorting_to_nwbfile(sorting: BaseSorting, nwbfile_path: Optional[Path] = None, nwbfile: Optional[NWBFile] = None, metadata: Optional[dict] = None, overwrite: bool = False, verbose: bool = False, unit_ids: Optional[list[Union[str, int]]] = None, property_descriptions: Optional[dict] = None, skip_properties: Optional[list[str]] = None, write_as: Literal['units', 'processing'] = 'units', units_name: str = 'units', units_description: str = 'Autogenerated by neuroconv.', waveform_means: Optional[ndarray] = None, waveform_sds: Optional[ndarray] = None, unit_electrode_indices=None)[source]#
Primary method for writing a SortingExtractor object to an NWBFile.
- Parameters
sorting (spikeinterface.BaseSorting)
nwbfile_path (FilePath, optional) – Path for where to write or load (if overwrite=False) the NWBFile. If specified, the context will always write to this location.
nwbfile (NWBFile, optional) – If passed, this function will fill the relevant fields within the NWBFile object. E.g., calling:
write_recording(recording=my_recording_extractor, nwbfile=my_nwbfile)
will result in the appropriate changes to the my_nwbfile object. If neither ‘nwbfile_path’ nor ‘nwbfile’ are specified, an NWBFile object will be automatically generated and returned by the function.
metadata (dict, optional) – Metadata dictionary with information used to create the NWBFile when one does not exist or overwrite=True.
overwrite (bool, default: False) – Whether to overwrite the NWBFile if one exists at the nwbfile_path. The default is False (append mode).
verbose (bool, default: False) – If ‘nwbfile_path’ is specified, informs user after a successful write operation.
unit_ids (list, optional) – Controls the unit_ids that will be written to the nwb file. If None (default), all units are written.
property_descriptions (dict, optional) – For each key in this dictionary which matches the name of a unit property in sorting, adds the value as a description to that custom unit column.
skip_properties (list of str, optional) – Each string in this list that matches a unit property will not be written to the NWBFile.
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.’)
waveform_means (np.ndarray, optional) – Waveform mean (template) for each unit. Shape: (num_units, num_samples, num_channels).
waveform_sds (np.ndarray, optional) – Waveform standard deviation for each unit. Shape: (num_units, num_samples, num_channels).
unit_electrode_indices (list of lists of int, optional) – For each unit, a list of electrode indices corresponding to waveform data.
- add_sorting_analyzer_to_nwbfile(sorting_analyzer: SortingAnalyzer, nwbfile: Optional[NWBFile] = None, metadata: Optional[dict] = None, recording: Optional[BaseRecording] = None, unit_ids: Optional[Union[list[str], list[int]]] = None, skip_properties: Optional[list[str]] = None, property_descriptions: Optional[dict] = None, write_as: Literal['units', 'processing'] = 'units', units_name: str = 'units', units_description: str = 'Autogenerated by neuroconv.')[source]#
Convenience function to write directly a sorting analyzer object to an nwbfile.
The function adds the data of the recording and the sorting plus the following information from the sorting analyzer: - quality metrics - template mean and std - template metrics
- Parameters
sorting_analyzer (spikeinterface.SortingAnalyzer) – The sorting analyzer object to be written to the NWBFile.
nwbfile (NWBFile, optional) – If passed, this function will fill the relevant fields within the NWBFile object. E.g., calling:
write_recording(recording=my_recording_extractor, nwbfile=my_nwbfile)
will result in the appropriate changes to the my_nwbfile object. If neither ‘nwbfile_path’ nor ‘nwbfile’ are specified, an NWBFile object will be automatically generated and returned by the function.
metadata (dict, optional) – Metadata dictionary with information used to create the NWBFile when one does not exist or overwrite=True. The “Ecephys” section of metadata is also used to create electrodes and electrical series fields.
recording (BaseRecording, optional) – If the sorting_analyzer is ‘recordingless’, this argument needs to be passed to save electrode info. Otherwise, electrodes info is not added to the nwb file.
unit_ids (list, optional) – Controls the unit_ids that will be written to the nwb file. If None (default), all units are written.
property_descriptions (dict, optional) – For each key in this dictionary which matches the name of a unit property in sorting, adds the value as a description to that custom unit column.
skip_properties (list of str, optional) – Each string in this list that matches a unit property will not be written to the NWBFile.
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, optional, 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.’)
- write_sorting_analyzer_to_nwbfile(sorting_analyzer: SortingAnalyzer, nwbfile_path: Optional[Path] = None, nwbfile: Optional[NWBFile] = None, metadata: Optional[dict] = None, overwrite: bool = False, recording: Optional[BaseRecording] = None, verbose: bool = False, unit_ids: Optional[Union[list[str], list[int]]] = None, write_electrical_series: bool = False, add_electrical_series_kwargs: Optional[dict] = None, skip_properties: Optional[list[str]] = None, property_descriptions: Optional[dict] = None, write_as: Literal['units', 'processing'] = 'units', units_name: str = 'units', units_description: str = 'Autogenerated by neuroconv.')[source]#
Convenience function to write directly a sorting analyzer object to an nwbfile.
The function adds the data of the recording and the sorting plus the following information from the sorting analyzer: - quality metrics - template mean and std - template metrics
- Parameters
sorting_analyzer (spikeinterface.SortingAnalyzer) – The sorting analyzer object to be written to the NWBFile.
nwbfile_path (FilePath) – Path for where to write or load (if overwrite=False) the NWBFile. If specified, the context will always write to this location.
nwbfile (NWBFile, optional) – If passed, this function will fill the relevant fields within the NWBFile object. E.g., calling:
write_recording(recording=my_recording_extractor, nwbfile=my_nwbfile)
will result in the appropriate changes to the my_nwbfile object. If neither ‘nwbfile_path’ nor ‘nwbfile’ are specified, an NWBFile object will be automatically generated and returned by the function.
metadata (dict, optional) – Metadata dictionary with information used to create the NWBFile when one does not exist or overwrite=True. The “Ecephys” section of metadata is also used to create electrodes and electrical series fields.
overwrite (bool, default: False) – Whether to overwrite the NWBFile if one exists at the nwbfile_path.
recording (BaseRecording, optional) – If the sorting_analyzer is ‘recordingless’, this argument needs to be passed to save electrode info. Otherwise, electrodes info is not added to the nwb file.
verbose (bool, default: False) – If ‘nwbfile_path’ is specified, informs user after a successful write operation.
unit_ids (list, optional) – Controls the unit_ids that will be written to the nwb file. If None (default), all units are written.
write_electrical_series (bool, default: False) – If True, the recording object associated to the analyzer is written as an electrical series.
add_electrical_series_kwargs (dict, optional) – Keyword arguments to control the add_electrical_series() function in case write_electrical_series=True
property_descriptions (dict, optional) – For each key in this dictionary which matches the name of a unit property in sorting, adds the value as a description to that custom unit column.
skip_properties (list of str, optional) – Each string in this list that matches a unit property will not be written to the NWBFile.
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.’)
Data chunk iterator#
- class SpikeInterfaceRecordingDataChunkIterator(recording: spikeinterface.core.baserecording.BaseRecording, segment_index: int = 0, return_scaled: bool = False, buffer_gb: Optional[float] = None, buffer_shape: Optional[tuple] = None, chunk_mb: Optional[float] = None, chunk_shape: Optional[tuple] = None, display_progress: bool = False, progress_bar_class: Optional[tqdm.std.tqdm] = None, progress_bar_options: Optional[dict] = None)[source]#
Bases:
GenericDataChunkIterator
DataChunkIterator specifically for use on RecordingExtractor objects.
Initialize an Iterable object which returns DataChunks with data and their selections on each iteration.
- Parameters
recording (SpikeInterfaceRecording) – The SpikeInterfaceRecording object (RecordingExtractor or BaseRecording) which handles the data access.
segment_index (int, optional) – The recording segment to iterate on. Defaults to 0.
return_scaled (bool, optional) – Whether to return the trace data in scaled units (uV, if True) or in the raw data type (if False). Defaults to False.
buffer_gb (float, optional) – The upper bound on size in gigabytes (GB) of each selection from the iteration. The buffer_shape will be set implicitly by this argument. Cannot be set if buffer_shape is also specified. The default is 1GB.
buffer_shape (tuple, 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 also specified. The default is None.
chunk_mb (float, optional) – The upper bound on size in megabytes (MB) of the internal chunk for the HDF5 dataset. The chunk_shape will be set implicitly by this argument. Cannot be set if chunk_shape is also specified. The default is 10MB, as recommended by the HDF5 group. For more details, search the hdf5 documentation for “Improving IO Performance Compressed Datasets”.
chunk_shape (tuple, optional) – Manual specification of the internal chunk shape for the HDF5 dataset. Cannot be set if chunk_mb is also specified. The default is None.
display_progress (bool, optional) – Display a progress bar with iteration rate and estimated completion time.
progress_bar_class (dict, optional) – The progress bar class to use. Defaults to tqdm.tqdm if the TQDM package is installed.
progress_bar_options (dict, optional) – Dictionary of keyword arguments to be passed directly to tqdm. See tqdm/tqdm for options.
- get_electrical_series_chunk_shape(number_of_channels: int, number_of_frames: int, dtype: dtype, chunk_mb: float = 10.0) tuple[int, int] [source]#
Estimate good chunk shape for an ElectricalSeries dataset.
This function gives good estimates for cloud access patterns.
- Parameters
number_of_channels (int) – The number of channels in the ElectricalSeries dataset.
number_of_frames (int) – The number of frames in the ElectricalSeries dataset.
dtype (np.dtype) – The data type of the ElectricalSeries dataset.
chunk_mb (float, optional) – The upper bound on size in megabytes (MB) of the internal chunk for the HDF5 dataset. The chunk_shape will be set implicitly by this argument.
- Returns
The chunk shape for the ElectricalSeries dataset.
- Return type
tuple[int, int]