brainstorm3 icon indicating copy to clipboard operation
brainstorm3 copied to clipboard

[bugfix] import snirf with event having only one occurance

Open Edouard2laire opened this issue 11 months ago • 1 comments

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

Edouard2laire avatar Mar 13 '24 21:03 Edouard2laire

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 avatar Mar 14 '24 01:03 rcassani

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

rcassani avatar Jun 20 '24 19:06 rcassani

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

rcassani avatar Jun 20 '24 19:06 rcassani

thanks :)

Edouard2laire avatar Jun 20 '24 19:06 Edouard2laire