If BaSiC.fit() could provide a way to peak at its parameters throughout optimization, we can do some cool stuff in the napari plugin. For example, there could be a preview layer that is updated with the flatfield estimate every n iterations. This would probably slow down the computation but would provide a cool way of watching the process unfold. We could also use the parameters to plot error, etc.
napari provides a thread_worker decorator to simplify adding plugin functions as to not block using the gui. The worker can yield values during its call, which can be passed onto other functions.
It is generally bad design to change output type of a function based on argument, but ignoring that, here is one way this could be implemented.
class BaSiC:
...
def fit(self, images, ..., updates=False):
...
while not CONVERGED:
...
if updates:
yield self.params
...
If
BaSiC.fit()
could provide a way to peak at its parameters throughout optimization, we can do some cool stuff in the napari plugin. For example, there could be a preview layer that is updated with the flatfield estimate every n iterations. This would probably slow down the computation but would provide a cool way of watching the process unfold. We could also use the parameters to plot error, etc.napari provides a
thread_worker
decorator to simplify adding plugin functions as to not block using the gui. Theworker
can yield values during its call, which can be passed onto other functions.It is generally bad design to change output type of a function based on argument, but ignoring that, here is one way this could be implemented.