huppertt / nirs-toolbox

Toolbox for fNIRS analysis
89 stars 61 forks source link

Module: loadNIRx additional issues when loading data with short channels #49

Open ouhscgl opened 2 months ago

ouhscgl commented 2 months ago

Issue Brief Description Starting from like 82 in the loadNIRx() function reassembles the probe optodes the wrong way around (eg.: detectors and then sources instead of being on parity with the 'without short channel' implementation by having sources then detectors. This leads to issues in the Probe.m script, as the validation tries to load in sources outside the expected index range (eg.: Source-01 located at index 33 instead of index 1).

Reproducing the Issue

  1. Attempt loading in a NIRx file (with short channels) using the nirs.io.loadNIRx() function. Identified on macOS and was able to consistently reproduce but was unable to reproduce on Windows. Fixed issue by re-introducing parity with the non-short channel variant.

Suggested Fix from:

82         probe.optodes=[probe.optodes(lst2(1:info.Detectors-info.ShortDetectors),:); ...
83           DetShort; probe.optodes(lst,:); probe.optodes(lst3,:)];
84        probe.optodes_registered=[probe.optodes_registered(lst2(1:info.Detectors-info.ShortDetectors),:); ...
85           DetShort3D; probe.optodes_registered(lst,:); probe.optodes_registered(lst3,:)];

to:

82        probe.optodes=[probe.optodes(lst,:); probe.optodes(lst2(1:info.Detectors-info.ShortDetectors),:); ...
83           DetShort; probe.optodes(lst3,:)];
84        probe.optodes_registered=[probe.optodes_registered(lst,:); probe.optodes_registered(lst2(1:info.Detectors-...
85           info.ShortDetectors),:); DetShort3D; probe.optodes_registered(lst3,:)];

Fix Brief Description Flips the assignments.