Closed Tazinho closed 7 years ago
I would use the registration
function, which has some different defaults, but is a better registration wrapper, and returns a list of the transformations and the files.
reg = registration(filename = some_file_path,
outfile = some_file_output_path,
other.files = other_metrical_file_paths,
other.outfiles = other_metrical_file_output_paths,
template.file = some_template_path,
interpolator = "linear")
res = ants_apply_transforms(fixed = template.file,
moving = other_binary_file_paths, transformlist = reg$fwdtransforms,
interpolator = "nearestNeighbor")
mapply(function(img, fname) {
writenii(img, fname)
}, res, other_binary_file_output_paths)
These functions wrap antsApplyTransforms
and antsRegistration
from ANTsR
Thanks for your quick response! This sounds really good. For everyone with the same usecase:
remove.warp = FALSE
within extrantsr::registration()
ants_apply_transforms()
Error in antsApplyTransforms(fixed = fixed, moving = moving, transformlist = transformlist, :
Transform /tmp/RtmpzANGJs/file161b39a9966c1Warp.nii.gz does not exist.
These should be found in:
> reg$fwdtransforms
[1] "/tmp/RtmpzANGJs/file161b39a9966c1Warp.nii.gz"
[2] "/tmp/RtmpzANGJs/file161b39a9966c0GenericAffine.mat"
But are only, if you made the setting above.
At the moment I am using
ants_regwrite()
to register different niftis on a template. The niftis differ in their scales. I have binary and metrical maps. So I need different interpolation arguments and so I need to callants_regwrite()
two times. My main issue with this, is that this means that the registration is done two times, which (as I understand) leads to (minimal) different transformations (since there seems to be now way to control external random number generators) and doubled runtime.Is there a compact highlevel syntax invoking
ants_regwrite()
or similar to do sth like the following, just with using two times the same transformation?