RecordingMetadata#
- class neurodent.loading.RecordingMetadata(
- metadata_path: str | Path | None,
- *,
- n_channels: int | None = None,
- f_s: float | None = None,
- dt_end: datetime | None = None,
- channel_names: list[str] | None = None,
- V_units: str | None = None,
- mult_to_uV: float | None = None,
Bases:
objectStores metadata information for neural recordings.
This class handles recording metadata including channel information, sampling rates, timestamps, and voltage units. Every loader in the package initializes it from parameters. It can still be read from a DataWave-style CSV sidecar, a path the removed binary mode used and only tests exercise now.
- Variables:
metadata_path (
str | Path | None) – Path to metadata CSV file if loaded from filemetadata_df (
pd.DataFrame | None) – DataFrame containing metadata if loaded from filen_channels (
int) – Number of channels in the recordingf_s (
float) – Sampling frequency in HzV_units (
str | None) – Voltage units (e.g., ‘µV’, ‘mV’, ‘V’)mult_to_uV (
float | None) – Multiplication factor to convert to microvoltsprecision (
str | None) – Data precision/dtype (e.g., ‘float32’, ‘int16’)dt_end (
datetime | None) – End datetime of recordingchannel_names (
list[str]) – List of channel names
Examples
From parameters: >>> meta = RecordingMetadata( … None, … n_channels=4, … f_s=1000.0, … dt_end=datetime(2023, 1, 1), … channel_names=[‘ch1’, ‘ch2’, ‘ch3’, ‘ch4’] … )
From CSV file: >>> meta = RecordingMetadata(‘/path/to/metadata.csv’)
- __init__(
- metadata_path: str | Path | None,
- *,
- n_channels: int | None = None,
- f_s: float | None = None,
- dt_end: datetime | None = None,
- channel_names: list[str] | None = None,
- V_units: str | None = None,
- mult_to_uV: float | None = None,
Initialize RecordingMetadata either from a file path or direct parameters.
- Parameters:
metadata_path (
str | Path | None) – Path to metadata CSV file. If provided, other parameters are ignored and metadata is loaded from the file.n_channels (
int, optional) – Number of channels in the recordingf_s (
float, optional) – Sampling frequency in Hzdt_end (
datetime, optional) – End datetime of recordingchannel_names (
list[str], optional) – List of channel namesV_units (
str, optional) – Voltage units (e.g., ‘µV’, ‘mV’, ‘V’)mult_to_uV (
float, optional) – Multiplication factor to convert to microvolts
- Raises:
ValueError – If metadata_path is None and required parameters are missing
- classmethod from_dict(
- data: dict,
Create RecordingMetadata from a dictionary (from JSON deserialization).
- to_json(file_path: Path) None[source]#
Save RecordingMetadata to a JSON file.
The file is written atomically (temp file + rename) so an interrupted write never leaves a partial/corrupt metadata sidecar.
- classmethod from_json(
- file_path: Path,
Load RecordingMetadata from a JSON file.