svmbir
svmbir copied to clipboard
Object oriented interface
I pushed a branch oo_interface
that includes a definition of a new callable class Recon
that wraps svmbir.recon()
. What it currently does is very simple. Instances of Recon have the attribute .params
which is a dictionary of all the arguments to svmbir.recon(). An instance of Recon is callable, and can be used with the same syntax as svmbir.recon(). So,
img = svmbir.recon(sino,angles,**kwargs)
Can be achieved equivalently with,
rec_op = svmbir.Recon(**kwargs)
img = rec_op(sino,angles) # can also add keyword arguments here
Additionally it defines the following methods:
__init__(self, **kwargs) # defines/sets initial 'params' attribute
__call__(self, sino, angles, **kwargs) # calls svmbir.recon()
set_defaults() # resets params attribute to defaults
set_params(**kwargs) # sets params entries by keyword
save_params(filename) # save params dict to numpy/pickle file
load_params(filename) # load params dict from numpy/pickle file
backproject(sino, angles, **kwargs) # backprojector
I added a file demo/demo_oo.py
that illustrates further.
We can use this thread to discuss this and further development of an OO interface for svmbir.