SingleBinaryDecoder¶
class SingleBinaryDecoder(settings: Optional[dict] = None)
Bases: MetaReader
Subclass of MetaReader for reading a single, user-configured raw binary file, with sampling rate, header size, array count, byte order, and data type all specified via settings rather than inferred from a vendor-specific header.
Public Methods¶
- SingleBinaryDecoder.close_resources(channel: int | None = None) None¶
Perform any actions necessary to gracefully close resources before app exit
- Parameters:
channel (Optional[int]) – channel ID
- SingleBinaryDecoder.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. Seeget_empty_settings()for the structure of the dict and whatType,Value,Min,Max,OptionsandUnitsmean in it, and for the reserved keys the GUI builds file pickers from.The keys this plugin adds:
Input File- the raw binary file to read. Unlike the other readers this one has no header to consult, so every parameter below has to be supplied by hand.Sampling Rate(Hz) - the acquisition rate the file was recorded at.Header Bytes- how many bytes to skip before the first sample.Number of Arrays- how many interleaved channels the file holds.Byte Order-'<'for little-endian,'>'for big-endian.Data Type-Floating Point,Signed IntegerorUnsigned Integer.Data Bytes- the width of one sample, 8, 4 or 2 bytes.Bitmask- applied to each integer sample before scaling, for formats that pack status bits into the data word; 0 disables it.ScaleandOffset- the affine conversion from raw sample to pA.
- Parameters:
- Returns:
the dict that must be filled in to initialize the filter
- Return type:
Private Methods¶
- SingleBinaryDecoder._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]
- SingleBinaryDecoder._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.
- SingleBinaryDecoder._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.
- SingleBinaryDecoder._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.
- SingleBinaryDecoder._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.
- SingleBinaryDecoder._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.
- SingleBinaryDecoder._set_file_extension() str¶
Set the expected file extension for files read using this reader subclass
- SingleBinaryDecoder._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
- SingleBinaryDecoder._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.
- Raises:
ValueError – If the settings dict does not contain the correct information.