coco_pipe.descriptors.extractors._psd¶
Shared PSD computation for PSD-consuming descriptor paths.
This module holds the reusable PSD step used by the descriptors planner and by PSD-consuming extractors when they need a standalone spectral input. It does not define descriptor semantics. It only:
prepare a writable runtime environment for MNE-backed PSD helpers
lazily import the MNE PSD functions used by descriptors
compute Welch or multitaper PSD batches on explicit NumPy inputs
Author: Hamza Abdelhedi (hamza.abdelhedi@umontreal.ca)
Functions¶
Lazily import MNE PSD helpers with writable runtime cache locations. |
|
|
Compute PSD values for one batch of segmented signals. |
Module Contents¶
- coco_pipe.descriptors.extractors._psd.load_mne_psd_functions()[source]¶
Lazily import MNE PSD helpers with writable runtime cache locations.
- Returns:
(psd_array_welch, psd_array_multitaper)imported from mne.time_frequency.- Return type:
tuple
Notes
MNE may write cache or config files during import/use. The descriptors module keeps those paths inside the system temp directory so PSD computation remains sandbox-friendly.
- coco_pipe.descriptors.extractors._psd.compute_psd(X: numpy.ndarray, sfreq: float, method: str, fmin: float, fmax: float, n_jobs: int | None = None) tuple[numpy.ndarray, numpy.ndarray][source]¶
Compute PSD values for one batch of segmented signals.
- Parameters:
X (np.ndarray) – Input array with shape
(n_obs, n_channels, n_times).sfreq (float) – Sampling frequency in Hertz.
method ({"welch", "multitaper"}) – PSD estimator to use.
fmin (float) – Lower frequency bound passed to the PSD backend.
fmax (float) – Upper frequency bound passed to the PSD backend.
n_jobs (int, optional) – Parallel worker count forwarded to the MNE PSD backend when the caller enables PSD-level parallelism. None leaves the backend default in place.
- Returns:
PSD values with shape
(n_obs, n_channels, n_freqs)and the aligned frequency grid with shape(n_freqs,).- Return type:
tuple[np.ndarray, np.ndarray]
Notes
For Welch PSDs, the descriptors module uses:
n_fft = min(n_times, 256)n_per_seg = n_fft
while enforcing a minimum of 8 for both values. This keeps Welch behavior bounded and deterministic across the current descriptor tests and examples.