Skip to main content

feature_computation.compute_features_from_file

feature_computation.compute_features_from_file(
    ap_file=None,
    lf_file=None,
    t_start=None,
    duration=None,
    duration_ap=5,
    duration_lf=25,
    traj_dict=None,
    features_to_compute=None,
    output_dir=None,
    scratch_dir=None,
    lf_k_filter=False,
    feature_params=None,
    **kwargs,
)

Compute features from .cbin files.

Features are computed via :class:ephysatlas.feature_calculators.SpikeGLXFileFeatureCalculator, which reads the AP/LF .cbin files through spikeglx.Reader and shares the computation engine (:func:compute_features_from_raw) with :func:compute_features_from_pid.

Args: ap_file (str, optional): Path to an AP .cbin file. Must be supplied if lf_file is None. lf_file (str, optional): Path to an LF .cbin file. Must be supplied if ap_file is None. t_start (float, optional): Start time (seconds) of the snippet. Defaults to 0.0 when omitted. duration (float, optional): Duration in seconds for feature computation. If None, uses the entire available duration. Deprecated: use duration_ap and duration_lf instead. duration_ap (float, optional): Duration in seconds for AP feature computation. If None, uses the entire available AP duration. duration_lf (float, optional): Duration in seconds for LF feature computation. If None, uses the entire available LF duration. traj_dict (dict, optional): Trajectory dictionary with keys x, y, z, depth, theta, phi for adding target coordinate columns. features_to_compute (list, optional): Feature families to compute. None lets the feature calculator pick defaults from the available bands. output_dir (Path, optional): Root directory for cached outputs. A snippet-level directory is created beneath it. scratch_dir (Path, optional): Location for temporary scratch files generated by downstream feature routines. lf_k_filter (bool | None, optional): Spatial-filter mode forwarded to :func:ibldsp.voltage.destripe_lfp. The default False preserves the current CAR-style LF destriping; use None to disable LF spatial filtering. feature_params (FeatureParams | dict, optional): Per-feature parameters forwarded to the engine, as a FeatureParams or a nested dict (e.g. {"csd": {"scale": False}}). None uses the defaults. **kwargs: Additional keyword arguments forwarded to :func:compute_features_from_raw.

Returns: pd.DataFrame: Aggregated feature table for the requested time range.

Raises: ValueError: If neither AP nor LF file is provided.

Note: The on-disk output layout is named after the AP/LF file stem (pid = calculator.name) via :func:ephysatlas.utils.setup_output_directory. This replaces the earlier md5-hash probe directory and probe_unknown_pid_* snippet directory; the returned DataFrame, the channels.pqt contents, and the per-snippet parquet .attrs the aggregation layer reads (filename/t_start/duration_ap/duration_lf) are unchanged.