mne_bids.update_sidecar_json#
- mne_bids.update_sidecar_json(bids_path, entries, verbose=None)[source]#
- Update sidecar files using a dictionary or JSON file. - Will update metadata fields inside the path defined by - bids_path.fpathaccording to the- entries. If a field does not exist in the corresponding sidecar file, then that field will be created according to the- entries. If a field does exist in the corresponding sidecar file, then that field will be updated according to the- entries.- For example, if - InstitutionNameis not defined in the sidecar json file, then trying to update- InstitutionNameto- Martinos Centerwill update the sidecar json file to have- InstitutionNameas- Martinos Center.- Parameters:
- bids_pathBIDSPath
- The set of paths to update. The - mne_bids.BIDSPathinstance passed here must have the- .rootattribute set. The- .datatypeattribute may be set. If- .datatypeis not set and only one data type (e.g., only EEG or MEG data) is present in the dataset, it will be selected automatically. This must uniquely identify an existing file path, else an error will be raised.
- entriesdict|str|pathlib.Path
- A dictionary, or JSON file that defines the sidecar fields and corresponding values to be updated to. 
- verbosebool|str|int|None
- Control verbosity of the logging output. If - None, use the default verbosity level. See the logging documentation and- mne.verbose()for details. Should only be passed as a keyword argument.
 
- bids_path
- Raises:
- RuntimeError
- If the specified - bids_path.fpathcannot be found in the dataset.
- RuntimeError
- If the - bids_path.fpathdoes not have- .jsonextension.
 
 - Notes - This function can only update JSON files. - Sidecar JSON files include files such as - *_ieeg.json,- *_coordsystem.json,- *_scans.json, etc.- You should double check that your update dictionary is correct for the corresponding sidecar JSON file because it will perform a dictionary update of the sidecar fields according to the passed in dictionary overwriting any information that was previously there. - Examples - Update a sidecar JSON file - >>> from pathlib import Path >>> root = Path('./mne_bids/tests/data/tiny_bids').absolute() >>> bids_path = BIDSPath(subject='01', task='rest', session='eeg', ... suffix='eeg', extension='.json', datatype='eeg', ... root=root) >>> entries = {'PowerLineFrequency': 60} >>> update_sidecar_json(bids_path, entries, verbose=False) 
