mne-tools / mne-bids

MNE-BIDS is a Python package that allows you to read and write BIDS-compatible datasets with the help of MNE-Python.
https://mne.tools/mne-bids/
BSD 3-Clause "New" or "Revised" License
132 stars 87 forks source link

Validator warning for write_anat with no acquisition #238

Closed alexrockhill closed 5 years ago

alexrockhill commented 5 years ago

I get the following warning from the validator during write_anat without passing an acquisition parameter:

File Path: NIfTI file's header field for unit information for x, y, z, and t dimensions empty or too short

Type:       Warning
File:       sub-sample_ses-01_T1w.nii.gz
Location:       data_BIDS/sub-sample/ses-01/anat/sub-sample_ses-01_T1w.nii.gz
Reason:     NIfTI file's header field for unit information for x, y, z, and t dimensions empty or too short

======================================================

It's not clear if the acquisition parameter would fix this, maybe someone can suggest how to get these parameters from an MGH file.

alexrockhill commented 5 years ago

Also, when I use mri_convert to change the MGH file to NIfTI, the dataset is successfully validated. This makes sense to me and per @jasmainak this would suggest this is an MNE-BIDS issue.

agramfort commented 5 years ago

can you provide some data to replicate the pb?

alexrockhill commented 5 years ago

Sure:

from mne_bids import write_anat from mne import read_trans

subject = 'sample' session = '01' t1f = 'MNE-sample-data/subjects/sample/mri/T1.mgz' raw = 'MNE-sample-data/MEG/sample/sample_audvis-raw.fif' trans = 'MNE-sample-data/MEG/sample/sample_audvis_raw-trans.fif' write_anat('data_BIDS', subject, t1f, session=session, raw=raw, trans=read_trans(transf), overwrite=True)

That worked but raised the validator error for me.

alexrockhill commented 5 years ago

Sorry

from mne_bids import write_anat

from mne.datasets import sample
from mne import read_trans
from mne.io import read_raw_fif

subject = 'sample'
session = '01'

data_path = sample.data_path()
t1f = data_path + '/subjects/sample/mri/T1.mgz'
raw = read_raw_fif(data_path + '/MEG/sample/sample_audvis_raw.fif')
transf = data_path + '/MEG/sample/sample_audvis_raw-trans.fif'
write_anat('data_BIDS', subject, t1f, session=session,
                  raw=raw, trans=read_trans(transf), overwrite=True)
jasmainak commented 5 years ago

I can confirm the problem. I edited your comment @alexrockhill

Here is the validator output

(mne) mainak@mainak-ThinkPad-W540 ~/Desktop $ bids-validator data_BIDS/
    1: [ERR] The compulsory file /dataset_description.json is missing. See Section 03 (Modality agnostic files) of the BIDS specification. (code: 57 - DATASET_DESCRIPTION_JSON_MISSING)

    1: [WARN] Nifti file's header field for unit information for x, y, z, and t dimensions empty or too short (code: 41 - NIFTI_UNIT)
        ./sub-sample/ses-01/anat/sub-sample_ses-01_T1w.nii.gz

    2: [WARN] The recommended file /README is missing. See Section 03 (Modality agnostic files) of the BIDS specification. (code: 101 - README_FILE_MISSING)

        Summary:               Available Tasks:        Available Modalities: 
        2 Files, 4.77MB                                T1w                   
        1 - Subject                                                          
        1 - Session                                                          

If you have any questions please post on https://neurostars.org/tags/bids
agramfort commented 5 years ago

can you have a look @jasmainak ?

jasmainak commented 5 years ago

see https://github.com/jasmainak/mne-bids/pull/new/fix_units_warning

agramfort commented 5 years ago

Great