nirspipe.io.bids#
BIDS dataset querying and participants.tsv helpers.
Module Contents#
Functions#
Return a pybids BIDSLayout for the dataset, safe to query from parallel subjects. |
|
Check the input dataset with the BIDS validator, exiting non-zero on any error. |
|
Convert one raw snirf file into a BIDS nirs entry. |
|
A participant’s age in years from participants.tsv, converted by participants.json’s Units. |
|
Return paths to all snirf files for a given subject/session/task. |
|
A |
|
The channels a recording’s |
|
Build a BIDS filename stem (sub-.._ses-.._task-.._acq-.._run-..) from parsed entities. |
Data#
API#
- nirspipe.io.bids.logger = 'get_logger(...)'#
- nirspipe.io.bids.get_layout(bids_dir: pathlib.Path, validate: bool = True) bids.BIDSLayout#
Return a pybids BIDSLayout for the dataset, safe to query from parallel subjects.
- nirspipe.io.bids.validate_bids(bids_dir: pathlib.Path) None#
Check the input dataset with the BIDS validator, exiting non-zero on any error.
Carries on with a warning when no validator is installed, so a machine without one can still run;
--skip-bids-validationis how a user proceeds past a failing dataset.
- nirspipe.io.bids.write_bids_from_snirf(input_file: pathlib.Path, bids_dir: pathlib.Path, subject: str, task: str, session: str | None = None, run: str | None = None, overwrite: bool = False, optode_frame: str = 'unknown') None#
Convert one raw snirf file into a BIDS nirs entry.
optode_frame names the space the SNIRF’s optode coordinates live in. SNIRF does not record it, so MNE reads them as “unknown” and mne-bids then writes no _optodes.tsv or _coordsystem.json, both of which BIDS requires: it will not guess a frame on the author’s behalf. Pass “head” when the positions were digitised against the nasion and the two preauricular points, “mri” when they already sit on a template brain: MNE reads “mri” as fsaverage, not as the subject’s own scan.
- nirspipe.io.bids.get_participant_age(bids_root: pathlib.Path, subject: str, fix: str = 'pass --dpf as numbers') float#
A participant’s age in years from participants.tsv, converted by participants.json’s Units.
Raises ValueError when the row, the column or a number is missing, or the unit is not one of years, months, weeks or days.
- nirspipe.io.bids.get_nirs_files(layout: bids.BIDSLayout, subject: str, session: str | None = None, task: str | None = None, filter_file: pathlib.Path | None = None) list[pathlib.Path]#
Return paths to all snirf files for a given subject/session/task.
task: if None, all tasks are returned. filter_file: optional JSON with extra pybids query kwargs, e.g. {“run”: “01”}.
- nirspipe.io.bids.read_bids_filter(path: pathlib.Path) dict#
A
--bids-filter-file: the pybids query keywords it adds,{"run": 1}.
- nirspipe.io.bids.channel_status_bads(layout: bids.BIDSLayout, nirs_path: pathlib.Path) list[str]#
The channels a recording’s
channels.tsvmarksbadin its status column."S1_D2 760" bad, "S2_D1 760" good, "S2_D2 850" BAD -> ["S1_D2 760", "S2_D2 850"]
The nearest
channels.tsv, inheritance included; none, or one without a status column, gives none. Case is ignored, as mne-bids ignores it.