bids-matlab-tools
bids-matlab-tools copied to clipboard
bug in writeeventfile if onset fields are {'onset' 'onset'}
Hey,
there seems to be a check missing in the writeeventfile function. Early on, the function checks if an 'onset' field is already present in the data to be used as the 'onset' saved in the tsv file, otherwise it should use 'latency' as basis.
Later on onset is then calculated as
onset = (EEG.event(iEvent).(tmpField)-1)/EEG.srate
This only works if latency is the basis of onset, otherwise onset should be used as is (since it's already in seconds, per eeglab standard iirc)
I can make a PR with my fix (it's just including an additional if statement)
https://github.com/sccn/EEG-BIDS/blob/106788bd05b73943fd1092e7b787e935ebcdc580/bids_writeeventfile.m#L175