nirspipe.io.tables#
One delimiter rule for every table a user hands the package, one format for every table it writes.
Module Contents#
Functions#
Write a table as BIDS reads one: tab-separated, missing values |
|
BIDS sidecar entries, Description and Units, for the given columns that either dict names. |
|
Read a user-supplied table, whatever its extension and delimiter. |
|
A tab-separated table the package wrote, or None when absent or unreadable. |
|
The whole run’s rows, |
|
A null’s draw rows that hold a value; one a rejected channel left blank holds nothing. |
|
A table’s whole-run rows and its condition rows, each None when it has none. |
Data#
API#
- nirspipe.io.tables.logger = 'get_logger(...)'#
- nirspipe.io.tables.NA = 'n/a'#
- nirspipe.io.tables.LABEL_DTYPES = None#
- nirspipe.io.tables.WHOLE_RUN = 'whole_run'#
- nirspipe.io.tables.write_tsv(frame: pandas.DataFrame, path, **kwargs)#
Write a table as BIDS reads one: tab-separated, missing values
n/a, no index unless asked.
- nirspipe.io.tables.column_entries(columns, descriptions: dict, units: dict | None = None) dict#
BIDS sidecar entries, Description and Units, for the given columns that either dict names.
- nirspipe.io.tables.read_table(path: str | pathlib.Path, **kwargs) pandas.DataFrame#
Read a user-supplied table, whatever its extension and delimiter.
Every entry point that accepts a table from the user (events, segments, pairs, participants) goes through here, so a .csv of events works where a .tsv does and nobody has to convert a file to satisfy one call site. Extra keyword arguments reach
pandas.read_csvunchanged.This is for reading only. What the package writes back out stays BIDS-correct: participants.tsv and *_events.tsv are tab-separated regardless of what came in.
- nirspipe.io.tables.read_tsv_or_none(path: pathlib.Path, lost: str) pandas.DataFrame | None#
A tab-separated table the package wrote, or None when absent or unreadable.
lostsays what an unreadable one costs the caller, for the warning.
- nirspipe.io.tables.join_whole_run(whole: list[pd.DataFrame], by_condition: list[pd.DataFrame]) pandas.DataFrame | None#
The whole run’s rows,
conditionwhole_run, and every condition’s as one table.whole [chromophore, label, coherence], by_condition [chromophore, condition, label, ...] -> [chromophore, condition, label, coherence], whole-run rows first
- nirspipe.io.tables.measured_draws(draws: pandas.DataFrame, value: str) pandas.DataFrame#
A null’s draw rows that hold a value; one a rejected channel left blank holds nothing.
- nirspipe.io.tables.split_whole_run(frame: pandas.DataFrame | None) tuple[pd.DataFrame | None, pd.DataFrame | None]#
A table’s whole-run rows and its condition rows, each None when it has none.
condition [whole_run, whole_run, game, rest] -> (2 rows, no condition column), (2 rows) no condition column -> (every row, None)