ipfx.dataset package¶
Submodules¶
ipfx.dataset.create module¶
-
ipfx.dataset.create.
create_ephys_data_set
(nwb_file:str, sweep_info:Union[Dict[str, Any], NoneType]=None, ontology:Union[str, NoneType]=None) → ipfx.dataset.ephys_data_set.EphysDataSet[source]¶ Create an ephys data set with the appropriate nwbdata reader class
Parameters: - nwb_file
- sweep_info
- ontology
Returns: - EphysDataSet
-
ipfx.dataset.create.
get_nwb_version
(nwb_file:str) → Dict[str, Any][source]¶ Find version of the nwb file
Parameters: - nwb_file
Returns: - dict in the format:
- {
major: str full str.
- }
ipfx.dataset.ephys_data_interface module¶
-
class
ipfx.dataset.ephys_data_interface.
EphysDataInterface
(ontology: ipfx.stimulus.StimulusOntology, validate_stim: bool = True)[source]¶ Bases:
abc.ABC
The interface that any child class providing data to the EphysDataSet must implement
Attributes: sweep_numbers
A time-ordered sequence of each sweep’s integer identifier
Methods
get_clamp_mode
(self, sweep_number)Extract clamp mode from the class of Time Series Parameters ———- sweep_number get_full_recording_date
(self)Obtain the full date and time at which recording began. get_stimulus_code
(self, sweep_number)Obtain the code of the stimulus presented on a particular sweep. get_stimulus_unit
(self, sweep_number)Extract unit of a stimulus get_sweep_attrs
(self, sweep_number)Extract sweep attributes get_sweep_data
(self, sweep_number)Extract sweep data get_sweep_metadata
(self, sweep_number)Returns metadata about a sweep get_stimulus_name -
get_clamp_mode
(self, sweep_number) → str[source]¶ Extract clamp mode from the class of Time Series Parameters ———- sweep_number
-
get_full_recording_date
(self) → datetime.datetime[source]¶ Obtain the full date and time at which recording began.
Returns: - A datetime object, with timezone, reporting the start of recording
-
get_stimulus_code
(self, sweep_number:int) → str[source]¶ Obtain the code of the stimulus presented on a particular sweep.
Parameters: - sweep_number : unique identifier for the sweep
Returns: - The codified name of the stimulus presented on the
- identified sweep
-
get_stimulus_unit
(self, sweep_number:int) → str[source]¶ Extract unit of a stimulus
Parameters: - sweep_number
Returns: - stimulus unit
-
get_sweep_attrs
(self, sweep_number) → Dict[str, Any][source]¶ Extract sweep attributes
Parameters: - sweep_number
Returns: - sweep attributes
-
get_sweep_data
(self, sweep_number:int) → Dict[str, Any][source]¶ Extract sweep data
Parameters: - sweep_number
Returns: - dict in the format:
- {
‘stimulus’: np.ndarray, ‘response’: np.ndarray, ‘stimulus_unit’: string, ‘sampling_rate’: float
- }
-
get_sweep_metadata
(self, sweep_number:int) → Dict[str, Any][source]¶ Returns metadata about a sweep
Parameters: - sweep_number : identifier of the sweep whose metadata will be returned
Returns: - dict in the format:
- {
“sweep_number”: int, “stimulus_units”: str, “bridge_balance_mohm”: float, “leak_pa”: float, “stimulus_scale_factor”: float, “stimulus_code”: str, “stimulus_code_ext”: str, “stimulus_name”: str, “clamp_mode”: str
- }
-
sweep_numbers
¶ A time-ordered sequence of each sweep’s integer identifier
ipfx.dataset.ephys_data_set module¶
-
class
ipfx.dataset.ephys_data_set.
EphysDataSet
(data: ipfx.dataset.ephys_data_interface.EphysDataInterface, sweep_info: Optional[List[Dict]] = None)[source]¶ Bases:
object
Attributes: ontology
The stimulus ontology maps codified description of the stimulus type to the human-readable descriptions.
- sweep_info
sweep_table
Each row of the sweep table contains the metadata for a single sweep.
Methods
filtered_sweep_table
(self, clamp_mode, …)Utility for filtering the sweep table get_clamp_mode
(self, sweep_number)Obtain the clamp mode of a given sweep. get_recording_date
(self)Return the date and time at which recording began. get_stimulus_code
(self, sweep_number)Return the (short form) stimulus code for a particular sweep. get_stimulus_code_ext
(self, sweep_number)Obtain the extended stimulus code for a sweep. get_stimulus_units
(self, sweep_number)Report the SI unit of measurement for a sweep’s stimulus data get_sweep_data
(self, sweep_number)Obtain the recorded data for a given sweep. get_sweep_number
(self, stimuli, clamp_mode, …)Convenience for getting the integer identifier of the temporally latest sweep matching argued criteria. get_sweep_numbers
(self, stimuli, clamp_mode, …)Return the integer identifier of all sweeps matching argued criteria sweep
(self, sweep_number)Create an instance of the Sweep class with the data loaded from the from a file sweep_set
(self, sweep_numbers, int, …)Construct a SweepSet object, which offers convenient access to an ordered collection of sweeps. -
CLAMP_MODE
= 'clamp_mode'¶
-
COLUMN_NAMES
= ['stimulus_units', 'stimulus_code', 'stimulus_amplitude', 'stimulus_name', 'clamp_mode', 'sweep_number']¶
-
CURRENT_CLAMP
= 'CurrentClamp'¶
-
STIMULUS_AMPLITUDE
= 'stimulus_amplitude'¶
-
STIMULUS_CODE
= 'stimulus_code'¶
-
STIMULUS_NAME
= 'stimulus_name'¶
-
STIMULUS_UNITS
= 'stimulus_units'¶
-
SWEEP_NUMBER
= 'sweep_number'¶
-
VOLTAGE_CLAMP
= 'VoltageClamp'¶
-
filtered_sweep_table
(self, clamp_mode:Union[str, NoneType]=None, stimuli:Union[Collection[str], NoneType]=None, stimuli_exclude:Union[Collection[str], NoneType]=None) → pandas.core.frame.DataFrame[source]¶ Utility for filtering the sweep table
Parameters: - clamp_mode: filter to one of self.VOLTAGE_CLAMP or self.CURRENT_CLAMP
- stimuli: filter to sweeps presenting these stimuli (codes)
- stimuli_exclude: filter to sweeps not presenting these stimuli
Returns: - filtered sweep table
-
get_clamp_mode
(self, sweep_number:int) → str[source]¶ Obtain the clamp mode of a given sweep. Should be one of EphysDataSet.VOLTAGE_CLAMP or EphysDataSet.CURRENT_CLAMP
Parameters: - sweep_number : identifier for the sweep whose clamp mode will be
returned
Returns: - The clamp mode of the identified sweep
-
get_recording_date
(self) → str[source]¶ Return the date and time at which recording began.
Returns: - a string, formatted like: “%Y-%m-%d %H:%M:%S” in local time
-
get_stimulus_code
(self, sweep_number:int) → str[source]¶ Return the (short form) stimulus code for a particular sweep.
Parameters: - sweep_number : identifier for the sweep whose stimulus code will be
returned
Returns: - code defining the stimulus presented on the identified sweep
-
get_stimulus_code_ext
(self, sweep_number:int) → str[source]¶ Obtain the extended stimulus code for a sweep. This is the stimulus code for that sweep augmented with an integer counter describing the number of presentations of that stimulus up to and including the requested sweep.
Parameters: - sweep_number : identifies the sweep whose extended stimulus code will
- be returned
Returns: - A string of the form “{stimulus_code}[{counter}]”
-
get_stimulus_units
(self, sweep_number:int) → str[source]¶ Report the SI unit of measurement for a sweep’s stimulus data
Parameters: - sweep_number : identifies the sweep whose stimulus unit will be
returned
Returns: - An SI (or derived) unit’s name
-
get_sweep_data
(self, sweep_number:int) → Dict[source]¶ Obtain the recorded data for a given sweep.
Parameters: - sweep_number : identifier for the sweep whose data will be returned
Returns: - A dictionary containing at least:
- {
‘stimulus’: np.ndarray, ‘response’: np.ndarray, ‘stimulus_unit’: string, ‘sampling_rate’: float
}
-
get_sweep_number
(self, stimuli:Collection[str], clamp_mode:Union[str, NoneType]=None) → int[source]¶ Convenience for getting the integer identifier of the temporally latest sweep matching argued criteria.
Parameters: - stimuli : filter to sweeps presentingthese stimuli
- clamp_mode : filter to sweeps of this clamp mode
Returns: - The identifier of the last sweep matching argued criteria
-
get_sweep_numbers
(self, stimuli:Collection[str]=None, clamp_mode:Union[str, NoneType]=None) → List[int][source]¶ Return the integer identifier of all sweeps matching argued criteria
Parameters: - stimuli : filter to sweeps presenting these stimuli (codes)
- clamp_mode : filter to sweeps of this clamp mode
Returns: - A list of sweep numbers matching these criteria
-
ontology
¶ The stimulus ontology maps codified description of the stimulus type to the human-readable descriptions.
-
sweep
(self, sweep_number:int) → ipfx.sweep.Sweep[source]¶ Create an instance of the Sweep class with the data loaded from the from a file
Parameters: - sweep_number: int
Returns: - sweep: Sweep object
-
sweep_info
¶
-
sweep_set
(self, sweep_numbers:Union[Sequence[int], int, NoneType]=None) → ipfx.sweep.SweepSet[source]¶ Construct a SweepSet object, which offers convenient access to an ordered collection of sweeps.
Parameters: - sweep_numbers : Identifiers for the sweeps which will make up this set.
If None, use all available sweeps.
Returns: - A SweepSet constructed from the requested sweeps
-
sweep_table
¶ Each row of the sweep table contains the metadata for a single sweep. In particular details of the stimulus presented and the clamp mode. See EphysDataInterface.get_sweep_metadata for more information.
ipfx.dataset.ephys_nwb_data module¶
-
class
ipfx.dataset.ephys_nwb_data.
EphysNWBData
(nwb_file: None, ontology: ipfx.stimulus.StimulusOntology, load_into_memory: bool = True, validate_stim: bool = True)[source]¶ Bases:
ipfx.dataset.ephys_data_interface.EphysDataInterface
Abstract base class for implementing an EphysDataInterface with an NWB file
Provides common NWB2 reading and writing functionality
Attributes: sweep_numbers
A time-ordered sequence of each sweep’s integer identifier
Methods
get_clamp_mode
(self, sweep_number)Extract clamp mode from the class of Time Series Parameters ———- sweep_number get_full_recording_date
(self)Extract session_start_time in nwb Use last value if more than one is present get_stimulus_code
(self, sweep_number)Obtain the code of the stimulus presented on a particular sweep. get_stimulus_unit
(self, sweep_number)Extract unit of a stimulus get_sweep_attrs
(self, sweep_number)Extract sweep attributes get_sweep_data
(self, sweep_number)Extracts numpy arrays, stimulus unit, and sampling rate from sweep. get_sweep_metadata
(self, sweep_number)Returns metadata about a sweep load_nwb
(self, nwb_file, load_into_memory)Load NWB to self.nwb get_long_unit_name get_spike_times get_stimulus_name validate_SI_unit -
RESPONSE
= (<class 'pynwb.icephys.VoltageClampSeries'>, <class 'pynwb.icephys.CurrentClampSeries'>)¶
-
STIMULUS
= (<class 'pynwb.icephys.VoltageClampStimulusSeries'>, <class 'pynwb.icephys.CurrentClampStimulusSeries'>)¶
-
get_clamp_mode
(self, sweep_number)[source]¶ Extract clamp mode from the class of Time Series Parameters ———- sweep_number
-
get_full_recording_date
(self)[source]¶ Extract session_start_time in nwb Use last value if more than one is present
Returns: - recording_date: str
use date format “%Y-%m-%d %H:%M:%S”, drop timezone info
-
get_stimulus_code
(self, sweep_number)[source]¶ Obtain the code of the stimulus presented on a particular sweep.
Parameters: - sweep_number : unique identifier for the sweep
Returns: - The codified name of the stimulus presented on the
- identified sweep
-
get_stimulus_unit
(self, sweep_number)[source]¶ Extract unit of a stimulus
Parameters: - sweep_number
Returns: - stimulus unit
-
get_sweep_attrs
(self, sweep_number)[source]¶ Extract sweep attributes
Parameters: - sweep_number
Returns: - sweep attributes
-
get_sweep_data
(self, sweep_number:int) → Dict[str, Union[numpy.ndarray, str, float]][source]¶ Extracts numpy arrays, stimulus unit, and sampling rate from sweep.
Grabs stimulus and response PatchClampSeries and extracts numpy arrays for the stimulus and response time series data as well as the stimulus unit and sampling rate
Parameters: - sweep_number: int
Integer specifying the sweep to extract data from
Returns: - sweep_data : Dict[str, Union[np.ndarray, str, float]]
Dictionary of sweep data, which includes stimulus and response numpy arrays as well as stimulus units and sampling rate.
-
get_sweep_metadata
(self, sweep_number:int)[source]¶ Returns metadata about a sweep
Parameters: - sweep_number : identifier of the sweep whose metadata will be returned
Returns: - dict in the format:
- {
“sweep_number”: int, “stimulus_units”: str, “bridge_balance_mohm”: float, “leak_pa”: float, “stimulus_scale_factor”: float, “stimulus_code”: str, “stimulus_code_ext”: str, “stimulus_name”: str, “clamp_mode”: str
- }
-
load_nwb
(self, nwb_file:None, load_into_memory:bool=True)[source]¶ Load NWB to self.nwb
Parameters: - nwb_file: NWB file path or hdf5 obj
- load_into_memory: whether using load_into_memory approach to load NWB
-
sweep_numbers
¶ A time-ordered sequence of each sweep’s integer identifier
-
class
ipfx.dataset.ephys_nwb_data.
NWBHDF5IO
(*args, **kwargs)[source]¶ Bases:
pynwb.NWBHDF5IO
Simple alias to suppress ‘ignoring namespace’ errors in NWBHDF5IO
Attributes: comm
The MPI communicator to use for parallel I/O.
- driver
manager
The BuildManager this instance is using
mode
Return the HDF5 file mode.
source
The source of the container being read/written i.e.
Methods
close
(self)Close this HDMFIO object to further reading/writing close_linked_files
(self)Close all opened, linked-to files. copy_file
(source_filename, dest_filename[, …])Convenience function to copy an HDF5 file while allowing external links to be resolved. export
(src_io[, nwbfile, write_args])Args: export_io
(path, src_io[, comm, container, …])Export from one backend to HDF5 (class method). get_builder
(h5obj)Get the builder for the corresponding h5py Group or Dataset get_container
(h5obj)Get the container for the corresponding h5py Group or Dataset get_written
(self, builder)Return True if this builder has been written to (or read from) disk by this IO object, False otherwise. load_namespaces
(namespace_catalog[, path, …])Load cached namespaces from a file. open
(self)Open this HDMFIO object for writing of the builder read
()Read a container from the IO source. read_builder
()Returns: set_attributes
(obj, attributes)Args: set_dataio
([data, maxshape, chunks, …])Wrap the given Data object with an H5DataIO. write
(container[, cache_spec, link_data, …])Write the container to an HDF5 file. write_builder
(builder[, link_data, …])Args: write_dataset
(parent, builder[, link_data, …])Write a dataset to HDF5 write_group
(parent, builder[, link_data, …])Args: write_link
(parent, builder)Args: get_type
ipfx.dataset.hbg_nwb_data module¶
-
class
ipfx.dataset.hbg_nwb_data.
HBGNWBData
(nwb_file: str, ontology: ipfx.stimulus.StimulusOntology, load_into_memory: bool = True, validate_stim: bool = True)[source]¶ Bases:
ipfx.dataset.ephys_nwb_data.EphysNWBData
Provides an Ephys Data Interface to an HBG generated NWB file
Attributes: sweep_numbers
A time-ordered sequence of each sweep’s integer identifier
Methods
get_clamp_mode
(self, sweep_number)Extract clamp mode from the class of Time Series Parameters ———- sweep_number get_full_recording_date
(self)Extract session_start_time in nwb Use last value if more than one is present get_stimulus_code
(self, sweep_number)Obtain the code of the stimulus presented on a particular sweep. get_stimulus_unit
(self, sweep_number)Extract unit of a stimulus get_sweep_attrs
(self, sweep_number)Extract sweep attributes get_sweep_data
(self, sweep_number)Extracts numpy arrays, stimulus unit, and sampling rate from sweep. get_sweep_metadata
(self, sweep_number)Returns metadata about a sweep load_nwb
(self, nwb_file, load_into_memory)Load NWB to self.nwb get_long_unit_name get_spike_times get_stimulus_code_ext get_stimulus_name validate_SI_unit -
get_sweep_metadata
(self, sweep_number:int) → Dict[str, Any][source]¶ Returns metadata about a sweep
Parameters: - sweep_number : identifier of the sweep whose metadata will be returned
Returns: - dict in the format:
- {
“sweep_number”: int, “stimulus_units”: str, “bridge_balance_mohm”: float, “leak_pa”: float, “stimulus_scale_factor”: float, “stimulus_code”: str, “stimulus_code_ext”: str, “stimulus_name”: str, “clamp_mode”: str
- }
ipfx.dataset.labnotebook module¶
-
class
ipfx.dataset.labnotebook.
LabNotebookReader
[source]¶ Bases:
object
The Lab Notebook Reader class
This class reads two sections: numeric data and text data
Methods
get_numeric_value
(self, name, data_col, …)fetch numeric data get_text_value
(self, name, data_col, …)fetch text data get_value
(self, name, sweep_num, default_val)looks for key in lab notebook and returns the value associated with the specified sweep, or the default value if no value is found (NaN and empty strings are considered to be non-values) register_enabled_names
(self)register_enabled_names: mapping of notebook keys to keys representing if that value is enabled move this to subclasses if/when key names diverge -
get_numeric_value
(self, name, data_col, sweep_col, enable_col, sweep_num, default_val)[source]¶ fetch numeric data
val_number has 3 dimensions – the first has a shape of (#fields * 9). there are many hundreds of elements in this dimension. they look to represent the full array of values (for each field for each multipatch) for a given point in time, and thus given sweep according to Thomas Braun (igor nwb dev), the first 8 pages are for headstage data, and the 9th is for headstage-independent data
Parameters: - name: str
- data_col: int
- sweep_col: int
- enable_col: int
- sweep_num: int
- default_val: dict
Returns: - last non-empty entry in specified column
- for specified sweep number
-
get_text_value
(self, name, data_col, sweep_col, enable_col, sweep_num, default_val)[source]¶ fetch text data
Parameters: - name: str
- data_col: int
- sweep_col: int
- enable_col: int
- sweep_num: int
- default_val: dict
Returns: - last non-empty entry in specified column
- for specified sweep number
-
get_value
(self, name, sweep_num, default_val)[source]¶ looks for key in lab notebook and returns the value associated with the specified sweep, or the default value if no value is found (NaN and empty strings are considered to be non-values)
name_number has 3 dimensions – the first has shape (#fields * 9) and stores the key names. the second looks to store units for those keys. The third is numeric text but it’s role isn’t clear
val_number has 3 dimensions – the first has a shape of (#fields * 9). there are many hundreds of elements in this dimension. they look to represent the full array of values (for each field for each multipatch) for a given point in time, and thus given sweep
Parameters: - name: str
- sweep_num: int
- default_val: dict
Returns: - values obtained from lab notebook
-
-
class
ipfx.dataset.labnotebook.
LabNotebookReaderIgorNwb
(nwb_file)[source]¶ Bases:
ipfx.dataset.labnotebook.LabNotebookReader
LabNotebookReaderIgorNwb: Loads lab notebook data out of an Igor-generated NWB file. Module input is the name of the nwb file. Notebook data can be read through get_value() function
Methods
get_numeric_value
(self, name, data_col, …)fetch numeric data get_text_value
(self, name, data_col, …)fetch text data get_value
(self, name, sweep_num, default_val)looks for key in lab notebook and returns the value associated with the specified sweep, or the default value if no value is found (NaN and empty strings are considered to be non-values) register_enabled_names
(self)register_enabled_names: mapping of notebook keys to keys representing if that value is enabled move this to subclasses if/when key names diverge get_numerical_keys get_numerical_values get_textual_keys get_textual_values
ipfx.dataset.mies_nwb_data module¶
-
class
ipfx.dataset.mies_nwb_data.
MIESNWBData
(nwb_file: str, notebook: ipfx.dataset.labnotebook.LabNotebookReader, ontology: ipfx.stimulus.StimulusOntology, load_into_memory: bool = True, validate_stim: bool = True)[source]¶ Bases:
ipfx.dataset.ephys_nwb_data.EphysNWBData
Provides an Ephys Data Interface to a MIES generated NWB file
Attributes: sweep_numbers
A time-ordered sequence of each sweep’s integer identifier
Methods
get_clamp_mode
(self, sweep_number)Extract clamp mode from the class of Time Series Parameters ———- sweep_number get_full_recording_date
(self)Extract session_start_time in nwb Use last value if more than one is present get_stimulus_code
(self, sweep_number)Obtain the code of the stimulus presented on a particular sweep. get_stimulus_unit
(self, sweep_number)Extract unit of a stimulus get_sweep_attrs
(self, sweep_number)Extract sweep attributes get_sweep_data
(self, sweep_number)Extracts numpy arrays, stimulus unit, and sampling rate from sweep. get_sweep_metadata
(self, sweep_number)Returns metadata about a sweep load_nwb
(self, nwb_file, load_into_memory)Load NWB to self.nwb get_long_unit_name get_spike_times get_stim_code_ext get_stimulus_name validate_SI_unit -
get_sweep_metadata
(self, sweep_number:int) → Dict[str, Any][source]¶ Returns metadata about a sweep
Parameters: - sweep_number : identifier of the sweep whose metadata will be returned
Returns: - dict in the format:
- {
“sweep_number”: int, “stimulus_units”: str, “bridge_balance_mohm”: float, “leak_pa”: float, “stimulus_scale_factor”: float, “stimulus_code”: str, “stimulus_code_ext”: str, “stimulus_name”: str, “clamp_mode”: str
- }