bids-matlab-tools icon indicating copy to clipboard operation
bids-matlab-tools copied to clipboard

bug in writeeventfile if onset fields are {'onset' 'onset'}

Open ReneSkukies opened this issue 1 month ago • 0 comments

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

ReneSkukies avatar Sep 26 '25 13:09 ReneSkukies