Skip to content

FSL FLIRT '-omat' affine matrix output not in decimal format #2813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zmorrissey opened this issue Dec 5, 2018 · 4 comments
Open

FSL FLIRT '-omat' affine matrix output not in decimal format #2813

zmorrissey opened this issue Dec 5, 2018 · 4 comments

Comments

@zmorrissey
Copy link

Summary

Hello, I am using the nipype.interfaces.fsl.FLIRT() command to register a T2 atlas nifti image to a T2 subject nifti image, and I need the affine matrix output of this transformation for the following step to transform the atlas labels into the subject space.

After running the FSL interface's FLIRT command using the out_matrix_file input, it appears to run successfully without any errors, but the resulting .mat file appears to be in a hex type of format instead of decimal format, and there don't appear to be any options listed in the documentation to specify the format for this output file. However, if I run the same command directly in bash, the affine matrix appears (normal) in decimal format.

I'm not sure if this due to nipype or if there is a way to check which version of FSL nipype is calling? I had a similar issue using bash with an earlier version of FSL that was fixed after upgrading to FSL 6.0.

Any help would be appreciated. Thank you!

Actual behavior

The result of nipype's FLIRT out_matrix_file option is a .mat file that is not in recognizable decimal format:

0x1.f3704b5f9a7a8p-1  -0x1.7233534569a2ap-5  0x1.b8452355d1391p-9  0x1.46384be3f5eacp+2  
0x1.71392a592f9f9p-5  0x1.f4bb310ffd381p-1  0x1.609369afdb69fp-11  -0x1.3f0114ec4ce68p+0  
-0x1.d43cafec304ap-9  -0x1.78c17ac5694fep-11  0x1.f64664aad24ecp-1  -0x1.0b85d4efb3e03p+2  
0x0p+0  0x0p+0  0x0p+0  0x1p+0 

Expected behavior

When I run the same command in bash using flirt, I get this matrix:

0.9754661135  -0.04519048942  0.003358994068  5.097186062  
0.04507120391  0.977990659  0.00067248503  -1.246110256  
-0.00357236526  -0.0007186046211  0.9810058077  -4.180043444  
0  0  0  1  

Script/Workflow details

In Python:

from nipype.interfaces.fsl import FLIRT

flt = FLIRT()
flt.inputs.in_file = 't2_atlas.nii.gz'
flt.inputs.reference = 'subject01_t2.nii.gz'
flt.inputs.out_file = 'atlas_in_t2_space.nii.gz'
flt.inputs.output_type = 'NIFTI_GZ'
flt.inputs.out_matrix_file = 'TM_atlas_to_t2.mat'
flt.run()

If I take the flt.cmdline output and run it directly in bash, it works properly:

flirt -in t2_atlas.nii.gz -ref subject01_t2.nii.gz -out atlas_in_t2_space.nii.gz -omat TM_atlas_to_t2.mat

Platform details:

{'commit_hash': 'b448b6061',
 'commit_source': 'installation',
 'networkx_version': '2.1',
 'nibabel_version': '2.3.1',
 'nipype_version': '1.1.6',
 'numpy_version': '1.14.2',
 'pkg_path': '/usr/local/lib/python3.5/dist-packages/nipype',
 'scipy_version': '1.0.0',
 'sys_executable': '/usr/bin/python3',
 'sys_platform': 'linux',
 'sys_version': '3.5.2 (default, Nov 23 2017, 16:37:01) \n[GCC 5.4.0 20160609]',
 'traits_version': '4.6.0'}

Execution environment

Ubuntu 16.04 xenial
Python 3.5.2
ipython v6.4.0
nipype v1.5.6
fsl v6.0.0

@satra
Copy link
Member

satra commented Dec 6, 2018

this is really weird because nipype doesn't write the file, fsl does. are you running the nipype command and the bash version in the same terminal (just to rule out environment issues).

@zmorrissey
Copy link
Author

@satra,

Thanks for the reply. I tried your suggestion, and started a new ipython session directly in the terminal and ran the same nipype commands. Looks like it is working normally this way, I was able to get a decimal format .mat file like I did when running regular fsl.

I have been running my nipype code in an ipython session in Emacs v25.3.2; since it is working properly via the terminal perhaps this an environment issue?

@satra
Copy link
Member

satra commented Dec 6, 2018

@zmorrissey - seems like it. you may want to compare the environment variables inside emacs ipython and on the terminal. it may have something with language and encoding settings.

@zmorrissey
Copy link
Author

@satra - I see, I will look into this to see if I can hunt down which environment variables are causing the issue in case others have similar problems. I appreciate your help and prompt reply!

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants