Open cmpetty opened 3 years ago
as a follow-up, if i do the same applytransform step above through a subprocess, it comes out normal as well:
for i in range(3):
at_cmd = ['antsApplyTransforms','-d','3','-e','0','-i','inv_identity_warp%s.nii' % str(i),
'-o','inv_mrtrix_warp%s.nii' % str(i),'-r','mean_b0.nii.gz',
'-t',os.path.join(dvdir,'fmriprep',subj,sess,'anat','%s_%s_from-MNI152NLin2009cAsym_to-T1w_mode-image_xfm.h5' % (subj,sess)),
'-t','ants_2InverseWarp.nii.gz',
'-t','[ants_1Affine.mat,1]',
'-v','1','--default-value','2147483647']
subprocess.call(at_cmd)
Sorry for the slow response. Could you show the result of print(at.cmdline)
for comparison?
for i in range(3):
at = ApplyTransforms()
at.inputs.dimension = 3
at.inputs.args = "-e 0 -v 1"
at.inputs.float = False
at.inputs.input_image = "inv_identity_warp%s.nii" % str(i)
at.inputs.reference_image = "mean_b0.nii.gz"
at.inputs.output_image = "inv_mrtrix_warp%s.nii" % str(i)
at.inputs.transforms = [os.path.join(dvdir,'fmriprep',subj,sess,'anat','%s_%s_from-MNI152NLin2009cAsym_to-T1w_mode-image_xfm.h5' % (subj,sess)),'ants_2InverseWarp.nii.gz','ants_1Affine.mat']
at.inputs.invert_transform_flags = [False,False,True]
at.inputs.default_value = 2147483647
print(at.cmdline)
## res = at.run()
results in:
antsApplyTransforms -e 0 -v 1 --default-value 2.14748e+09 --dimensionality 3 --float 0 --input inv_identity_warp0.nii --interpolation Linear --output inv_mrtrix_warp0.nii --reference-image mean_b0.nii.gz --transform /mnt/munin2/Lee/HCPcovid.01/Analysis/derivatives/fmriprep/sub-0137/ses-02/anat/sub-0137_ses-02_from-MNI152NLin2009cAsym_to-T1w_mode-image_xfm.h5 --transform ants_2InverseWarp.nii.gz --transform [ ants_1Affine.mat, 1 ]
antsApplyTransforms -e 0 -v 1 --default-value 2.14748e+09 --dimensionality 3 --float 0 --input inv_identity_warp1.nii --interpolation Linear --output inv_mrtrix_warp1.nii --reference-image mean_b0.nii.gz --transform /mnt/munin2/Lee/HCPcovid.01/Analysis/derivatives/fmriprep/sub-0137/ses-02/anat/sub-0137_ses-02_from-MNI152NLin2009cAsym_to-T1w_mode-image_xfm.h5 --transform ants_2InverseWarp.nii.gz --transform [ ants_1Affine.mat, 1 ]
antsApplyTransforms -e 0 -v 1 --default-value 2.14748e+09 --dimensionality 3 --float 0 --input inv_identity_warp2.nii --interpolation Linear --output inv_mrtrix_warp2.nii --reference-image mean_b0.nii.gz --transform /mnt/munin2/Lee/HCPcovid.01/Analysis/derivatives/fmriprep/sub-0137/ses-02/anat/sub-0137_ses-02_from-MNI152NLin2009cAsym_to-T1w_mode-image_xfm.h5 --transform ants_2InverseWarp.nii.gz --transform [ ants_1Affine.mat, 1 ]
then put them back together:
#correct them back into 4d warp KEEP
corr_cmd = ['warpcorrect','inv_mrtrix_warp[].nii','inv_mrtrix_warp_corrected.mif','-marker','2147483647','-force']
subprocess.call(corr_cmd)
Summary
I am warping mrtrix3 identity matrices with antsApplyTransforms. The same command on the command line versus through nipype is giving me a slightly different result. nipype interface was used on L image, command line call on the right. The calls were exactly the same as far as i can tell. Results mostly look the same, with the exception of the grey pieces of tracts in the corner. If i display these as points instead of pseudo-tubes they disappear.
Expected behavior
identical results
Script/Workflow details
Command line version, which looks correct:
Python version, using nipype wrapper for ants:
Platform details:
Execution environment
Scientific Linux 7.8 3.10.0-1160.2.2.el7.x86_64
verbose output from one antsApplyTransforms call
command line:
Python: