general-discussion
general-discussion > RE: Niak for reading non-linear transformations
Nov 18, 2016 08:11 PM | Phil Novosad
RE: Niak for reading non-linear transformations
Hi Pierre,
I ended up writing a small script to do this. To anyone else who may need to read in displacement fields, the way I did it was to extract each vector component from the displacement field and read it in separately as a 3D volume. Depending on what registration algo is used, the "vector dimension" bit may have to be swapped (I seem to recall that demons and minctracc give fields with different fastest-varying dimensions). Something like this:
---
function [grid] = read_grid(grid_name)
% get 3 components of displacement field
command = ['mincreshape -clobber -dimrange vector_dimension=1,0 ' grid_name ' x_comp.mnc']; system(command);
command = ['mincreshape -clobber -dimrange vector_dimension=0,0 ' grid_name ' y_comp.mnc']; system(command);
command = ['mincreshape -clobber -dimrange vector_dimension=2,0 ' grid_name ' z_comp.mnc']; system(command);
% read each file with niak
[~,v] = niak_read_minc('x_comp.mnc'); grid(:,:,:,1) = v;
[~,v] = niak_read_minc('y_comp.mnc'); grid(:,:,:,2) = v;
[~,v] = niak_read_minc('z_comp.mnc'); grid(:,:,:,3) = v;
end
I ended up writing a small script to do this. To anyone else who may need to read in displacement fields, the way I did it was to extract each vector component from the displacement field and read it in separately as a 3D volume. Depending on what registration algo is used, the "vector dimension" bit may have to be swapped (I seem to recall that demons and minctracc give fields with different fastest-varying dimensions). Something like this:
---
function [grid] = read_grid(grid_name)
% get 3 components of displacement field
command = ['mincreshape -clobber -dimrange vector_dimension=1,0 ' grid_name ' x_comp.mnc']; system(command);
command = ['mincreshape -clobber -dimrange vector_dimension=0,0 ' grid_name ' y_comp.mnc']; system(command);
command = ['mincreshape -clobber -dimrange vector_dimension=2,0 ' grid_name ' z_comp.mnc']; system(command);
% read each file with niak
[~,v] = niak_read_minc('x_comp.mnc'); grid(:,:,:,1) = v;
[~,v] = niak_read_minc('y_comp.mnc'); grid(:,:,:,2) = v;
[~,v] = niak_read_minc('z_comp.mnc'); grid(:,:,:,3) = v;
end
Threaded View
Title | Author | Date |
---|---|---|
Phil Novosad | Mar 21, 2016 | |
Pierre Bellec | Mar 22, 2016 | |
Phil Novosad | Nov 18, 2016 | |
Pierre Bellec | Nov 20, 2016 | |