====== vmr.ApplyTRF ======
===== Motivation =====
The main motivation for using this function is the ability to flexibly script spatial VMR transformation in Matlab.
===== Method reference ('vmr.Help('ApplyTRF')') =====
VMR::ApplyTRF - apply transformation to VMR
FORMAT: newvmr = vmr.ApplyTRF(trf [, opts])
Input fields:
trf TRF object
opts struct with optional fields
.asdouble store output as double (default: false)
.inverse apply inverse transformation (default: false)
.method interpolation, see flexinterpn_method (default: 'linear')
Output fields:
newvmr transformed VMR
===== Usage examples =====
* using a TRF that was created in BrainVoyager (and instead of the file selector in the first two lines, this can be scripted!): %load VMR and TRF
vmr = xff('*.vmr');
trf = xff('*.trf');
% apply transformation with cubic interpolation
trfvmr = vmr.ApplyTRF(trf, struct('method', 'cubic'));
trfvmr.SaveAs;
% clear objects
vmr.ClearObject;
trf.ClearObject;
trfvmr.ClearObject;
* using two VMRs, coregister them, then transform the first: % load two VMRs
vmr1 = xff(sourcevmr);
vmr2 = xff(targetvmr);
% run coregistration (requires SPM5 or SPM8 on the path!!)
% vmr2 is the target space (stationary), vmr1 the one to be resampled!
trf = vmrspmcoreg(vmr1, vmr2)
% resample vmr1 using sinc (lanczos3) interpolation
vmr1_in_vmr2_space = vmr1.ApplyTRF(trf, struct('method', 'lanczos3'));
% save TRF and VMR
[sourcepath, sourcefile] = fileparts(sourcevmr);
if isempty(sourcepath)
sourcepath = '.';
end
[nullpath, targetfile] = fileparts(targetvmr);
trf.SaveAs(sprintf('%s/%s-TO-%s.trf', sourcepath, sourcefile, targetfile));
vmr1_in_vmr2_space.SaveAs(sprintf('%s/%s-TO-%s.vmr', sourcepath, sourcefile, targetfile));
% clear objects
clearxffobjects({vmr1, vmr2, trf, vmr1_in_vmr2_space});