nitransforms icon indicating copy to clipboard operation
nitransforms copied to clipboard

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

Open m-petersen opened this issue 3 years ago • 6 comments

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 avatar Dec 07 '21 16:12 m-petersen

Version is 21.0.0

m-petersen avatar Dec 08 '21 09:12 m-petersen

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

oesteban avatar Feb 16 '22 16:02 oesteban

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.

m-petersen avatar Feb 21 '22 15:02 m-petersen

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

oesteban avatar Feb 21 '22 16:02 oesteban

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

m-petersen avatar Mar 01 '22 09:03 m-petersen

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!

arovai avatar Apr 08 '24 13:04 arovai