I saw the bug here, and started to wonder if we want the functionals/API to take just tuple[float, float, float] or VoxelSize. I wouldn't want to create a VoxelSize first if I know PlantSeg and just want to use the functions.
def _image_postprocessing(image: PlantSegImage, scale_to_origin: bool, export_dtype) -> PlantSegImage:
if scale_to_origin and image.requires_scaling:
data = dp.scale_image_to_voxelsize(
image.get_data(),
input_voxel_size=image.voxel_size, # <-- here image.voxel_size is a VoxelSize but input_voxel_size wants tuple
output_voxel_size=image.original_voxel_size, # same here
order=image.interpolation_order(),
)
new_voxel_size = image.original_voxel_size
PS: if we decide to let functionals take vallina-typed inputs, then I fix this by adding a .to_tuple() to VoxelSize or rename VoxelSize.voxels_size to VoxelSize.value. So we access image.voxel_size.value or image.voxel_size.to_tuple().
I think we should write a new functional that also takes the layout as input (like in the current image_rescale_to_voxel_size_task). I agree that the function will only need to know about the tuple.
I saw the bug here, and started to wonder if we want the functionals/API to take just
tuple[float, float, float]
orVoxelSize
. I wouldn't want to create aVoxelSize
first if I know PlantSeg and just want to use the functions.PS: if we decide to let functionals take vallina-typed inputs, then I fix this by adding a
.to_tuple()
toVoxelSize
or renameVoxelSize.voxels_size
toVoxelSize.value
. So we accessimage.voxel_size.value
orimage.voxel_size.to_tuple()
.