Base Data Interface#
- class BaseDataInterface(verbose: bool = False, **source_data)[source]#
Bases:
ABCAbstract class defining the structure of all DataInterfaces.
- classmethod get_source_schema()[source]#
Infer the JSON schema for the source_data from the method signature (annotation typing).
- get_conversion_options_schema() dict[source]#
Infer the JSON schema for the conversion options from the method signature (annotation typing).
- get_metadata() DeepDict[source]#
Child DataInterface classes should override this to match their metadata.
- run_conversion(nwbfile_path: Optional[str] = None, nwbfile: Optional[NWBFile] = None, metadata: Optional[dict] = None, overwrite: bool = False, **conversion_options)[source]#
Run the NWB conversion for the instantiated data interface.
- Parameters
nwbfile_path (FilePathType) – 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) – An in-memory NWBFile object to write to the location.
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).
- class BaseTemporalAlignmentInterface(verbose: bool = False, **source_data)[source]#
Bases:
BaseDataInterfaceAn extension of the BaseDataInterface that includes several methods for performing temporal alignment.
- abstract 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
- abstract get_timestamps() ndarray[source]#
Retrieve the timestamps for the data in this interface.
- Returns
timestamps – The timestamps for the data stream.
- Return type
numpy.ndarray
- abstract set_aligned_timestamps(aligned_timestamps: ndarray) None[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_starting_time(aligned_starting_time: float) None[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.
- align_by_interpolation(unaligned_timestamps: ndarray, aligned_timestamps: ndarray) None[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.