OHBA-analysis / osl

OHBA Software Library - MEG/EEG Analysis Tools
https://osl.readthedocs.io/en/latest/
Other
39 stars 8 forks source link

Surface extraction fails if sMRI sform code is incorrect #233

Closed matsvanes closed 8 months ago

matsvanes commented 11 months ago

In some datasets extracting surfaces fails because we check for the sform code here. But what is the significance of this code, and is it necessary?

I believe @cgohil8 mentioned the sform code is not important for MEG purposes, so I've manually changed the sform in order to compute the surfaces, but is this valid? And if so, can't we do this automatically so we don't get these errors anymore?

See the error message below

Processing failed during stage : "custom_coregister"<class 'ValueError'>
sform code for /ohba/pi/mwoolrich/mvanes/Projects/NTAD/source/P1023_resting_close_af/rhino/surfaces/smri.nii.gz is 2, and needs to be 4 or 1
  File "/ohba/pi/mwoolrich/mvanes/software/osl/osl/source_recon/batch.py", line 183, in run_src_chain
    func(src_dir, subject, preproc_file, smri_file, epoch_file, **userargs)
  File "coregister.py", line 222, in custom_coregister
    source_recon.wrappers.compute_surfaces(
  File "/ohba/pi/mwoolrich/mvanes/software/osl/osl/source_recon/wrappers.py", line 110, in compute_surfaces
    already_computed = rhino.compute_surfaces(
  File "/ohba/pi/mwoolrich/mvanes/software/osl/osl/source_recon/rhino/surfaces.py", line 211, in compute_surfaces
    flirt_mri2mniaxes_xform = rhino_utils._get_flirt_xform_between_axes(filenames["smri_file"], filenames["std_brain"])
  File "/ohba/pi/mwoolrich/mvanes/software/osl/osl/source_recon/rhino/utils.py", line 834, in _get_flirt_xform_between_axes
    fromvox2from = _get_sform(from_nii)["trans"]
  File "/ohba/pi/mwoolrich/mvanes/software/osl/osl/source_recon/rhino/utils.py", line 275, in _get_sform
    raise ValueError("sform code for {} is {}, and needs to be 4 or 1".format(nii_file, sformcode))
matsvanes commented 9 months ago

I see this is also done in utils/opm.py: https://github.com/OHBA-analysis/osl/blob/main/osl/utils/opm.py#L52C23-L52C34 . Is this something that we can generally do @woolrich ?

matsvanes commented 9 months ago

@cgohil8 add link to examples