I am trying to do some registration in python using the nipype package. It worked for basic registration:
from nipype.interfaces import fsl
from nipype.testing import example_data
flt = fsl.FLIRT(bins=640, cost_func='mutualinfo')
flt.inputs.in_file = 'myInput.img'
flt.inputs.reference = 'myReference.img'
flt.inputs.out_file = 'moved_subject.nii'
flt.inputs.out_matrix_file = 'subject_to_template.mat'
res = flt.run()
This yielded a successful registration. However, I am trying to apply this registration transformation to a non-brain image in the same space as the input MRI, using the outputted flt.inputs.out_matrix_file = 'subject_to_template.mat'.
I tried the following:
from nipype.interfaces import fsl
flt = fsl.FLIRT(bins=640, cost_func='mutualinfo')
flt.inputs.in_file = 'myNonBrainImage.img'
flt.inputs.reference = 'myReference.img'
flt.inputs.out_file = 'regNonBrain.nii'
flt.inputs.in_matrix_file = 'subject_to_template.mat'
flt.inputs.apply_xfm = True
res = flt.run()
Hoping that the flt.inputs.in_matrix_file and flt.inputs.apply_xfm = True flag would override standard registration and just use the matrix to register the additional image, but I got this error:
INFO:interface:stderr 2011-08-10T14:59:17.307116:Unrecognised option D
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/bin/python27/lib/python2.7/site-packages/nipype-0.4.1-py2.7.egg/nipype/interfaces/base.py", line 775开发者_如何转开发, in run
runtime = self._run_interface(runtime)
File "/usr/bin/python27/lib/python2.7/site-packages/nipype-0.4.1-py2.7.egg/nipype/interfaces/base.py", line 1050, in _run_interface
self.raise_exception(runtime)
File "/usr/bin/python27/lib/python2.7/site-packages/nipype-0.4.1-py2.7.egg/nipype/interfaces/base.py", line 1027, in raise_exception
raise RuntimeError(message)
RuntimeError: Command:
flirt -in RF8869_3D_XRT_Dose_CT_A.img -ref clo010809T1Gd.img -out regDose.nii -omat /root/Desktop/Test Data/RF8869_3D_XRT_Dose_CT_A_flirt.mat -applyxfm -bins 640 -searchcost mutualinfo -init subject_to_template.mat
Standard output:
Standard error:
Unrecognised option D
Return code: 255
Interface FLIRT failed to run.
Do you know why and how can I solve this?
There is a space in directory/file name containing your images:
/root/Desktop/Test Data
Rename Test Data as Test_Data and it will work
精彩评论