From matthijs at mouseimaging.ca Tue Jun 11 15:59:00 2013 From: matthijs at mouseimaging.ca (Matthijs Van Eede) Date: Tue, 11 Jun 2013 15:59:00 -0400 (EDT) Subject: [MINC-development] mincresample using ftol based on the input file stepsizes In-Reply-To: <1675037948.207607.1370974251733.JavaMail.root@mouseimaging.ca> Message-ID: <1872028961.210172.1370980740737.JavaMail.root@mouseimaging.ca> Greetings! I was going through my todo list, and saw that there was an issue I wanted to address for a long time which I should really tackle properly. When using mincresample, the error tolerance for determining where a voxel comes from (ftol) is based on the step sizes of the deformation grid used for the resampling. Especially when using animal data, there can be a big difference between that step size and the step size of the actual input file, potentially causing resampling inaccuracies. A possible solution to this is to artificially change the stepsize of the input data (which I remember Andrew saying at some point), but as Jason mentioned, it would be nice to have "normal" sized mouse brains even on the southern hemisphere :-) In order to do this, mincresample needs to pass along the step size information of the input file being resampled. I've made changes to the libminc and minc-tools repositories from GitHub which I forked from BIC-MNI. For libminc, I worked on Vladimir's develop branch which is used for his minc-toolkit repository. I made changes to the following files: libminc/volume_io/Include/volume_io/vol_io_prototypes.h libminc/volume_io/MNI_formats/gen_xfs.c libminc/volume_io/MNI_formats/grid_transforms.c and minc-tools/progs/mincresample/mincresample.c minc-tools/progs/mincresample/mincresample.h minc-tools/progs/mincresample/resample_volumes.c Here are the specific changes: https://github.com/mcvaneede/libminc/commit/784f6a01036c2c1d38924eea363e1aa7a0638673 https://github.com/mcvaneede/minc-tools/commit/89bcfe73b705ebc84d7442cec0cff78aa7217e15 Would it be possible to merge these changes back into the main branch at BIC-MNI? Thanks in advance, Matthijs PS The way I addressed this issue overall, is to create two functions out of the original function that needed to pass along the input step size information as follows: Original function: VIOAPI VIO_Status grid_inverse_transform_point( VIO_General_transform *transform, VIO_Real x, VIO_Real y, VIO_Real z, VIO_Real *x_transformed, VIO_Real *y_transformed, VIO_Real *z_transformed ) { ... ... } And split it up into the two following (main): VIOAPI VIO_Status grid_inverse_transform_point_with_input_steps( VIO_General_transform *transform, VIO_Real x, VIO_Real y, VIO_Real z, VIO_Real *input_volume_steps, VIO_Real *x_transformed, VIO_Real *y_transformed, VIO_Real *z_transformed ) { ... ... } and the now "dummy": VIOAPI VIO_Status grid_inverse_transform_point( VIO_General_transform *transform, VIO_Real x, VIO_Real y, VIO_Real z, VIO_Real *x_transformed, VIO_Real *y_transformed, VIO_Real *z_transformed ) { return grid_inverse_transform_point_with_input_steps(transform, x, y, z, NULL, x_transformed, y_transformed, z_transformed ); } From vladimir.fonov at gmail.com Tue Jun 11 16:12:39 2013 From: vladimir.fonov at gmail.com (Vladimir S. FONOV) Date: Tue, 11 Jun 2013 16:12:39 -0400 Subject: [MINC-development] mincresample using ftol based on the input file stepsizes In-Reply-To: <1872028961.210172.1370980740737.JavaMail.root@mouseimaging.ca> References: <1872028961.210172.1370980740737.JavaMail.root@mouseimaging.ca> Message-ID: <51B784B7.50308@gmail.com> Hello, can you create pull-requests for libminc and minc-tools - this way we can integrate this info into the main github repository On 13-06-11 03:59 PM, Matthijs Van Eede wrote: > Greetings! > > I was going through my todo list, and saw that there was an issue I wanted to address for a long time which I should really tackle properly. When using mincresample, the error tolerance for determining where a voxel comes from (ftol) is based on the step sizes of the deformation grid used for the resampling. Especially when using animal data, there can be a big difference between that step size and the step size of the actual input file, potentially causing resampling inaccuracies. A possible solution to this is to artificially change the stepsize of the input data (which I remember Andrew saying at some point), but as Jason mentioned, it would be nice to have "normal" sized mouse brains even on the southern hemisphere :-) > > In order to do this, mincresample needs to pass along the step size information of the input file being resampled. I've made changes to the libminc and minc-tools repositories from GitHub which I forked from BIC-MNI. For libminc, I worked on Vladimir's develop branch which is used for his minc-toolkit repository. I made changes to the following files: > > libminc/volume_io/Include/volume_io/vol_io_prototypes.h > libminc/volume_io/MNI_formats/gen_xfs.c > libminc/volume_io/MNI_formats/grid_transforms.c > > and > > minc-tools/progs/mincresample/mincresample.c > minc-tools/progs/mincresample/mincresample.h > minc-tools/progs/mincresample/resample_volumes.c > > Here are the specific changes: > > https://github.com/mcvaneede/libminc/commit/784f6a01036c2c1d38924eea363e1aa7a0638673 > https://github.com/mcvaneede/minc-tools/commit/89bcfe73b705ebc84d7442cec0cff78aa7217e15 > > Would it be possible to merge these changes back into the main branch at BIC-MNI? > Thanks in advance, > Matthijs > > PS The way I addressed this issue overall, is to create two functions out of the original function that needed to pass along the input step size information as follows: > > Original function: > VIOAPI VIO_Status grid_inverse_transform_point( > VIO_General_transform *transform, > VIO_Real x, > VIO_Real y, > VIO_Real z, > VIO_Real *x_transformed, > VIO_Real *y_transformed, > VIO_Real *z_transformed ) > { > ... > ... > } > > And split it up into the two following (main): > VIOAPI VIO_Status grid_inverse_transform_point_with_input_steps( > VIO_General_transform *transform, > VIO_Real x, > VIO_Real y, > VIO_Real z, > VIO_Real *input_volume_steps, > VIO_Real *x_transformed, > VIO_Real *y_transformed, > VIO_Real *z_transformed ) > { > ... > ... > } > > and the now "dummy": > > VIOAPI VIO_Status grid_inverse_transform_point( > VIO_General_transform *transform, > VIO_Real x, > VIO_Real y, > VIO_Real z, > VIO_Real *x_transformed, > VIO_Real *y_transformed, > VIO_Real *z_transformed ) > { > return grid_inverse_transform_point_with_input_steps(transform, x, y, z, > NULL, > x_transformed, y_transformed, z_transformed ); > } > _______________________________________________ > MINC-development mailing list > MINC-development at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development > -- Best regards, Vladimir S. FONOV ~ vladimir.fonov gmail.com From matthijs at mouseimaging.ca Tue Jun 11 16:40:43 2013 From: matthijs at mouseimaging.ca (Matthijs Van Eede) Date: Tue, 11 Jun 2013 16:40:43 -0400 (EDT) Subject: [MINC-development] mincresample using ftol based on the input file stepsizes In-Reply-To: <51B784B7.50308@gmail.com> References: <1872028961.210172.1370980740737.JavaMail.root@mouseimaging.ca> <51B784B7.50308@gmail.com> Message-ID: <1039091318.210647.1370983243157.JavaMail.root@mouseimaging.ca> Great, thanks Vladimir! ----- Original Message ----- From: "Vladimir S. FONOV" To: minc-development at bic.mni.mcgill.ca Sent: Tuesday, June 11, 2013 4:12:39 PM Subject: Re: [MINC-development] mincresample using ftol based on the input file stepsizes Hello, can you create pull-requests for libminc and minc-tools - this way we can integrate this info into the main github repository On 13-06-11 03:59 PM, Matthijs Van Eede wrote: > Greetings! > > I was going through my todo list, and saw that there was an issue I wanted to address for a long time which I should really tackle properly. When using mincresample, the error tolerance for determining where a voxel comes from (ftol) is based on the step sizes of the deformation grid used for the resampling. Especially when using animal data, there can be a big difference between that step size and the step size of the actual input file, potentially causing resampling inaccuracies. A possible solution to this is to artificially change the stepsize of the input data (which I remember Andrew saying at some point), but as Jason mentioned, it would be nice to have "normal" sized mouse brains even on the southern hemisphere :-) > > In order to do this, mincresample needs to pass along the step size information of the input file being resampled. I've made changes to the libminc and minc-tools repositories from GitHub which I forked from BIC-MNI. For libminc, I worked on Vladimir's develop branch which is used for his minc-toolkit repository. I made changes to the following files: > > libminc/volume_io/Include/volume_io/vol_io_prototypes.h > libminc/volume_io/MNI_formats/gen_xfs.c > libminc/volume_io/MNI_formats/grid_transforms.c > > and > > minc-tools/progs/mincresample/mincresample.c > minc-tools/progs/mincresample/mincresample.h > minc-tools/progs/mincresample/resample_volumes.c > > Here are the specific changes: > > https://github.com/mcvaneede/libminc/commit/784f6a01036c2c1d38924eea363e1aa7a0638673 > https://github.com/mcvaneede/minc-tools/commit/89bcfe73b705ebc84d7442cec0cff78aa7217e15 > > Would it be possible to merge these changes back into the main branch at BIC-MNI? > Thanks in advance, > Matthijs > > PS The way I addressed this issue overall, is to create two functions out of the original function that needed to pass along the input step size information as follows: > > Original function: > VIOAPI VIO_Status grid_inverse_transform_point( > VIO_General_transform *transform, > VIO_Real x, > VIO_Real y, > VIO_Real z, > VIO_Real *x_transformed, > VIO_Real *y_transformed, > VIO_Real *z_transformed ) > { > ... > ... > } > > And split it up into the two following (main): > VIOAPI VIO_Status grid_inverse_transform_point_with_input_steps( > VIO_General_transform *transform, > VIO_Real x, > VIO_Real y, > VIO_Real z, > VIO_Real *input_volume_steps, > VIO_Real *x_transformed, > VIO_Real *y_transformed, > VIO_Real *z_transformed ) > { > ... > ... > } > > and the now "dummy": > > VIOAPI VIO_Status grid_inverse_transform_point( > VIO_General_transform *transform, > VIO_Real x, > VIO_Real y, > VIO_Real z, > VIO_Real *x_transformed, > VIO_Real *y_transformed, > VIO_Real *z_transformed ) > { > return grid_inverse_transform_point_with_input_steps(transform, x, y, z, > NULL, > x_transformed, y_transformed, z_transformed ); > } > _______________________________________________ > MINC-development mailing list > MINC-development at bic.mni.mcgill.ca > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development > -- Best regards, Vladimir S. FONOV ~ vladimir.fonov gmail.com _______________________________________________ MINC-development mailing list MINC-development at bic.mni.mcgill.ca http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-development