QI2lab/OPM

Code to read affine transforms for registered data

dpshepherd opened this issue · 2 comments

@ptbrown1729

I added return_affine_xform to data_io.py to read back out the affine transforms that register all tiles to a global coordinate system and across iterative labeling rounds as determined by BigStitcher.

The order for the transforms in the list returned by return_affine_xform for each tile should go:

registration across rounds - anchored by round 0, y = 0, z=0
registration within round - anchored by y=0, z=0 in each round
flip x-axis and shift to other side of image
place into stage coordinates
pixel calibration (uniform matrix)

This demo code should give you a list, with each affine transform in reverse order, with the newest transform first. Right now, the data has to be flipped between python and fiji, which is why there is a weird transforms.

from data_io import return_affine_xform
from pathlib import Path

bdv_xml_path = Path('/mnt/opm2/20210908/deskew_flatfield_output/bdv/16plex_lung_bdv.xml')
affine_xforms = return_affine_xform(bdv_xml_path,r_idx=1,y_idx=1,z_idx=0,total_z_pos=2)
print(affine_xforms)

We'll need to work out exactly what the (0,0,0) pixel that anchors everything is between java and python, but this should be enough for you to register localizations across rounds in the coverslip coordinate system.

FYI - I'm working towards merging the iterative localization branch. My goal is to have only one reconstruction code that auto detects what kind of acquisition was run based on the metadata.

@dpshepherd sounds good, I will give that a try and start trying to interpret the transforms. Is the data in opm2/20210908 ready for me to start running the localization?

Yes. I only deskewed and registered channel 1 as the fiducial.

For the current way I am parsing metadata and loading tiles for the interleaved scan strategy, have a look at reconstruction/recon_opm_iterative_stagescan.py in the Iterative Multiplexing branch.