mne_bids.write_raw_bids¶
-
mne_bids.
write_raw_bids
(raw, bids_basename, output_path, events_data=None, event_id=None, overwrite=False, verbose=True)[source]¶ Walk over a folder of files and create BIDS compatible folder.
Warning
The original files are simply copied over. This function cannot convert modify data files from one format to another. Modification of the original data files is not allowed.
- Parameters
- rawinstance of mne.io.Raw
The raw data. It must be an instance of mne.Raw. The data should not be loaded on disk, i.e., raw.preload must be False.
- bids_basenamestr
The base filename of the BIDS compatible files. Typically, this can be generated using make_bids_basename. Example: sub-01_ses-01_task-testing_acq-01_run-01. This will write the following files in the correct subfolder of the output_path:
sub-01_ses-01_task-testing_acq-01_run-01_meg.fif sub-01_ses-01_task-testing_acq-01_run-01_meg.json sub-01_ses-01_task-testing_acq-01_run-01_channels.tsv sub-01_ses-01_task-testing_acq-01_run-01_coordsystem.json
and the following one if events_data is not None:
sub-01_ses-01_task-testing_acq-01_run-01_events.tsv
and add a line to the following files:
participants.tsv scans.tsv
Note that the modality ‘meg’ is automatically inferred from the raw object and extension ‘.fif’ is copied from raw.filenames.
- output_pathstr
The path of the root of the BIDS compatible folder. The session and subject specific folders will be populated automatically by parsing bids_basename.
- events_datastr | array | None
The events file. If a string, a path to the events file. If an array, the MNE events array (shape n_events, 3). If None, events will be inferred from the stim channel using mne.find_events.
- event_iddict | None
The event id dict used to create a ‘trial_type’ column in events.tsv
- overwritebool
Whether to overwrite existing files or data in files. Defaults to False. If overwrite is True, any existing files with the same BIDS parameters will be overwritten with the exception of the participants.tsv and scans.tsv files. For these files, parts of pre-existing data that match the current data will be replaced. If overwrite is False, no existing data will be overwritten or replaced.
- verbosebool
If verbose is True, this will print a snippet of the sidecar files. If False, no content will be printed.
Notes
For the participants.tsv file, the raw.info[‘subjects_info’] should be updated and raw.info[‘meas_date’] should not be None to compute the age of the participant correctly.