Idea: add automated 2d stitching script for sections, based on interactive-render-workflow / stitch_render_client.ipynb. While stitching remains an interactive process, there should be a way to run it straightforwardly using some default parameters. This process is generally simpler that the 3D alignment, so start with exploring how we can automate this as much as possible. Depending on how good this works, we can optionally extend this to the 3D alignment step.
If stitching fails based on some QC metrics, the interactive notebook can be used to solve the issues. Ideally the problematic sections should be passed on to a file which can be read by the interactive notebook. Then visualize these sections and determine what needs to be done.
[ ] Quantify number of point matches, identify tilepairs with <7 matches as problematic.
[ ] Run renderapi.client.pointMatchClient with more stringent RANSAC and SIFT parameters on problematic tile pairs, interatively if needed. I.e. use a larger image scale space, or more steps per scale octave for SIFT (find more point match candidates) or lower matchMinInlierRatio for RANSAC (expect less inliers,will yield more matches but potentially worse ones). https://github.com/AllenInstitute/asap-modules/blob/master/asap/point_match_optimization/pt_match_optimization.py
The solver writes the transformations in the tilespecs associated with the serial section in the render stack. Once this is done, the QC module can be run to gather statistics about the quality of the stitching and also visualization plots of the stitched section.
[ ] Identify problematic alignment based on QC metrics
[ ] QC metrics are mean point-correspondence residuals: https://github.com/AllenInstitute/asap-modules/blob/master/asap/residuals/compute_residuals.py and Median Absolute Deviation (MAD). MAD is scaling of the tile heigths and widths (y_scale and x_scale) after the alignment, and then the difference between the scaling and the median of the scaling factors of all tiles. This describes how much distortion the tiles undergo when computing the montage, the higher the MAD the more distortion (not good because the translation should involve minimal distortion of the tiles), the higher the mean residual the less accurate the stitching. Ideally: low MAD, low mean residual
[ ] If the misalignments are caused due to insufficient point correspondences, send sections back to the pointMatchClient
[ ] Send misaligned sections flagged by the QC with sufficient point correspondences to BigFeta with new parameters. Find parameters using optimization algorithm based on the stitching quality metrics (Come back to this)
This issue has high priority, would be an extra software feature that we would like to have as first in line. I'll look into the QC metrics on wednesday.
Idea: add automated 2d stitching script for sections, based on
interactive-render-workflow / stitch_render_client.ipynb
. While stitching remains an interactive process, there should be a way to run it straightforwardly using some default parameters. This process is generally simpler that the 3D alignment, so start with exploring how we can automate this as much as possible. Depending on how good this works, we can optionally extend this to the 3D alignment step.If stitching fails based on some QC metrics, the interactive notebook can be used to solve the issues. Ideally the problematic sections should be passed on to a file which can be read by the interactive notebook. Then visualize these sections and determine what needs to be done.
https://asap-modules.readthedocs.io/en/latest/readme/montaging.html for general idea of what it should look like
Basic functionality needed
renderapi.client.pointMatchClient
on multiple threads with default settings forRANSAC
andSIFT
parameters (see notebook for details)Nice-to-haves (not yet implemented in software)
renderapi.client.pointMatchClient
with more stringentRANSAC
andSIFT
parameters on problematic tile pairs, interatively if needed. I.e. use a larger image scale space, or more steps per scale octave for SIFT (find more point match candidates) or lower matchMinInlierRatio for RANSAC (expect less inliers,will yield more matches but potentially worse ones). https://github.com/AllenInstitute/asap-modules/blob/master/asap/point_match_optimization/pt_match_optimization.pyFrom the docs: https://asap-modules.readthedocs.io/en/latest/readme/montaging.html
The solver writes the transformations in the tilespecs associated with the serial section in the render stack. Once this is done, the QC module can be run to gather statistics about the quality of the stitching and also visualization plots of the stitched section.
python -m asap.em_montage_qc.detect_montage_defects --input_json --output_json <output