raacampbell / matlab_elastix

MATLAB Elastix wrapper
http://www.mathworks.com/matlabcentral/fileexchange/52982-matlab-elastix
GNU Lesser General Public License v3.0
26 stars 12 forks source link

Transformix not returning transformation field #20

Open w013nad opened 7 years ago

w013nad commented 7 years ago

In transformix, it's supposed to be possible to output a deformation field rather than an image. (I'm working with hyperspectral so it's much easier to get the deformation field and transform all the layers individually using the deformation field. Anyway, I came up with a fix outlined below. Note that the fix is tailored to my needs. This is for a 2D image, not sure how it would work for 3D Originally I did get an output but it was an empty 1x1 stucture

fid = fopen(fullfile(outputDir,'deformationField.raw')); raw_out = fread(fid,Inf,'float'); out_points(:,:,1) = reshape(raw_out(1:2:end),size_im(2),size_im(1)); out_points(;,:,2) = reshape(raw_out(2:2:end),size_im(2),size_im(1)); out_points = permute(out_points,[2,1,3]);

From there, I'm able to just cycle through and call for ii = 1:num_channels out(:,:,ii) = imwarp(moving(:,:,ii),out_points); end

I originally just ran all the layers through but this comes out to a 1.5 minutes saving per data cube processed.

Also, how to I insert code formatting here? Not used to github.

raacampbell commented 7 years ago

Thanks, I'll look into this.

w013nad commented 7 years ago

Short update. When I did this, my error rates jumped way up. It's still deforming correctly but my RMSE of desired output to actual output jumped form 0.03 to 0.04. Not really sure why.

raacampbell commented 3 years ago

Not followed up