RecordingMetadata#

class neurodent.core.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)[source]#

Bases: object

Stores metadata information for neural recordings.

This class handles recording metadata including channel information, sampling rates, timestamps, and voltage units. It can be initialized either from a CSV metadata file (for backward compatibility with DDF binary format) or directly from parameters.

Variables:
  • metadata_path (str | Path | None) – Path to metadata CSV file if loaded from file

  • metadata_df (pd.DataFrame | None) – DataFrame containing metadata if loaded from file

  • n_channels (int) – Number of channels in the recording

  • f_s (float) – Sampling frequency in Hz

  • V_units (str | None) – Voltage units (e.g., ‘µV’, ‘mV’, ‘V’)

  • mult_to_uV (float | None) – Multiplication factor to convert to microvolts

  • precision (str | None) – Data precision/dtype (e.g., ‘float32’, ‘int16’)

  • dt_end (datetime | None) – End datetime of recording

  • channel_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) None[source]#

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 recording

  • f_s (float, optional) – Sampling frequency in Hz

  • dt_end (datetime, optional) – End datetime of recording

  • channel_names (list[str], optional) – List of channel names

  • V_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

to_dict() dict[source]#

Convert RecordingMetadata to a dictionary for JSON serialization.

classmethod from_dict(data: dict) RecordingMetadata[source]#

Create RecordingMetadata from a dictionary (from JSON deserialization).

to_json(file_path: Path) None[source]#

Save RecordingMetadata to a JSON file.

classmethod from_json(file_path: Path) RecordingMetadata[source]#

Load RecordingMetadata from a JSON file.

update_sampling_rate(new_f_s: float) None[source]#

Update the sampling rate in this metadata object.

This should be called when the associated recording is resampled.