ChimeraReader20240101

class ChimeraReader20240101(settings: Optional[dict] = None)

Bases: MetaReader

Subclass of MetaReader for reading chimera VC400 .log files using the 2024-01 format specification with json string embedded in the file header and multiple files per dataset.

Attributes:

datafile (str): Path to the data file. logger (logging.Logger): Logger instance for logging messages. datafiles (List[List[str]]): List of sorted data files grouped by channel and time. configs (List[List[dict]]): List of sorted configuration dictionaries grouped by channel and time. datamaps (List[List[numpy.ndarray]]): List of sorted data maps (memmaps or numpy arrays) grouped by channel and time. file_start_indices (List[List[int]]): List of starting indices for each data map in each channel. total_channel_samples (List[int]): List of total number of samples in each channel. samplerate (float): Sampling rate for data acquisition.

Public Methods

ChimeraReader20240101.close_resources(channel: int | None = None) → None

Perform any actions necessary to gracefully close resources before app exit

Parameters:

channel (Optional[int]) – channel ID

ChimeraReader20240101.get_empty_settings(globally_available_plugins: Dict[str, List[str]] | None = None, standalone: bool = False) → Dict[str, Dict[str, Any]]

Declare the settings this reader exposes, on top of the base contract.

Called by poriscope when the plugin is instantiated or reconfigured, to build the settings dialog and to sanity-check whatever the user enters; the accepted values are then readable through self.settings. See get_empty_settings() for the structure of the dict and what Type, Value, Min, Max, Options and Units mean in it, and for the reserved keys the GUI builds file pickers from.

The keys this plugin adds:

  • Input File - the Chimera .log file to read. Everything else - sample rate, bit depth, scaling - comes from the JSON header embedded at the start of that file, ahead of its <END HEADER> marker.

Parameters:
  • globally_available_plugins (Optional[Dict[str, List[str]]]) – a dict containing all data plugins that exist to date, keyes by metaclass

  • standalone (bool) – False if this is called as part of a GUI, True otherwise. Default False

Returns:

the dict that must be filled in to initialize the filter

Return type:

Dict[str, Dict[str, Any]]

ChimeraReader20240101.report_channel_status(channel: int | None = None, init: bool = False) → str

Report what MetaReader reports, plus this reader’s deprecation notice.

The notice goes in the text shown when the reader is created, because that is where someone who opens a 2024-01 file every day will see it - the changelog only reaches people who read changelogs. It is added in the per-channel arm, so the all-channels report carries one notice per channel, and only when init is True, so it is not repeated on every later status refresh.

Parameters:
  • channel (Optional[int]) – channel ID

  • init (bool) – is the function being called as part of plugin initialization? Default False

Returns:

the status of the channel as a string

Return type:

str

ChimeraReader20240101.reset_channel(channel: int | None = None) → None

Perform any actions necessary to gracefully close resources before app exit. If channel is not None, handle only that channel, else close all of them.

Parameters:

channel (Optional[int]) – channel ID

Private Methods

ChimeraReader20240101._convert_data(data: ndarray[tuple[int, ...], dtype[int16]], config: dict) → ndarray[tuple[int, ...], dtype[float64]]

Convert raw data from disk into rescaled current, in pA.

Parameters:
  • data (npt.NDArray[np.int16]) – Data to convert.

  • config (dict) – Configuration dictionary for data conversion.

Returns:

The data, rescaled to pA.

Return type:

npt.NDArray[np.float64]

ChimeraReader20240101._get_configs(datafiles: List[str]) → List[dict]

Load configuration files as dictionaries, corresponding to datamaps as needed. Parses the JSON header embedded at the start of each .log file (terminated by an <END HEADER> marker) to build a per-file configuration dict.

Parameters:

datafiles (List[str]) – List of data file paths.

Returns:

List of configuration dictionaries.

Return type:

List[dict]

ChimeraReader20240101._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:
  • file_names (List[str]) – List of file paths.

  • configs (List[dict]) – List of configuration dictionaries.

Returns:

List of channel numbers parsed from configuration.

Return type:

List[int]

ChimeraReader20240101._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:

str

Raises:

ValueError – If the base naming pattern cannot be ascertained.

ChimeraReader20240101._get_file_time_stamps(file_names: List[str], configs: List[dict]) → List[datetime]

Get a list of serialization keys used to sort the list of files associated to the experiment.

Parameters:
  • file_names (List[str]) – List of file paths.

  • configs (List[dict]) – List of configuration dictionaries.

Returns:

List of timestamps parsed from configuration.

Return type:

List[datetime]

ChimeraReader20240101._init() → None

called at the start of base class initialization

ChimeraReader20240101._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:
  • datafiles (List[str]) – List of data file paths.

  • configs (List[dict]) – List of configuration dictionaries.

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.

ChimeraReader20240101._set_file_extension() → str

Set the expected file extension for files read using this reader subclass

ChimeraReader20240101._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

ChimeraReader20240101._validate_settings(settings: dict) → None

Validate that the settings dict contains the correct information for use by the subclass.

Parameters:

settings (dict) – Parameters for event detection.