sccn / EEG-BIDS

21 stars 17 forks source link

reading BIDS with utf-8-sig.tsv #78

Closed behinger closed 4 months ago

behinger commented 3 years ago

When reading a BIDS file with an UTF-8-sig encoded events.tsv file, we get an error because "onset" is not read as "onset" but as " onset" (with the " " actually being 65279 [output of double(inputline(1))]). This crashes pop_importbids in L392 with

events(end).(eventData{1,iField}) = eventData{iEvent,iField};

pop_loadbv(): reading header file
Done.
pop_loadbv(): reading EEG data
pop_loadbv(): scaling EEG data
pop_loadbv(): reading marker file
Done.
Invalid field name: 'onset'.

Error in pop_importbids (line 392)
                                    events(end).(eventData{1,iField}) = eventData{iEvent,iField};

Note how the character 65279 is not displayed here because strg + c/v removed it (we see 'onset' instead of ' onset'). Thus I attach a screenshot

grafik

I tried digging into the loadtxt script of eeglab, it does not seem straight forward to fix it. Thus I propose following fix:

                                    events(end).(genvarname(eventData{1,iField})) = eventData{iEvent,iField};

using genvarname is a bit of a hack though. But it works for me.

Note: UTF-8-sig is the export value of the mne_bids tool.

arnodelorme commented 3 years ago

This is an old report, but we would be grateful if you could share a data file

behinger commented 3 years ago

was on vaccation. I attached an events file - is that enough or should I zip the whole dataset?

tmp.zip

dungscout96 commented 4 months ago

I verified using the provided example events.tsv file that the issue no longer exists