fNIRS / snirf-samples

Sample SNIRF datasets
Other
5 stars 1 forks source link

All sample files have /nirs/aux/time and /nirs/data/time stored as 2D array #12

Closed kdarti closed 4 months ago

kdarti commented 5 months ago

All sample files have /nirs/aux/time and /nirs/data/time stored as 2D array, but according to snirf spec it should be 1D array. Not a big thing, but e.g. mne-nirs aux reading function fails due to this since it expects a 1D array.

fangq commented 5 months ago

This is an issue that I am aware of, but still haven't got a good fix.

the issue comes from the fact that the minimum matlab data array dimensions is 2, so there is no way one can tell if an Nx1 array is supposed to be 1D vector of length N, or a 2D array; similarly, it is also difficult to tell easyh5 saveh5 function that an N x 1 x 1 array is 3 or higher dimensional because matlab ndims() function will always return 2.

kdarti commented 5 months ago

Ok, so if I understand you correctly, the issue isn't with actually writing a 1d array, but rather knowing when to write it as 1d array?

fangq commented 5 months ago

that's correct.

the source of this issue came from the design that my savesnirf.m function was built on top of a general-purpose HDF5 writer, saveh5.m. The SNIRF-specific settings must be somehow passed onto saveh5 to be reinforced - this is possible for data types, but for dimensions, I haven't found a way to let savesnirf.m to "inform" saveh5 such requirements.

one idea is to allow saveh5 to have a "schema" input so that such requirements can be propagated into, but I was hoping to find a less invasive solution.