Skip to content

Add automatic laminography alignment tool#2259

Open
hrobarts wants to merge 7 commits intomasterfrom
laminography_alignment
Open

Add automatic laminography alignment tool#2259
hrobarts wants to merge 7 commits intomasterfrom
laminography_alignment

Conversation

@hrobarts
Copy link
Contributor

@hrobarts hrobarts commented Jan 23, 2026

Changes

Add automatic laminography alignment tool.
Projection matching method to optimise laminography reconstruction by searching tilt and centre of rotation offset

  • Bins projection data with coarse_binning and final_binning
  • Reduces angles to Nyquist or angle_binning
  • Searches a range of tilt and CoR defined by parameter_bounds starting with an initial guess initial_parameters.
  • Reconstructs at each geometry guess, either reconstructs a full volume or a user defined reduced_volume
  • Forward projects and compares to measured projections. Residual is real minus reprojected data, loss is high pass and Sobel filtered
  • Minimises for tilt and CoR using the Powell method

Testing you performed

New demo script: TomographicImaging/CIL-Demos#280

Related issues/links

Checklist

  • I have performed a self-review of my code
  • I have added docstrings in line with the guidance in the developer guide
  • I have updated the relevant documentation
  • I have implemented unit tests that cover any new or modified functionality
  • CHANGELOG.md has been updated with any functionality change
  • Request review from all relevant developers

@github-project-automation github-project-automation bot moved this to Todo in UM 2026 Jan 29, 2026
@casperdcl casperdcl moved this from Todo to In Progress in UM 2026 Jan 29, 2026
@hrobarts hrobarts requested a review from gfardell February 2, 2026 13:52
@hrobarts hrobarts self-assigned this Feb 2, 2026
@hrobarts hrobarts linked an issue Feb 10, 2026 that may be closed by this pull request
Copy link
Contributor Author

@hrobarts hrobarts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments from code review meeting

parameter_tolerance=(0.01, 0.01), coarse_binning=None, final_binning = None,
angle_binning = None, reduced_volume = None):
"""
Initialize a LaminographyCorrector processor to optimize tilt and center-of-rotation for
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Initialize a LaminographyCorrector processor to optimize tilt and center-of-rotation for
Initialize a LaminographyCorrector processor to fit your geometry to find tilt and center-of-rotation for


Parameters
----------
initial_parameters : tuple of float, optional
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe get this from geometry instead

Initial guess for the geometry parameters (tilt_angle_deg, center_of_rotation_pix).
Defaults to (0.0, 0.0).

parameter_bounds : list of tuple of float, optional
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add units

Bounds for the parameters [(tilt_min, tilt_max), (CoR_min, CoR_max)].
Defaults to [(-10, 10), (-20, 20)].

parameter_tolerance : tuple of float, optional
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add units

Final binning factor applied for fine optimisation.
If None, no binning is applied in the fine optimisation step.

angle_binning : float, optional
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slice the angles

Subsampling factor for the angle dimension during optimisation.
If None, automatically determined based on input dataset.

reduced_volume : ImageGeometry, optional
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reduced_volume : ImageGeometry, optional
image_geometry: ImageGeometry, optional

If None, automatically determined based on input dataset.

reduced_volume : ImageGeometry, optional
A reduced-dimension volume to be used for optimisation, e.g. obtained using
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A reduced-dimension volume to be used for optimisation, e.g. obtained using
Pass a reduced-dimension ImageGeometry to speed up the fit, e.g. obtained using

losses = [t[2] for t in eval['evaluations']]

ax = axs[i]
scatter = ax.scatter(tilts, cors, c=losses, cmap='viridis', s=100, edgecolors='k')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
scatter = ax.scatter(tilts, cors, c=losses, cmap='viridis', s=100, edgecolors='k')
scatter = ax.scatter(tilts, cors, c=losses, cmap='viridis_r', s=100, edgecolors='k')

# Test with 180 degree tilt
ag_updated_180 = processor.update_geometry(ag, 180.0, 0.0)
self.assertEqual(ag_updated_180.config.panel.num_pixels[0], original_panel[0])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a tilted dataset from the cil data simulated spheres data forward projected




class LaminographyCorrector(Processor):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class LaminographyCorrector(Processor):
class LaminographyGeometryCorrector(Processor):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Automatic laminography alignment algorithm

1 participant