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

Sqlite Callback #1988

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

manchester-jhellier
Copy link
Contributor

Description

A callback which lets us evaluate user-defined functions on an Algorithm and save solution state under user-defined conditions. Evaluations of functions and locations of saved solution artifacts are stored in an sqlite database.

Example Usage

Not quite sure what to put for this. Is there a minimal CIL problem you like to test with? I can write some tests based on that if you'd like.

@MargaretDuff
Copy link
Member

Hey @manchester-jhellier - thank-you for this - it looks really interesting!

A demonstration example could be something on the spheres data (which is small and should be quick to run) e.g.

from cil.utilities import dataexample
from cil.processors import TransmissionAbsorptionConverter, Slicer
from cil.utilities.quality_measures import psnr
import numpy as np
from cil.plugins.tigre import ProjectionOperator
from cil.optimisation.functions import LeastSquares, L2NormSquared, TotalVariation,
from cil.optimisation.algorithms import FISTA 

ground_truth = dataexample.SIMULATED_SPHERE_VOLUME.get()

data = dataexample.SIMULATED_CONE_BEAM_DATA.get()
data = data.get_slice(vertical='centre')
ground_truth = ground_truth.get_slice(vertical='centre')
absorption = TransmissionAbsorptionConverter()(data)
absorption = Slicer(roi={'angle':(0, -1, 5)})(absorption)

ig = ground_truth.geometry

alpha1=0.1
alpha2=0.1

A = ProjectionOperator(image_geometry=ig, 
                       acquisition_geometry=absorption.geometry)
F = LeastSquares(A = A, b = absorption)+alpha1*L2NormSquared()
G = alpha2*TotalVariation(lower=0)

algo_tv = FISTA(initial = ig.allocate(), f = F, g = G)
algo_tv.run(100, callbacks=[callbacks.ProgressCallback()])

Here there are 2 regularisation parameters - for the TV and Tikhonov terms and so you could try a range of values of these, saving the PSNR of the reconstructed image compared with the ground truth alongside a path to saved image? Example code could go in this folder https://github.com/TomographicImaging/CIL-Demos/tree/main/misc or it would fit really well as a CIL showcase (I can help polish this!) https://github.com/TomographicImaging/CIL-User-Showcase.

R.e. unit tests, they need to be much less computationally costly and are more about testing each "unit" of the code e.g. that the initialise works with all the right defaults etc. We can help write these later!

@manchester-jhellier
Copy link
Contributor Author

Cool! That looks like nice little problem; I'll see if I can't grab all three components of the objective and store them, should show you what I mean. The callbacks will be a bit solver-specific, hence my issue about subobjective evaluation on demand. I'll try and make you a demonstration soon.

@MargaretDuff
Copy link
Member

Thanks @manchester-jhellier!

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.

2 participants