Hello everyone
I am trying to convert re_eeg to BIDS format.
I have an error as ValueError: Subfield equipment_code contains spaces: ‘Geodesic Sensor Net 64 2.0’
although I tried to remove the spaces in my code.
I appreciate it if you have an idea to help.
base_path = "E:\\RestEEGcomparison"
bids_root = "E:\\BIDS formatted EEG data"
sessions = ['pre', 'post']
sub_folders = os.listdir(base_path)
for sub_f in sub_folders:
sub_id = sub_f
for session in sessions:
eeg_file = os.path.join(base_path, sub_f, f"{sub_id}{session}.mff")
if os.path.exists(eeg_file):
raw = mne.io.read_raw_egi(eeg_file, preload=True)
# removing the spaces from the equipment code
if 'device_info' in raw.info and 'type' in raw.info['device_info']:
raw.info['device_info']['equipment_code'] = raw.info['device_info']['type'].replace(' ', '')
print(f"Modified equipment code for {eeg_file}: {raw.info['device_info']['equipment_code']}")
# Extract events from the raw data using 'DIN1' as the stimulus channel
events = mne.find_events(raw, stim_channel='DIN1', output='onset')
bids_path = BIDSPath(subject=sub_id, session=session,
task='rest', acquisition='standard', datatype='eeg', suffix='eeg', root=bids_root)
write_raw_bids(raw, bids_path, events=events, event_id=raw.event_id, format='EDF', allow_preload=True, overwrite=True)
print(f"Successfully converted and handled events for {eeg_file}")
print("Conversion to BIDS format completed.")