brainstorm-tools / brainstorm3

Brainstorm software: MEG, EEG, fNIRS, ECoG, sEEG and electrophysiology
http://neuroimage.usc.edu/brainstorm
GNU General Public License v3.0
377 stars 162 forks source link

[bugfix] import snirf with event having only one occurance #694

Closed Edouard2laire closed 3 months ago

Edouard2laire commented 6 months ago

Fix the following bug happening when importing a snirf where one event has only one occurrence:

Maybe its not the best fix.


***************************************************************************
** Error: Line 258: Index in position 2 exceeds array bounds. Index must not exceed 1.
** 
** Call stack:
** >in_data_snirf.m at 258
** >in_fopen.m at 221
** >import_raw.m at 132
** >bst_call.m at 28
** >tree_callbacks.m>@(h,ev)bst_call(@import_raw,[],[],iSubject) at 672
** 
********

Edit: maybe its not the best fix. jnirs.nirs.stim(iEvt).data should be nEvent x 3

rcassani commented 6 months ago

Based on the SNIRF specification, a better approach would be to search first for the optional record /nirs(i)/stim(j)/dataLabels to decide if transpose or not. If this is not available, transpose could be required in this condition:

if size(data, 1) < 3 && diff(size(data) < 0)
  % Transpose

with the hope that if it's 3 by 3, it's correct

rcassani commented 3 months ago

The code in this PR was commit directly in the master brain in 3638bb5

rcassani commented 3 months ago

@Edouard2laire, I added the code directly in the master branch to avoid double commit (code and version update)

Edouard2laire commented 3 months ago

thanks :)