ANTs registration (rigid) - *InverseWarp.nii.gz not found

315 views
Skip to first unread message

Cris Lanting

unread,
Jul 24, 2014, 4:26:42 PM7/24/14
to nipy...@googlegroups.com
Hi All,

In a NiPy-pipeline I've included two separate (ANTs-based) registration steps:
1. A rigid-body (6 DoF as far as I can see) registration (reg.inputs.transforms = ['Rigid']) to go get from functional data (EPI)-space to the individual T1-space
2. A non-linear step from the individual T1 to a template (reg.inputs.transforms = ['Rigid', 'Affine', 'SyN'])

With step 1 I've ran into a problem previously found and described elsewhere (https://github.com/binarybottle/mindboggle/issues/15#issuecomment-18250434):
FileNotFoundError: File/Directory '['/data/local_dir/tamac/Connectivity/tmpdir_FS2_smooth/resting/restpreproc/registration/_subject_id_n3875/CoregAnts/func2highres_0GenericAffine.mat', '/data/local_dir/tamac/Connectivity/tmpdir_FS2_smooth/resting/restpreproc/registration/_subject_id_n3875/CoregAnts/func2highres_1InverseWarp.nii.gz']' not found for Registration output 'reverse_transforms'.

Especially the *_1InverseWarp.nii.gz seems to be missing. This was acknowledged a bug (may 2013; see the link mentioned) but was wondering whether there is a work-around by now. I'm using Nipype v. 0.9.1 and Ants 1.9.x SVN 1789. What I don't understand is that it seems to work when I isolate the registration to the following  (now on OSX instead of linux but surely this is not the issue):

import os
from nipype.interfaces.ants import Registration
import nibabel as nb
from nipy.labs import viz

datadir = '/Users/cplanting/Projects/RestingState/n3806'

input_images=[
os.path.join(datadir,'FFE_brain.nii.gz'),
os.path.join(datadir,'mean_brain.nii.gz'),
]

reg = Registration()
reg.inputs.fixed_image =  input_images[0]
reg.inputs.moving_image = input_images[1]
reg.inputs.num_threads = 2
reg.inputs.output_transform_prefix = 'output_'
reg.inputs.output_warped_image = 'output_warped_image.nii.gz'
reg.inputs.transforms = ['Rigid']
reg.inputs.transform_parameters = [(0.1,)]
reg.inputs.number_of_iterations = [[1000,500,250,100]]
reg.inputs.dimension = 3
reg.inputs.write_composite_transform = True
reg.inputs.collapse_output_transforms = False
reg.inputs.metric = ['MI']
reg.inputs.metric_weight = [1] # Default (value ignored currently by ANTs)
reg.inputs.radius_or_number_of_bins = [32]
reg.inputs.sampling_strategy = ['Regular'] 
reg.inputs.sampling_percentage = [0.25] 
reg.inputs.convergence_threshold = [1.e-8]
reg.inputs.convergence_window_size = [10] 
reg.inputs.smoothing_sigmas = [[3,2,1,0]]
reg.inputs.sigma_units = ['mm']*2
reg.inputs.shrink_factors = [[8,4,2,1]]
reg.inputs.use_estimate_learning_rate_once = [True]
reg.inputs.use_histogram_matching = [False]  # This is the default
reg.inputs.output_warped_image = True
reg.inputs.winsorize_lower_quantile = 0.01
reg.inputs.winsorize_upper_quantile = 0.99
reg.inputs.write_composite_transform = True
reg.run()

normed_img_fname = '/Users/cplanting/output__Warped.nii.gz'
normed_img = nb.load(normed_img_fname)
fixed_img_fname = input_images[0]
fixed_img = nb.load(fixed_img_fname)
slicer = viz.plot_anat(normed_img.get_data(), normed_img.get_affine(), dim=.2, black_bg=True)
slicer.edge_map(fixed_img.get_data(), fixed_img.get_affine())

Any ideas?

Satrajit Ghosh

unread,
Jul 24, 2014, 9:03:05 PM7/24/14
to nipy-user
hi chris,

this is puzzling. are your nipype and ants versions the same on both OSX and the other machine?

cheers,

satra


--

---
You received this message because you are subscribed to the Google Groups "NiPy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nipy-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cris Lanting

unread,
Jul 25, 2014, 5:23:34 AM7/25/14
to nipy...@googlegroups.com
Hi Satra,

With a bit of debugging I've found the culprit:

with:
reg.inputs.collapse_output_transforms = True

it generates the following output:
output_0GenericAffine.mat
output_Composite.h5
output_InverseComposite.h5
output__Warped.nii.gz

it the results in the reported error.

with:
reg.inputs.collapse_output_transforms = False
output_0Rigid.mat
output_Composite.h5
output_InverseComposite.h5
output__Warped.nii.gz

When you think of it a bit more it makes sense (sort of): since I ask for a rigid transform only, there is one output transform. Perhaps it needs two or more to be able to 'collapse' the ouput transforms?! I also noticed that with collapse_output_transforms = true it generates a 0GenericAffine.mat file wheres if it's false it results in a 0Rigid.mat output.

Cheers,
Cris

Satrajit Ghosh

unread,
Jul 25, 2014, 9:59:19 AM7/25/14
to nipy-user
hi chris,

that makes sense. however, we should improve the registration interface to ensure that it doesn't try to fill that output field when collapse_output_transforms is True and there is not non-linear transform selected.

the generic affine vs rigid is also understandable.

let's say you have as transforms: ['translation', 'rigid', 'affine']

these can all be represented by a 4x4 matrix, so when collapse is true these are combined into a genericaffine.mat file.

cheers,

satra

--

Satrajit Ghosh

unread,
Jul 25, 2014, 10:00:53 AM7/25/14
to nipy-user
issue filed here:


cheers,

satra

Cris Lanting

unread,
Jul 27, 2014, 3:50:46 PM7/27/14
to nipy...@googlegroups.com
Thanks. 

Cheers, Cris

Reply all
Reply to author
Forward
0 new messages