kreshuklab / plant-seg

A tool for cell instance aware segmentation in densely packed 3D volumetric images
https://kreshuklab.github.io/plant-seg/
MIT License
90 stars 31 forks source link

Axis order might have been inconsistent #289

Open qin-yu opened 1 month ago

qin-yu commented 1 month ago

There appears to be a discrepancy in how the resolution axes are handled. The naming convention and the effect on the resolution axes seem to differ in various parts of the code.

  1. The code snippet here reads and parses the ZYX resolution from a TIFF file into VoxelSize. This part of the code appears to work correctly. However, the naming convention used is __XY, which might be misleading because the effect seems to be __YX. https://github.com/kreshuklab/plant-seg/blob/53d12bd00dbc3f4490577a3fb1ce71207c0adf84/plantseg/io/tiff.py#L141-L144

  2. The function here correctly reads and parses the resolution, and ZYX is passed into VoxelSize. https://github.com/kreshuklab/plant-seg/blob/53d12bd00dbc3f4490577a3fb1ce71207c0adf84/plantseg/io/tiff.py#L32-L41

  3. The code snippet here outputs ZXY resolution from VoxelSize, which aligns with the intended behavior but does not match the actual effect observed. https://github.com/kreshuklab/plant-seg/blob/53d12bd00dbc3f4490577a3fb1ce71207c0adf84/plantseg/io/utils.py#L76-L95

qin-yu commented 1 month ago

I didn't mark this as a bug because I'm not 100% sure.

qin-yu commented 1 month ago

I just realised the ImageLayout always uses XY. But just confirmed that TIFF and HDF5 both have __YX/__HW and both pytorch3dunet and PlantSeg might have been using __YX effectively.

lorenzocerrone commented 4 weeks ago

The XY or YX is a harmless convention (unless you do measurements or have an XY anisotropy). Most tools agree on XY, but plantseg and pyotrch3dunet don't. But I would be in favor of moving to YX everywhere.