Skip to main content

feature_calculators.LFPackFeatureCalculator

feature_calculators.LFPackFeatureCalculator(
    h5_file,
    recording=None,
    scale=0,
    bin_channels=1,
    name=None,
    neuropixel_version=1,
)

Feature calculator for an lfpack-compressed LF archive.

Args: h5_file (str | Path): lfpack HDF5 archive (single-recording legacy layout, or multi-recording keyed by recording). recording (str, optional): Recording key within a multi-recording archive. Ignored (and not required) for a legacy single-recording file; required when h5_file holds more than one recording. scale (int): lfpack reconstruction scale (0 = full quality). bin_channels (int): Adjacent electrodes summed per output channel. Defaults to 1 (full electrode resolution) – unlike 2026-07_lfp-encoders/lfpack_io.py’s bin_channels=4, which is a choice specific to that regression project; region classification here is per-physical-channel. name (str, optional): Recording identifier used as the OOP pid in outputs. Defaults to recording or the file stem. neuropixel_version (int): Neuropixels version passed to compute_features_from_raw (unused for LF-only feature families, kept for interface parity).

Note: The reader is opened lazily on first access, not at construction.

Attributes

Name Description
reader Return the lazily opened, cached lfpack.LFPackReader.
saturation_mask Boolean saturation mask at this reader’s sampling rate, shape (ns,).

Methods

Name Description
available_duration Return (None, duration_lf) – this source has no AP stream.
load_channel_metadata Build channel metadata from the archive’s annotated channel info.
load_geometry Load ibldsp geometry from the reader, filling derived defaults.
load_raw_snippet Read one LF snippet from the archive.
saturation_times Return the archive’s saturation intervals on the session clock.

available_duration

feature_calculators.LFPackFeatureCalculator.available_duration()

Return (None, duration_lf) – this source has no AP stream.

load_channel_metadata

feature_calculators.LFPackFeatureCalculator.load_channel_metadata()

Build channel metadata from the archive’s annotated channel info.

Returns: pd.DataFrame: channel plus whichever of lateral_um/axial_um/x/y/z/atlas_id/ acronym/labels the archive carries (written by 2026-06-lfpack/attach_ibl_metadata.py for annotated archives). shank is filled with zeros (lfpack is single-shank today).

Raises: KeyError: If the reader exposes no channel geometry at all.

load_geometry

feature_calculators.LFPackFeatureCalculator.load_geometry()

Load ibldsp geometry from the reader, filling derived defaults.

Returns: dict[str, np.ndarray]: x/y from the reader, plus sample_shift/shank/col/row defaults (lfpack archives carry only on-probe x/y, matching SpikeGlxLikeFeatureCalculator.load_geometry’s fallback for a reader without those derived keys).

load_raw_snippet

feature_calculators.LFPackFeatureCalculator.load_raw_snippet(window)

Read one LF snippet from the archive.

Args: window (SnippetWindow): Snippet time window to read (duration_ap is ignored – this source is LF-only).

Returns: RawSnippet: raw_ap=None; raw_lf shaped (channels, samples) in volts.

saturation_times

feature_calculators.LFPackFeatureCalculator.saturation_times()

Return the archive’s saturation intervals on the session clock.

Returns: pd.DataFrame: start_sample/stop_sample/start_time/ stop_time (see lfpack.LFPackReader.saturation_times). Verified scale-independent, so reading it from any tier of a PID covers every tier.