From matthijs at phenogenomics.ca Fri Sep 16 17:58:52 2011 From: matthijs at phenogenomics.ca (Matthijs van Eede) Date: Fri, 16 Sep 2011 17:58:52 -0400 Subject: [MINC-development] mincresample using grids with large steps and input volumes with small steps Message-ID: <4E73C69C.8030109@phenogenomics.ca> Greetings MINC-experts, When you resample a file with relatively small voxel sizes (60 micron or smaller) and the deformation grid that is being used to resample this file has significantly larger voxels, some resampling issues can occur. This is because the tolerance for determining where a point came from is based on the step sizes of the deformation grid, and not the input volume. (This is related to the ftol variable in the function grid_inverse_transform_point in grid_transforms.c). There are some changes in minc-2.1.00, and the ftol is set to a lower value than would have been the case before, but we still wanted to base this tolerance value on the input file. In order to do this, I forked Andrew's git repository of minc, and implemented changes to get the information of step sizes all the way into that grid_inverse_transform_point function. (It's a long way :-)) My approach was as follows. I did not want to break any possible compatibility with other pieces of code that use functions defined in volume_io, and wanted to use a "default argument" for the functions that are involved in getting the step sizes of the input volume. In c that is not directly supported, so I did the following: Original function: VIOAPI void grid_inverse_transform_point( General_transform *transform, Real x, Real y, Real z, Real *x_transformed, Real *y_transformed, Real *z_transformed ) { ... ... } And changed that in the following two function: VIOAPI void grid_inverse_transform_point_with_input_steps( General_transform *transform, Real x, Real y, Real z, Real *input_volume_steps, Real *x_transformed, Real *y_transformed, Real *z_transformed ) { ... ... } and VIOAPI void grid_inverse_transform_point( General_transform *transform, Real x, Real y, Real z, Real *x_transformed, Real *y_transformed, Real *z_transformed ) { grid_inverse_transform_point_with_input_steps(transform, x, y, z, NULL, x_transformed, y_transformed, z_transformed ); } And applied this to a couple of functions in order to reach the function in mincresample where there is still information about the input volume around. I'd be happy to hear any suggestions/comments/remarks about this approach, and if you think this is a proper way to deal with this issue. The forked git branch is here: https://github.com/mcvaneede/minc Thank you in advance, Matthijs