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

Should functionals take PlantSeg classes e.g. VoxelSize or tuple[float, float, float] #290

Open
qin-yu opened this issue Aug 1, 2024 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@qin-yu
Copy link
Collaborator

qin-yu commented Aug 1, 2024

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().

@qin-yu qin-yu added bug Something isn't working enhancement New feature or request labels Aug 1, 2024
@lorenzocerrone
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants