Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix: when resampling, must scale displacements #4

Merged
merged 1 commit into from
Jan 24, 2023

Conversation

GFleishman
Copy link

The evaluation script takes a --sampling_factor argument which is passed to zoom to rescale the inputs. If the displacement vector field is resampled, it must also be scaled by the sampling_factor. Consider a displacement vector of [1, 1, 1] before resampling. This means move one voxel along each axis. Now consider resampling the data with a sampling_factor of 0.5. All voxels are now twice as big. Using the original value of [1, 1, 1] is now double the amount of displacement it was before resampling. So, what you really want is [0.5, 0.5, 0.5], which is: disp_field *= SAMPLING_FACTOR which I have added to line 73 of evaluation.py.

@GFleishman
Copy link
Author

Incidentally, if you maintain transforms in physical units and always give the physical voxel spacing of image and transform grids to the resample function these issues are less finicky. I see the appeal of using voxel units (because map_coordinates and it seems simpler) but in real applications all image measurements (registrations, segmentations, etc.) should always be in physical units.

@mansouralawi
Copy link
Collaborator

Thanks @GFleishman for submitting this fix! as mentioned the issue was due missed rescaling step after the downsampling and your solution would resolve it. Appreciate your help!

@mansouralawi mansouralawi merged commit 42c8c8f into ebesier:main Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants