Closed edyoshikun closed 10 months ago
In the final version of the registration pipeline we should rotate the volumes by 90 deg such that they are in landscape mode rather than portrait mode (i.e. with larger width than height). Our brains process landscape aspect ratio more naturally and our monitors are built that way too. This is not critical now, but may affect some of the earlier design choices.
@talonchandler let's schedule some time to go over this. Some design choices that we should also think about:
scipy.ndimage
vs ants registration
yaml
config files should we take as input and output for the estimate-affine
and optimize-affine
.coordinateTransformMetadta()
?Excellent! @edyoshikun and I just finished a paired session and put together this list of (very superficial) TODO items. Thanks for all of your effort here @edyoshikun.
@edyoshikun I've tagged you on the ones that you're best suited to handle. I'll handle the rest.
-ls
and -lf
flag names to -s
and -t
estimate-source-to-target-affine
estimate-source-to-target-affine
optimize-affine
docs, specify -o
is YAML (edit: this is specified in the example docstring, so I think it's good)optimize-affine
flags for display and channel choicepre_affine_90degree...
everywhere, handle output_shape
parameter-v
flag for optimize-affine
affine_transform
I've run all of the individual steps, and I understand how everything works. Early next week I'll run this on Soorya's data from hummingbird to test it further, and I'll give the code a line-by-line look.
@edyoshikun feel free to comment on my changes if you'd like to take a look.
@ieivanov
we should rotate the volumes by 90 deg such that they are in landscape mode rather than portrait mode (i.e. with larger width than height)
@edyoshikun and I discussed this and we'll suggest using napari's rotate feature for landscape (maybe even triggering rotation if Y>X in some scripts). If we want to change the convention for the y axis, we think that would be a larger change that would break convention (at least wrt DaXi and Sapoznik papers). We're open to more discussion.
Quick comment: I found the source
and target
nomenclature quite confusing. Instead, registration algorithms (including ants) use fixed
and moving
names to refer to the two images being registered. We should switch to that naming
In 91375274c06779ddd76561b7e46c1fbafd60ddf4 I've tried to develop what I think is a bit more intuitive manual registration workflow. Here are the highlights:
Talon and Ed, let me know what you think
input_shape_zyx
should be part of RegistrationSettings
as it is needed for the LIR cropping
A few observations after working through the registration pipeline:
apply_affine
handles missing data - currently we end up with an image that has both zeros and nans, which displays in napari as a black rectangle on a gray background. Instead, if the input data does not exist, apply_affine
should carry on and not modified the empty zarr created at the beginning.recOrder
model of reconstruct
breaking down into compute-ft
and apply-inv-tf
would be useful here as well. The overarching CLI could be mantis register
- what would be the individual components?nan
outputs I believe are a product from reconstruction on a blank/zeroes frame. I added a np.nan_to_num(zyx_data, nan=0)
prior to applying the transform to a volume. This would convert the nans to zeros, but I am trying to think of the cases in which we don't want this to happen. apply_affine
. It didn't make sense to separate them since the lir crop
has to apply the affine transform anyways to know what the rectangle's shape is. Perhaps my implementation of find_lir()
is not the fastest and cleanest. I added a mode so we can plot the output with a red rectangle for debugging. @edyoshikun can you revert the last two commits and add them on a branch off of this one? The registration is currently working and useful, we should be careful not to break it.
This PR adds the following:
TODO:
fry2
)keep_overhang: true
@edyoshikunestimate_affine
,optimize_affine
, andapply_affine
all take source and targets dirpaths, we no longer need to keepsource_shape_zyx
andtarget_shape_zyx
in the yml config file @edyoshikunutils
and into theregistration
andstabilization
modules @ieivanovFuture PRs:
target
tofixed
andsource
tomoving
to match convention in other image registration pipelinesestimate-affine
,optimize-affine
, andapply-affine
CLI calls toestimate-registration
,optimize-registration
, andregister
process_single_position_v2
andapply_transform_to_zyx_and_save_v2
(andaffine_transform
) to work on arrays of consistent shape - either ZYX or CZYX, not both. Possibly moveprocess_single_position
andapply_transform_to_zyx_and_save
toiohub
(long withupdate_scale_metadata
?). @talonchandler @ziw-liuapply_affine
handles positions will all nans or zeros. Currently we convert nans to zeros, which should not be necessary