Closed fangq closed 2 years ago
Hi, glad to see you using this
The array not having 'decode' means this was supposed to be a char array but was something else, so this is an issue of format on the end of the Snirf file perhaps. Nothing in pysnirf will work with this file until I add logic which loads this particular string without complaining.
What program generated this file? And how is the string formatted (in terms of HDF5)
I am happy to do the sleuthing and push a quick fix if you send the offending file along
@sstucker, thanks for the quick response - the file was created in matlab, using my toolbox EasyH5 (saveh5
function) via the savesnirf
wrapper called in this line -
https://github.com/fNIRS/snirf-samples/blob/master/basic/updatesnirffromsrc.m#L21
as you can see, I use JSON/JSNIRF as the "source code" to create the matlab struct, and then save the struct to an HDF5 file. my matlab data type to H5 dataset type mapping table is here
https://github.com/fangq/easyh5/blob/master/saveh5.m#L374-L387
To be clear this is a fixed length HDF5 string as opposed to a variable one?
I can't see how this code would create strings differently than the old Homer fixed length strings, which load fine.
I believe it was loaded ok, but for some reason, the variable holding the string, dataset[0]
, was converted to a numpy.ndarray in pysnirf2, thus, it can no longer call decode() (which only works for a string)
I tried to use pysnirf2 validator to test one of the samples files I previously generated
https://github.com/fNIRS/snirf-samples/blob/master/basic/neuro_run01.snirf
but it gives me the following error
I could open it and read the field using
h5py
any quick fixes?