Skip to content

add test for recipe localization modules coordinate conventions - #1663

Draft
barentine wants to merge 1 commit into
python-microscopy:masterfrom
barentine:recipeloc_coordinates
Draft

add test for recipe localization modules coordinate conventions#1663
barentine wants to merge 1 commit into
python-microscopy:masterfrom
barentine:recipeloc_coordinates

Conversation

@barentine

Copy link
Copy Markdown
Member

I'm PR'ing this as a draft to show a test I think we should have, and to raise as an issue the coordinate convention headache that one might hit if they do a couple of localization processes using recipe modules.
Namely:

  • DetectPoints2D output is in units of pixels, not units of nanometers
  • FitPoints requires input positions to be in units of nanometers
  • Between density mapping and FitPoints one picks up a half-pixel shift.

Would love to hear some thoughts on preferred way to fix some of these @David-Baddeley !
My thought would be to:

  • multiply DetectPoints2D by voxelsize_nm.x and voxelsize_nm.y
  • fix the fixme in visHelpers.rendGauss about im[0,0] centering
  • write a documentation page about coordinate conventions in PYMEVis / PYMEImage

@David-Baddeley

Copy link
Copy Markdown
Contributor

Coordinates in general could use a bit of a work-over - it's a bit more than just nm vs pixels, it's nm (roi referenced), nm (origin referenced), or pixels. Pixels is the most forgiving if the data comes from a source where it might be missing some metadata , but is also the least powerful.

@David-Baddeley

Copy link
Copy Markdown
Contributor

I wonder about adding some sort of units awareness to tabular, and letting it handle conversions (so if you had a column x, you could query e.g. x_nm or x_pixels), but this could be adding complexity where it's not needed.

@barentine

Copy link
Copy Markdown
Member Author

I do think baking in more unit awareness would be helpful rather than harmful. For example the change to have voxelsize_nm instead of just assuming voxelsize.x is in um has been quite nice.

Separately, I wonder whether there are other ways to bring DetectPoints2D into alignment with the FitPoints module - right now it is super frustrating to e.g. develop a recipe using localization, do the flat fielding yourself etc. and then if you forget to roll your own mapping filter (which is tough because you have to add voxelsize_nm to the mapping namespace somehow or magic number it), you end up with a major bug.

@David-Baddeley

David-Baddeley commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Having a bit of a think about what we'd really need to make this work in tabular.

To be robust we'd need to track:

type: (initially, None or "coordinate" / position)
units: (pixels, nm)
origin: (camera, ROI, stage, other?)
applied transformations: (has this been re-mapped from an image-splitting devce, or drift correction etc ...)

This feels quite heavy for the tabular class when it applies to 3 columns but not to others.

Serialising to hdf will be fine (or rather we can find a way to make it work), serialising to csv / excel will loose all the metadata.

I'm not saying we shouldn't do it, but just that we should think a bit about how.

One possible approach (albeit with high breaking change potential) is to actually change anything that currently writes x to write e.g. x_cam_pixels, x_roi_pixels, x_roi_nm instead and to implement a light-weight wrapper that does backwards compatible translation to x (advantage of this is that the unit intent is not lost if writing to e.g. csv, even if the metadata needed to translate the units is). Asking specifically for x_roi_pixels (rather than x) in a downstream module will fail in a fairly explainable way if that can't be computed.

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