pBFSLab / DeepPrep

DeepPrep: An accelerated, scalable, and robust pipeline for neuroimaging preprocessing empowered by deep learning
https://deepprep.readthedocs.io
Apache License 2.0
18 stars 6 forks source link

The usage of xfm files #112

Closed xingyu-liu closed 2 months ago

xingyu-liu commented 3 months ago

Hi, I have a couple of questions regarding the usage of xfm filed provided in anat dir.

  1. Could you elaborate me on how to apply the transformation from a image in T1w space to MNI sapce using the 'sub-01_from-T1w_to_MNI152NLin2009cAsym_desc-nonlinear_xfm.npz'? I've tried antsApplyTransforms, it couldn't recognize the .npz file type.

  2. I'm also not sure how to use the 'sub-01_from-T1w_to-MNI152NLin2009cAsym_desc-affine_xfm.txt' correctly. when I tried 'flirt -in t1w_data -ref MNI_data -applyxfm -init sub-01_from-T1w_to-MNI152NLin2009cAsym_desc-affine_xfm.txt, the output image was in a weird space other than the MNI space.

  3. A minor typo: a '_' was in the nonlinear_xfm.npz file name where it should be '-'. e.g.,

sub-01_from-T1wto****MNI152NLin2009cAsym_desc-nonlinear_xfm.npz

Thank you so much!

xingyu-liu commented 3 months ago

I also have tried to extract the 4D mat in .npz and save it as nii.gz, the data format was then recognizable, but no effect of applying it by antsApplyTransforms.

Ireneyou33 commented 2 months ago

Hi @xingyu-liu, we are working on this and will keep you in the loop.

lincong8722 commented 2 months ago

@xingyu-liu Hi, We have changed the step of applying the transformation matrix into a separate executable script. The specific steps are:

  1. Pull the 112-the-usage-of-xfm-files branch

  2. Rebuild an image with an empty entrypoint,the Dockerfile can be referenced as follows: FROM pbfslab/deepprep:23.1.0 ENTRYPOINT []

  3. To mount the code of the new branch in the docker container, you can refer to: docker run -it --rm --gpus all -v /workspace/DeepPrep/deepprep:/opt/DeepPrep/deepprep -v /license/license.txt:/opt/freesurfer/license.txt new_image /bin/bash

  4. If you want to apply a transformation matrix on T1w you can do the following: export FREESURFER_HOME=/opt/freesurfer && python3 /opt/DeepPrep/deepprep/nextflow/bin/apply_trans_matrix_from_t1_to_MNI.py --t1_native2mm /DeepPrep_workdir/BOLD/sub-01/anat/sub-01_space-T1w_res-2mm_desc-skull_T1w.nii.gz --trans_vox /DeepPrep_workdir/BOLD/sub-01/anat/sub-01_from-T1w_to_MNI152NLin6Asym_desc-nonlinear_xfm.npz --template_space MNI152NLin6Asym --template_resolution 02 --synth_script /opt/DeepPrep/deepprep/SynthMorph/mri_bold_apply_synthmorph.py --anat_file /DeepPrep_workdir/BOLD/sub-01/anat/sub-01_space-T1w_res-2mm_desc-skull_T1w.nii.gz --anat_output /DeepPrep_workdir/BOLD/sub-01/anat/sub-01_space-MNI152NLin6Asym_res-02_desc-skull_T1w.nii.gz

  5. If you want to apply a transformation matrix on bold you can do the following: export FREESURFER_HOME=/opt/freesurfer && python3 /opt/DeepPrep/deepprep/nextflow/bin/apply_trans_matrix_from_t1_to_MNI.py --bold_file /DeepPrep_workdir/BOLD/sub-01/ses-01/func/sub-01_ses-01_task-rest_run-01_space-T1w_desc-preproc_bold.nii.gz --fframe_bold_output /DeepPrep_workdir/BOLD/sub-01/ses-01/func/sub-01_ses-01_task-rest_run-01_space-MNI152NLin6Asym_res-02_boldref.nii.gz --orig_bold /DeepPrep_workdir/BIDS/sub-01/ses-01/func/sub-01_ses-01_task-rest_run-01_bold.nii.gz --t1_native2mm /DeepPrep_workdir/BOLD/sub-01/anat/sub-01_space-T1w_res-2mm_desc-skull_T1w.nii.gz --trans_vox /DeepPrep_workdir/BOLD/sub-01/anat/sub-01_from-T1w_to_MNI152NLin6Asym_desc-nonlinear_xfm.npz --template_space MNI152NLin6Asym --template_resolution 02 --work_dir /DeepPrep_workdir/tmp --synth_script /opt/DeepPrep/deepprep/SynthMorph/mri_bold_apply_synthmorph.py --bold_output /DeepPrep_workdir/BOLD/sub-01/ses-01/func/sub-01_ses-01_task-rest_run-01_space-MNI152NLin6Asym_res-02_desc-preproc_bold.nii.gz

Hope it can help you!