nipy / nitransforms

a standalone fork of nipy/nibabel#656
https://nitransforms.readthedocs.io
MIT License
28 stars 16 forks source link

Problem applying h5-files from fmriprep outputs for reproduction of normalization #137

Open m-petersen opened 2 years ago

m-petersen commented 2 years ago

Dear Developers,

currently I am aiming to reproduce the normalization steps in fmriprep (e.g. _desc-preproc_T1w.nii.gz -> 1_space-MNI152NLin6Asym_desc-preproc_T1w.nii.gz) with nitransforms. The bigger goal is to check bit-identity between fmriprep outputs and manually produced normalization outputs allowing us to easily reproduce just the normalization with datalad (rerun) and hence throw away the normalized images alleviating our storage issues. Not being able to identify the exact code related to the normalization in the fmriprep and smriprep code base I was trying to achieve a normalization with the .h5-file produced by fmriprep (_from-T1w_to-MNI152NLin6Asym_mode-image_xfm.h5).

If I understand the documentation correctly loading the h5-file with nt.manip.load and applying / mapping it subsequently should do the job.

My code:

T1w = nib.load("sub-000480a3_ses-1_desc-preproc_T1w.nii.gz")
T1w_MNI_ref = nib.load("sub-000480a3_ses-1_space-MNI152NLin6Asym_desc-preproc_T1w.nii.gz")
xfm = nt.manip.load("sub-000480a3_ses-1_from-T1w_to-MNI152NLin6Asym_mode-image_xfm.h5", reference=T1w_MNI_ref, moving=T1w)
T1w_MNI = xfm.apply(T1w)

However, when visualising the resulting T1w_MNI with T1w_MNI.orthoview() the image is empty / black.

I was also messing around with other approaches with no avail.

Is there a suggested way to apply the transforms? I would also greatly appreciate recommendations regarding the exact reproduction of fmriprep normalizations.

Thanks a lot in advance.

Cheers, Marvin

m-petersen commented 2 years ago

Version is 21.0.0

oesteban commented 2 years ago

Hi @m-petersen, have you tried the corresponding conversion with antsApplyTransforms?

m-petersen commented 2 years ago

Hi Oscar,

thanks for your reply.

Yes, a conversion using antsApplyTransforms as described here (https://neurostars.org/t/problem-applying-h5-files-from-fmriprep-outputs-for-reproduction-of-normalization/20959) works fine and that's what we are using now.

oesteban commented 2 years ago

Thanks much. Would you be able to share some data so that we can replicate the issue?

m-petersen commented 2 years ago

I have sent you an email with a link to a shared drive with the according files to phd(at)oscaresteban(dot)es.

arovai commented 5 months ago

Hello! I am running nitransforms 23.0.1 and I get the same issue as OP... are there some ideas around as of why this happen and how we can solve it? Thanks!