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

XY and Z drift stabilization #108

Closed
wants to merge 74 commits into from
Closed

XY and Z drift stabilization #108

wants to merge 74 commits into from

Conversation

edyoshikun
Copy link
Contributor

@edyoshikun edyoshikun commented Nov 22, 2023

TODO (01/19/24):

  • Merge main after registration_v2
  • Move the functions from /mantis/cli/stabilization to /mantis/analysis/stablize
  • Test the stabilization calculations
  • Update slurmkit call for CLI

This PR has the code for:

  • Calculating the z-drift and returning a z-translation matrix for timelapses estimate_stabilization_affine()
  • Calculating the xy-translation and returning a xy-translation matrices for timelapses stabilize_timalpse()
  • CLI call for running the stabilization
  • Save the translation matrices for XY and Z drift as yml
  • add tests

For the XY stabilization, you can use:
/hpc/projects/comp.micro/mantis/2023_09_22_A549_0.52NA_illum/3-registration/A549_MitoViewGreen_LysoTracker_W3_FOV5_1_phase.zarr

For Z drift, any of the timelapses:
/hpc/projects/comp.micro/mantis/2023_11_01_OpenCell_infection/4-registration/timelapse_7/timelapse_7_phase_registered.zarr

@edyoshikun edyoshikun mentioned this pull request Dec 8, 2023
3 tasks
@edyoshikun edyoshikun changed the title save to yml XY and Z drift stabilization Dec 8, 2023
@edyoshikun edyoshikun changed the base branch from stabilization to registration_v2 December 8, 2023 19:12
@edyoshikun edyoshikun mentioned this pull request Dec 9, 2023
11 tasks
Base automatically changed from registration_v2 to main January 19, 2024 01:47
@ieivanov
Copy link
Collaborator

Replaced by #128

@ieivanov ieivanov closed this Jan 23, 2024
ieivanov added a commit that referenced this pull request Jul 2, 2024
* initial commit adding tools for cropping and registering with ants

* adding lir crop

* starting cleanup for registration

* converting nan to zero

* ants estimate affine

* adding config file for estimate_transform

* cleaning up some redundancies

* fix edge case of input not being float32

* channel is an int

* typo in napari add image for vs ants optimzer

* adding utils yaml

* separated the manual estimation from the optimizer

* added ants to numpy and viceversa

* adding input at the end to prevent from closing

* replacing the reading of .mat to matrix from yaml

* added changes to ants to numpy from Jordaos input

* cannot have recOrder as dependency given different pycromanager versions

* format

* add test for optimize_affine and update readme

* adding docstring

* removed the config dependency

* removing the focus_finding svg

* removing the estimate_affine.yml and making flags to choose channels and verbose

* added comment and code to use scipy.

* -ls and -lf to -s and -t

* document FOCUS_SLICE_ROI_WIDTH

* `estimate-source-to-target-affine` -> `estimate-affine`

* standardize `optimize-affine` arguments

* cleaner docs

* update RegistrationSettings

* fix tests

* remove duplicate

* write indices to output config

* read channels from file

* test fix

* echo improvments

* black

* stabilization draft

* slurm z drift correction

* pystackreg

* functions for estimating the z_drift and xy translation over time

* style

* remove duplicate cli call

* more intuitive manual registration

* stabilization cli

* patch for deskewing

* fixing CLI calls and docstrings

* addine more comments to doctring

* stabilize_timalapse cli typo

* stabilize_timalapse cli typo

* removing some args in doctring.

* testing slurmkit

* fix apply affine example

* matrix multiplication bugfix

* updating the lir_crop using new registration

* adding lir crop to the apply affine and modifying the manual estimation and the optimizer to output the input zyx shape to yaml

* convert nans to zeros

* updating the output saving scheme taking zarrs and saving the verbose in the parent directory.
adding slurmkit demo

* add affine test

* fixing z-shift error

* remove saving intermediate z-shifts

* save to yml

* prototype to change to v2

* fixing the xy drift calculation. refactoring placed xy order instead of yx

* adding option to fill the zeroes with previous value.

* adding tests

* adding one more test

* adding test for affine

* removed main

* fix `apply_affine` docstring

* fixing formatting

* remove crop-output from cli args

* estimate affine cli docstrings

* reverting changes to AnalysisSettings model.

* optimize_affine cli docstrings

* Revert "reverting changes to AnalysisSettings model."

This reverts commit 0e2f8c4.

* fix points layer grid mode bug

* fix tests

* add slurmkit

* combining the croping and merging to the apply-affine

* removing unnecessary prints()

* add registration and stabilization modules

* style

* flake8

* Registration refator (#118)

* refactor apply_affine

* clean up

Co-authored-by: Eduardo Hirata-Miyasaki <eduardo.hirata@czbiohub.org>

* debug and add comments

* updating estimate_affine to match new yml

* don't start parallel pool for 1 iterable

* patch previous commit

* make sure the source_channel_used is first in the list for the optimizer

* make optimize_affine accept the new config parameters

* fix bug calling iohub info on paths with white spaces; rename target_channel_str

* better white space cli bug fix

* cleaner print statements

* don't use itertools.starmap

* clean up apply_affine print statements

* clean up optimize_affine

---------

Co-authored-by: Eduardo Hirata-Miyasaki <eduardo.hirata@czbiohub.org>
Co-authored-by: Eduardo Hirata-Miyasaki <edhiratam@gmail.com>

* removing the source n target shape zyx and testing keep overhang

* updating estimate affine with previous commit changes

* style

* Update example_apply_affine_settings.yml

* refactor registration and stabilization functions

* fixing pytests

* more intuitive function names

* minor refactor of estimane_affine

* bugfix

* fixing the slurmkit files.

* typo

* cleaner processing of additioanal source channels

* refactor apply_affine job submission

* remove position batch processing

* temporarily reorder functions

* revert temp reorder functions

* refactor functions

* refactor combined matrix calculation

* refactor z_drift multiprocessing

* small refactor + messaging

* renaming

* this eliminates stabilization_ove_time_ants by reusing processing_single_position_v2. Also fixes a bug in the processing_single_position_v2.

* modified the function to process channel indeces and copy over the other channels similar to affine transform.
by default all channels are processed with the same transform.

* remove `analysis/stabilize.py`

* renaming

* more renaming

* update docstring

* estimate_xy_stabilization uses the z indices calculated by estimate_z_stabilization

* style

* rename fields in position_focus.csv

* update z_drift figure save path

* add axis labels

* fixing tests

* fix method='ffill' deprecation issue

* clean up slurmkit examples

* update slurmkit_stabilize example

* fix tests

* minor fixes

* fix ffill

* add back `t_idx` param

* more ffill fix

* update apply_transform_to_zyx_and_save_v2 documentation

---------

Co-authored-by: Eduardo Hirata-Miyasaki <edhiratam@gmail.com>
Co-authored-by: Talon Chandler <talonchandler@gmail.com>
Co-authored-by: Eduardo Hirata-Miyasaki <eduardo.hirata@czbiohub.org>
@talonchandler talonchandler deleted the stabilization_yml branch July 11, 2024 22:36
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.

3 participants