general-discussion > Niak for reading non-linear transformations
Showing 1-4 of 4 posts
Results per page:
Mar 21, 2016  09:03 PM | Phil Novosad
Niak for reading non-linear transformations
Hi all,

I'm encountering a problem when using niak to read a non-linear transformation from 'minctracc'. 'mincinfo' correctly shows that the grid transformation has 4 dimensions (3D position + vector for each grid point), but using 'niak_read_vol' yields a single 3D volume (just one direction of the vector at each grid point). I'd like to be able to open the non-linear transformation, manipulate it using MATLAB, then save it back to minc and use 'mincresample'. Any suggestions?

Mar 22, 2016  07:03 PM | Pierre Bellec
RE: Niak for reading non-linear transformations
Hi Phil,

The NIAK reader/writer really is meant for structural and functional MRI, not any MINC volume. The fourth dimension is expected to be time, and that plays a role at different places. I have worked at some point on a general purpose reader (that also does not have dependencies besides matlab). You may want to give it a try:

If the reader works, and this is of interest, I may try wrapping up the writer (it's very close to done). 

I hope this helps,

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;

Nov 20, 2016  08:11 PM | Pierre Bellec
RE: Niak for reading non-linear transformations
Thanks for sharing!