freesurfer / surfa

Python utilities for medical image and surface-based analysis
24 stars 8 forks source link

Added 'reshape_on_bbox' method to the FramedImage class #34

Closed jnolan14 closed 2 months ago

jnolan14 commented 2 months ago

Bruce wants the ability to reshape a volume to a target size, centered on the bounding box. Added the 'reshape_on_bbox' method to the FramedImage class. It calls self.bbox to get the bounding box, then adjusts that cropping to match the target size using 'fit_slicing_to_shape' and uses that to crop the original volume.

@ahoopes, not sure if it is better to have this be its own method, or if it would be better to put this in 'reshape' and reintroduce the 'center' argument.

ahoopes commented 2 months ago

cool this is a good idea

my preference is just adding an argument option like center='bbox' or something to reshape instead of introducing a new function because its a bit more minimal and the functionality is basically the same, but could go either way

jnolan14 commented 2 months ago

Thanks, Andrew! I agree it would be a bit cleaner to fold the functionality into reshape, and would allow us to make the fit_to_shape hook fully backwards compatible. I'll add the functionality into reshape and update the fit_to_shape call