Skip to content

Commit 4824f6c

Browse files
committed
fix issue with samples being NaNs in some BIDS releases
1 parent bf33a0c commit 4824f6c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

bids_importeventfile.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@
6868
events(end).duration = eventData{iEvent,2}*EEG.srate; % convert to samples
6969
bids.eventInfo = {'onset' 'latency'; 'duration' 'duration'}; % order in events.tsv: onset duration
7070
if ~isempty(indSample)
71-
events(end).sample = eventData{iEvent,indSample} + 1;
72-
events(end).latency = eventData{iEvent,indSample} + 1;
73-
bids.eventInfo(end+1,:) = {'sample' 'sample'};
71+
if ~isnan(eventData{iEvent,indSample})
72+
events(end).sample = eventData{iEvent,indSample} + 1;
73+
events(end).latency = eventData{iEvent,indSample} + 1;
74+
if isempty(bids.eventInfo) || ~strcmpi(bids.eventInfo{end,1}, 'sample')
75+
bids.eventInfo(end+1,:) = {'sample' 'sample'};
76+
end
77+
end
7478
end
7579
for iField = 1:length(eventData(1,:))
7680
if ~any(strcmpi(eventData{1,iField}, {'onset', 'duration', 'sample', g.eventtype}))

0 commit comments

Comments
 (0)