dirconn.write_roi_bids#

dirconn.write_roi_bids(ts: TimeSeries, root: str | PathLike[str], *, subject: str, task: str, description: str, session: str | None = None, run: int | str | None = None, datatype: str = 'eeg', source_space: str | None = None, inverse_method: str | None = None, roi_extraction: str | None = None, source_orientation: str | None = None, leakage_correction: str | None = None, overwrite: bool = False) → Any#

Write region-level time series as a BIDS-Derivatives dataset (dirconn convention v0).

The data are stored as a double-precision FIF file. Epoched data are concatenated along time and described by an events.tsv file plus the Segmentation, NTrials, EpochLength and Tmin entries of the sidecar, so they can be restored exactly. Channel positions are not stored. Invalid samples (ts.valid) are written as NaN; read them back with read_bids(..., nan="mask"). A predict mask is an analysis choice, not part of the recording, and is not written: such series are refused.

Parameters:
  • ts (TimeSeries) – Region-level series; the channel metadata (region, hemisphere, atlas, node kind) is written to channels.tsv.

  • root (path-like) – Root of the derivatives dataset; created if needed.

  • subject (str) – BIDS entities.

  • task (str) – BIDS entities.

  • description (str) – Value of the desc entity, which is mandatory for derivatives (for example "dk").

  • session (optional) – BIDS entities.

  • run (optional) – BIDS entities.

  • datatype ({"eeg", "meg", "ieeg"}) – Directory and suffix to use, normally the modality the regions were reconstructed from.

  • source_space (str) – Processing description recorded in the Dirconn sidecar entry; omitted when None.

  • inverse_method (str) – Processing description recorded in the Dirconn sidecar entry; omitted when None.

  • roi_extraction (str) – Processing description recorded in the Dirconn sidecar entry; omitted when None.

  • source_orientation (str) – Processing description recorded in the Dirconn sidecar entry; omitted when None.

  • leakage_correction (str) – Processing description recorded in the Dirconn sidecar entry; omitted when None.

  • overwrite (bool) – Replace existing files instead of raising FileExistsError.

Returns:

Path of the FIF file.

Return type:

mne_bids.BIDSPath