TCossaLabABFReader¶
class TCossaLabABFReader(settings: Optional[dict] = None)
Bases: MetaReader
Subclass of MetaReader for reading ABF2 files
Public Methods¶
- TCossaLabABFReader.close_resources(channel: int | None = None) None¶
Perform any actions necessary to gracefully close resources before app exit
- Parameters:
channel (Optional[int]) – channel ID
- TCossaLabABFReader.get_empty_settings(globally_available_plugins: Dict[str, List[str]] | None = None, standalone: bool = False) Dict[str, Dict[str, Any]]¶
Get a dict populated with keys needed to initialize the filter if they are not set yet. This dict must have the following structure, but Min, Max, and Options can be skipped or explicitly set to None if they are not used. Type is required; Value may be omitted or set to None, both meaning there is no default and the user must supply one. All values provided must be consistent with Type.
settings = {'Parameter 1': {'Type': <int, float, str, bool>, 'Value': <value> or None, 'Options': [<option_1>, <option_2>, ... ] or None, 'Min': <min_value> or None, 'Max': <max_value> or None, 'Units': <unit str> or None }, ... }
Several parameter keywords are reserved: these are
‘Input File’ ‘Output File’ ‘Folder’
These must have Type str and will cause the GUI to generate widgets to allow selection of these elements when used
- Parameters:
- Returns:
the dict that must be filled in to initialize the filter
- Return type:
Private Methods¶
- TCossaLabABFReader._convert_data(data: ndarray[tuple[int, ...], dtype[int16]], config: dict, raw_data: bool = False) Tuple[ndarray, float, float] | ndarray¶
Scale or otherwise transform and return requested data. Applies the per-channel telegraph-derived scale recovered from the ABF2 header to convert raw ADC codes to pA. if raw_data is true, return also scale and offset
- Parameters:
- Returns:
Converted data, and scale and offset if and only if raw_data is True
- Return type:
- TCossaLabABFReader._get_configs(datafiles: List[str]) List[dict]¶
Load configuration files as dictionaries, corresponding to datamaps as needed. Default behavior assumes there are no config files needed.
- Parameters:
datafiles (List[str]) – List of data file paths.
- Returns:
List of configuration dictionaries.
- Return type:
List[dict]
- Raises:
NotImplementedError – If the file type is not ABF2 specifically
TypeError – If one of the channels does not have an “I” in its header label
ValueError – If any number of channels other than 2 is found in the data file
- TCossaLabABFReader._get_file_channel_stamps(file_names: List[str], configs: List[dict]) List[int]¶
Get a list of serialization keys used to sort the list of files associated to the experiment.
- Parameters:
- Returns:
List of channel numbers parsed from configuration.
- Return type:
List[int]
- Raises:
ValueError – If the filename does not match the expected pattern
- TCossaLabABFReader._get_file_pattern(file_name: str) str¶
Get the base name for matching other files to the same dataset as the initial one provided to the constructor.
- Parameters:
file_name (str) – File path.
- Returns:
Base name for matching other files.
- Return type:
- Raises:
ValueError – If the base naming pattern cannot be ascertained.
- TCossaLabABFReader._get_file_time_stamps(file_names: List[str], configs: List[dict]) List[int]¶
Get a list of serialization keys used to sort the list of files associated to the experiment.
- Parameters:
- Returns:
List of timestamps parsed from configuration.
- Return type:
List[int]
- Raises:
ValueError – If the filename does not match the expected pattern
- TCossaLabABFReader._map_data(datafiles: List[str], configs: List[dict]) List[ndarray]¶
Map data files into a set of memmaps or similarly define a way to access the raw data on disk. Returns a list of memmaps corresponding to each datafile/configfile pair.
- Parameters:
- Returns:
List of memmaps containing raw data.
- Return type:
List[np.ndarray]
- Raises:
FileNotFoundError – If at least one of the input raw data files is missing or renamed.
OSError – If the file indicated is inaccessible.
- TCossaLabABFReader._set_file_extension() str¶
Set the expected file extension for files read using this reader subclass
- TCossaLabABFReader._set_raw_dtype(configs: List[dict]) dtype¶
Set the data type for the raw data in files of this type
- Parameters:
configs (List[dict]) – List of configuration dictionaries corresponding to data files.
- Returns:
the dtype of the raw data in your data files
- Return type:
np.dtype
- TCossaLabABFReader._validate_file_type(filename: PathLike) None¶
Check that the file(s) being opened are of the correct type, and raise IOError if not
- Parameters:
filename (os.PathLike) – the path to one of the files to be opened