- 
                Notifications
    You must be signed in to change notification settings 
- Fork 536
Description
Summary
Hi! I am writing a diffusion processing workflow, and wants to use the freesurfer.TKregister2 interface for transforming a freesurfer transformation matrix to a fsl one. I see that the fsl_out option can be set to True according to the documentation ( and from the Tkregister2InputSpec code). However, doing that gives an error.
The causes seem to be these lines in nipype/interfaces/freesurfer/utils.py:
- line 1969-1970 in (TKregister2._format_arg)
if name in ("fsl_out", "lta_out") and value is True:
    value = self._list_outputs()[name]- line 1981-1984 in (TKregister2._list_outputs)
if fsl_out is True:
    outputs["fsl_file"] = fname_presuffix(
        reg_file, suffix=".mat", newpath=cwd, use_ext=False
    )So, with 'fsl_out=True', TKregister2._list_outputs sets up the output field 'fsl_file' and returns a dictionary (I think?) updated with a key called fsl_file. However, the key fsl_out is checked in TKregister2._format_arg which is not set.
Actual behavior
These errors were generated by nipype:
Traceback:
	Traceback (most recent call last):
	  File "/home/jwu/.venvs/mpp-dwi-proc/lib/python3.11/site-packages/nipype/interfaces/base/core.py", line 935, in _parse_inputs
	    arg = self._format_arg(name, spec, value)
	          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/home/jwu/.venvs/mpp-dwi-proc/lib/python3.11/site-packages/nipype/interfaces/freesurfer/utils.py", line 1970, in _format_arg
	    value = self._list_outputs()[name]
	            ~~~~~~~~~~~~~~~~~~~~^^^^^^
	KeyError: 'fsl_out'
	The above exception was the direct cause of the following exception:
	Traceback (most recent call last):
	  File "/home/jwu/.venvs/mpp-dwi-proc/lib/python3.11/site-packages/nipype/interfaces/base/core.py", line 735, in _run_interface
	    runtime.cmdline = self.cmdline
	                      ^^^^^^^^^^^^
	  File "/home/jwu/.venvs/mpp-dwi-proc/lib/python3.11/site-packages/nipype/interfaces/base/core.py", line 660, in cmdline
	    allargs = [self._cmd_prefix + self.cmd] + self._parse_inputs()
	                                              ^^^^^^^^^^^^^^^^^^^^
	  File "/home/jwu/.venvs/mpp-dwi-proc/lib/python3.11/site-packages/nipype/interfaces/base/core.py", line 937, in _parse_inputs
	    raise ValueError(
	ValueError: Error formatting command line argument 'fsl_out' with value 'True'
	The above exception was the direct cause of the following exception:
	Traceback (most recent call last):
	  File "/home/jwu/.venvs/mpp-dwi-proc/lib/python3.11/site-packages/nipype/interfaces/base/core.py", line 397, in run
	    runtime = self._run_interface(runtime)
	              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	  File "/home/jwu/.venvs/mpp-dwi-proc/lib/python3.11/site-packages/nipype/interfaces/base/core.py", line 737, in _run_interface
	    raise RuntimeError(
	RuntimeError: Error raised when interpolating the command lineExpected behavior
This option should set a file value for the output field fsl_file without error
How to replicate the behavior
This should replicate with any moving image and reg file:
tkr2 = freesurfer.Tkregister2(moving_image=moving_image, reg_file=reg_file, fsl_out=True)
tkr2.run()Script/Workflow details
command = 'singularity run -B work/work,features/features mfeatures.simg tkregister2'
tkr_diff2str = pe.Node(
            freesurfer.Tkregister2(command=command, noedit=True, fsl_out=True), name='tkr_diff2str')
diff_proc_wf.connect([ # part of the connections
            (nodif_bias, tkr_diff2str, [('out_file', 'moving_image')]),
            (bbr_epi2t1, tkr_diff2str, [('out_reg_file', 'reg_file')]),
            (split_t1_files, tkr_diff2str, [('t1', 'target_image')]),
            (tkr_diff2str, diff2str, [('fsl_file', 'in_file2')])])Platform details:
{'commit_hash': '<not found>',
 'commit_source': '(none found)',
 'networkx_version': '3.1',
 'nibabel_version': '5.1.0',
 'nipype_version': '1.8.6',
 'numpy_version': '1.24.3',
 'pkg_path': '/home/jwu/.venvs/mpp-dwi-proc/lib/python3.11/site-packages/nipype',
 'scipy_version': '1.10.1',
 'sys_executable': '/home/jwu/.venvs/mpp-dwi-proc/bin/python3',
 'sys_platform': 'linux',
 'sys_version': '3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]',
 'traits_version': '6.3.2'}
Execution environment
- Container (Singularity 3): FreeSurfer 7.3.2
- My python environment outside container