coco_pipe.io.utils

Helper functions for IO operations.

Attributes

Functions

_get_mne()

Lazily import MNE so base IO structures stay lightweight.

_get_bids_path()

Lazily import mne-bids' BIDSPath.

_get_read_raw_bids()

Lazily import the MNE-BIDS raw reader.

row_quality_score(→ pandas.Series)

Calculate a 'badness' score for each row (NaNs + Infs + Zeros).

make_strata(→ pandas.Series)

Create a single stratification label from multiple covariates.

sample_indices(→ pandas.Index)

Sample indices for each class based on size_map.

split_column(→ Tuple[str, str])

Split a column into (unit, feature) using sep and reverse.

read_bids_entry(→ Tuple[numpy.ndarray, numpy.ndarray, ...)

load_participants_tsv(→ Dict[str, Dict[str, Any]])

Reads participants.tsv and returns dict: {sub_id: {col: val, ...}}.

detect_subjects(→ List[str])

detect_sessions(→ List[str])

detect_runs(→ List[str])

Detect available runs for a given subject/session/task.

smart_reader(→ Any)

default_id_extractor(→ str)

Module Contents

coco_pipe.io.utils.logger
coco_pipe.io.utils.mne = None
coco_pipe.io.utils.BIDSPath = None
coco_pipe.io.utils.read_raw_bids = None
coco_pipe.io.utils._get_mne()[source]

Lazily import MNE so base IO structures stay lightweight.

coco_pipe.io.utils._get_bids_path()[source]

Lazily import mne-bids’ BIDSPath.

coco_pipe.io.utils._get_read_raw_bids()[source]

Lazily import the MNE-BIDS raw reader.

coco_pipe.io.utils.row_quality_score(df: pandas.DataFrame, exclude_cols: List[str] | None = None, count_zero: bool = True) pandas.Series[source]

Calculate a ‘badness’ score for each row (NaNs + Infs + Zeros). Lower is better.

coco_pipe.io.utils.make_strata(df: pandas.DataFrame, covariates: List[str], n_bins: int = 5, binning: str = 'quantile') pandas.Series[source]

Create a single stratification label from multiple covariates. Numeric covariates are binned.

coco_pipe.io.utils.sample_indices(df: pandas.DataFrame, target: str, size_map: Dict[Any, int], rng, replace: bool, prefer_clean: bool, exclude: List[str]) pandas.Index[source]

Sample indices for each class based on size_map.

coco_pipe.io.utils.split_column(name: str, sep: str, reverse: bool) Tuple[str, str][source]

Split a column into (unit, feature) using sep and reverse.

coco_pipe.io.utils.read_bids_entry(bids_path: Any, is_pre_epoched: bool, is_evoked: bool, mode: str, window_length: float | None, stride: float | None, event_id: Dict[str, int] | str | List[str] | None = None, tmin: float = -0.2, tmax: float = 0.5, baseline: Tuple[float | None, float | None] | None = None) Tuple[numpy.ndarray, numpy.ndarray, List[str], float, numpy.ndarray | None][source]
coco_pipe.io.utils.load_participants_tsv(root: pathlib.Path) Dict[str, Dict[str, Any]][source]

Reads participants.tsv and returns dict: {sub_id: {col: val, …}}.

coco_pipe.io.utils.detect_subjects(root: pathlib.Path) List[str][source]
coco_pipe.io.utils.detect_sessions(root: pathlib.Path, subject: str) List[str][source]
coco_pipe.io.utils.detect_runs(root: pathlib.Path, subject: str, session: str | None = None, task: str | None = None, datatype: str = 'eeg') List[str][source]

Detect available runs for a given subject/session/task.

coco_pipe.io.utils.smart_reader(path: pathlib.Path) Any[source]
coco_pipe.io.utils.default_id_extractor(path: pathlib.Path) str[source]