I found a minor issue in the Patient/Subject Information raw.info[‘subject_info’] which is potentially new after some recent changes (adding weight and height).
I used some of my old code parts to convert eeg data to bids using mne_bids (which worked perfectly with the previous versions).
As before I added the age of the participants using the birthday key for the subject_info dict before converting/writing the object into bids:
raw.info[‘subject_info’][‘birthday’] = (year, month, day) in integer (int)
Unfortunately, it was not recognized after the conversion (no info (n/a) in the participants.tsv file).
I looked into some documentation on the subject_info and found this interesting format specification in the dictionary documentation - could it be a copy-paste mistake which causes the issue?
subj_birth_day 404 julian - “Birthday of the subject”
Thanks for the first idea.
I tested it with datetime.datetime object but it is still not working properly. It is correctly added in the subject_info dict but gets lost after the conversion to bids (tsv file and raw object after read_raw_bids). Of course, the issue could also be in mne_bids since they also changed some things in the last months…
Of course:
Maybe it is an EEG specific issue? BrainVision format issue? I also get a warning for the Coordinate frame but I considered this independent from the subject_info…
CODE
# Import necessary Packages
import os
import mne_bids
import mne
import pickle
# Project Specifications
task = 'errormonitoring'
datatype = 'eeg'
suffix = 'eeg'
extension = '.vhdr'
data_format= 'BrainVision'
mne_events_id = {'Fixation': 0,
'Good': 100,
'Error': 200,
'Response_Cue': 2,
'Key_Press': 3,
'ITI': 4}
# Data Paths
bids_root = 'raw_data' # Path where to save BIDS files
source_root = 'source_data' # Path where to copy 'example_subj_raw.fif' and 'mne_events.pickle'
# Read Data
raw = mne.io.read_raw(os.path.join(source_root, 'example_subj_raw.fif'))
with open(os.path.join(source_root, 'mne_events.pickle'), 'rb') as file:
# A new file will be created
mne_events = pickle.load(file)
# Add Information for BIDS Conversion
raw.info['line_freq'] = 50
raw.info['subject_info'] = {}
raw.info['subject_info']['first_name'] = 'sub-001'
raw.info['subject_info']['his_id'] = 'sub-001'
raw.info['subject_info']['birthday'] = (1996, 10, 1)
raw.info['subject_info']['sex'] = 1
raw.info['subject_info']['hand'] = 1
montage = mne.channels.make_standard_montage('standard_1020')
print(montage)
raw.set_montage(montage)
# Write Run Task Data to BIDS
bids_path = mne_bids.BIDSPath(subject='001', task='errormonitoring', run = 1,root=bids_root, datatype='eeg', suffix='eeg',
extension='.vhdr')
mne_bids.write_raw_bids(raw = raw, bids_path=bids_path, events=mne_events, event_id=mne_events_id,
allow_preload=True, overwrite=True, format='BrainVision', montage = montage)
# Test Result
raw_bids = mne_bids.read_raw_bids(bids_path, extra_params=None, verbose=None)
print(raw_bids.info['subject_info'])
If it helps, I can also share the raw fif file and mne_events in pickle format…
You should be able to download the files via the owncloud Link: Fraunhofer ownCloud
I didn’t find an option to upload the file types directly in discourse
If there are any problems I can try another way to share them.