fNIRS / snirf

SNIRF Format Specification
http://fnirs.org/resources/software/snirf/
Other
57 stars 33 forks source link

Conversion (Homer3) .nirs to .snirf validation #134

Closed EwanMahe closed 1 year ago

EwanMahe commented 1 year ago

Hello everyone,

I have a question concerning the validation of the format of a .snirf file on Python. I convert a .nirs file to a .snirf file via Homer3 (v.1.80.2). When I use the validateSnirf() function from the snirf package, then result.display() to check the validity of this converted .snirf file, I get 120 WARNING and 2 or 3 FATAL (for aux1/dataTimeSeries and stim3/data for example) depending on the file selected. It told me that there is an invalid_dataset_shape. I don't understand because the file is supposed to be converted by Homer3, so I thought it would be valid, without errors. Does anyone know where this problem comes from, is it a problem with Homer3 (the file converted by Homer3 would not respect the specifications of the official .snirf format) or with the validateSnirf function of the Python package snirf ? This may also be a mistake on my part, as I am not an expert in this area. Sorry if the problem is obvious, or if it has already been solved previously.

Thanks in advance for your time and your help.

Ewan Mahé

samuelpowell commented 1 year ago

The pynsirf2 validator uses the official specification to validate the files. If this indicates fatal errors, it is likely that the software which wrote them needs to be fixed. I would suggest that you contact the Homer3 team in the first instance, and if they are able to prove that their implementation is compliant we can look at this further.

sstucker commented 1 year ago

If you post the explicit output, I can offer a bit more insight, but I agree that this should be raised as a Homer3 issue.

edit: please also note that resaving the data with pysnirf may correct the formatting issues.

EwanMahe commented 1 year ago

Thanks you for your answers. I will try to be clearer on the issues and the outcomes I get. I use the file named Test.nirs, I convert it in Homer3 and I get a second file which is called Test.snirf. When I put Test.snirf in the function validateSnirf(), I attribute it at a variable called result, and I check the error with "result.display()". The outcome I get (after multiples lines about WARNING, which are not the most important part I guess) is :

" /nirs/stim3/data FATAL INVALID_DATASET_SHAPE
/nirs/aux1/dataTimeSeries FATAL INVALID_DATASET_SHAPE

Found 390 OK (hidden) Found 371 INFO (hidden) Found 120 WARNING Found 2 FATAL

File is INVALID "

I send you the two files and the code I used to validate so you can check it. Thanks again for your precious help.

Forum_snirf.zip

kdarti commented 1 year ago

Hi @EwanMahe , I've worked a little bit with snirf and the validator so I've run into similar issues. I think in this case the problem is that the snirf specs (and hence validator) says it needs to be in the format of a 2D array:

image

The snirf files you have attached has data as vector, so only 1D.

image

E.g. the data format below passes validation without any errors.

image

Same issue with /nirs/stim3/data

For warnings and things, a few of those might be cases where the validator has more stringent criteria than the snirf spec. I can't remember exactly which cases, but I ran into at least one such case when validating snirf files.

samuelpowell commented 1 year ago

Thanks @kdarti, your results show that the output from Homer3 is not compliant with the specification. @EwanMahe can you raise this with the Homer3 authors? If you have any further problems feel free to reopen the issue.

EwanMahe commented 1 year ago

Thanks @kdarti for your help, and thanks you all for your contribution. I will try to contact the Homer3 authors to talk to them about it. Do you know how/where to contact them?