feature_computation.compute_features_from_pid
feature_computation.compute_features_from_pid(
pid=None,
eid=None,
probe_name=None,
t_start=None,
duration=None,
duration_ap=5,
duration_lf=25,
one=None,
features_to_compute=None,
output_dir=None,
recompute_channels=False,
scratch_dir=None,
feature_params=None,
**kwargs,
)Compute electrophysiological features from a probe ID using the ONE database.
This function serves as the main entry point for computing features from a specific probe. It handles the complete pipeline: loading data from ONE, setting up output directories, processing channel information, computing features, and optionally saving results with metadata.
Args: pid (str, optional): Probe ID. Required for standard ONE usage, also required for OneSdsc. eid (str, optional): Session ID. Required when using OneSdsc. probe_name (str, optional): Probe name. Required when using OneSdsc. t_start (float, optional): Start time in seconds for feature computation. Defaults to 0.0 if not specified. duration (float, optional): Duration in seconds for feature computation. If None, uses the entire available duration. one (ONE): ONE client instance. Required for data loading. features_to_compute (list, optional): List of feature sets to compute. If None, uses default feature sets. should be a subset of [‘lf’, ‘ap’, ‘waveforms’, ‘csd’] output_dir (Path, optional): Output directory for saving features and metadata. If None, features are not saved. recompute_channels (bool, optional): Whether to recompute channel information even if channels.pqt file is present. Defaults to False. scratch_dir (Path, optional): Directory for temporary files (e.g., dartsort scratch files). 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 passed to the feature computation pipeline.
Returns: pd.DataFrame: DataFrame containing the computed features for the specified time window.
Raises: ValueError: If ONE client instance is not provided. AssertionError: If required parameters are missing for OneSdsc (eid, probe_name).
Example: >>> from one.api import ONE >>> one = ONE() >>> df = compute_features_from_pid( … pid=‘probe00’, … t_start=100.0, … duration=30.0, … one=one, … output_dir=Path(‘output’) … )
Note: - The function automatically determines the maximum available duration if duration is None. - Cached channel information is used unless recompute_channels is True. - Target coordinates are added to channel information if not already present. - Features are computed via ephysatlas.feature_calculators.IBLPIDFeatureCalculator. - Metadata is added to all output files for provenance tracking. - The function uses file locking to prevent concurrent writes to channel files.