Extensions
Concert integrates third-party software in the ext package. Because the
dependencies of these modules are not listed as Concert dependencies, you have
to make sure, that the appropriate libraries and modules are installed.
UFO Processing
- class concert.ext.ufo.FlatCorrect(dark, flat, absorptivity=True, fix_nan_and_inf=True, copy_inputs=False)
Flat-field correction.
- class concert.ext.ufo.GeneralBackproject(args, resources=None, gpu_index=0, do_normalization=False, region=None, copy_inputs=False)
One backprojector worker.
- args
GeneralBackprojectArgsinstance with arguments for reconstruction
- resources
Ufo.Resources instance
- gpu_index
use GPU with this index
- do_normalization
do flat correction of not
- region
User defined region which can override the one stored in args
- copy_inputs
if True copy images before they are inserted into UFO
- class concert.ext.ufo.GeneralBackprojectArgs(**kwargs)
Data class holding arguments for tofu.
- exception concert.ext.ufo.GeneralBackprojectArgsError
- exception concert.ext.ufo.GeneralBackprojectError
- class concert.ext.ufo.GeneralBackprojectManager(self, args, average_normalization=True, regions=None, copy_inputs=False)
Manage 3D recnstruction by back projection. The manager stores darks, flats and projections and spreads them to back projection workers in as many batches as needed in order not to overflow GPU memory.
- args
GeneralBackprojectArgsinstance with arguments for reconstruction
- average_normalization
if False, use only one dark and flat image from their streams, otherwise average all of them
- regions
User defined regions (batches) for reconstruction, if None, batches are determined automatically
- copy_inputs
if True copy images before they are inserted into UFO
- await backproject(producer)
Backproject projections from producer.
- await find_parameters(parameters, projections=None, metrics=('sag',), regions=None, iterations=1, fwhm=0, minimize=(True,), z=None, store=True)
Find reconstruction parameters. parameters (see
GeneralBackprojectArgs.z_parameters) are the names of the parameters which should be found, projections are the input data and if not specified, the ones from last reconstruction are used. z specifies the height in which the parameter is looked for. If store is True, the found parameter values are stored in the reconstruction arguments. Optimization is done either brute-force if regions are not specified or one of the scipy minimization methods is used, see below.regions are reconstructed for the corresponding parameters and a metric from metrics list is applied. Thus, first parameter in parameters is reconstructed within the first region in regions and the first metric (see
GeneralBackprojectArgs.slice_metrics) in metrics is applied and so on. If metrics is of length 1 then it is applied to all parameters. minimize is a tuple specifying whether each parameter in the list should be minimized (True) or maximized (False). After every parameter is processed, the parameter optimization result is stored and the next parameter is optimized in such a way, that the result of the optimization of the previous parameter already takes place. iterations specifies how many times are all the parameters reconstructed. fwhm specifies the full width half maximum of the gaussian window used to filter out the low frequencies in the metric, which is useful when the region for a metric is large. If the fwhm is specified, the region must be at least 4 * fwhm large. If fwhm is 0 no filtering is done.
- property num_processed_projections
Number of projections sent to backprojectors.
- property num_received_projections
Number of received projections.
- reset()
Reset state, clearing all pre-processing steps but keep projections and slices intact.
- await update_darks(producer)
Get new darks from producer. Immediately start the reconstruction so that averaging starts.
- await update_flats(producer)
Get new flats from producer. Immediately start the reconstruction so that averaging starts.
- exception concert.ext.ufo.GeneralBackprojectManagerError
- class concert.ext.ufo.InjectProcess(graph, get_output=False, output_dims=2, scheduler=None, copy_inputs=False)
Process to inject NumPy data into a UFO processing graph.
InjectProcesscan also be used as a context manager, in which case it will callstart()on entering the manager andwait()on exiting it.graph must either be a Ufo.TaskGraph or a Ufo.TaskNode object. If it is a graph the input tasks will be connected to the roots, otherwise a new graph will be created. scheduler is one of the ufo schedulers, e.g. Ufo.Scheduler or Ufo.FixedScheduler.
- await insert(array, node=None, index=0)
Insert array into the node’s index input.
Note
array must be a NumPy compatible array.
- await result(leave_index=None)
Get result from leave_index if not None, all leaves if None. Returns a list of results in case leave_index is None or one result for the specified leave_index.
- start(arch=None, gpu=None)
Run the processing in a new thread.
Use
push()to insert data into the processing chaing andwait()to wait until processing has finished.
- stop()
Stop input tasks.
- wait()
Wait until processing has finished.
- exception concert.ext.ufo.InjectProcessError
Errors related with
InjectProcess.
- class concert.ext.ufo.LocalGeneralBackprojectArgs(**kwargs)
Viewers
Opening images in external programs.
- class concert.ext.viewers.ImageViewerBase(self, limits: str = 'stream', downsampling: int = 1, title: str = '', show_refresh_rate: bool = False, force: bool = False)
Backend-free base class for displaying images.
- limits
minimum and maximum gray value (black and white points). Can be a tuple (min, max), ‘auto’ or ‘stream’. When ‘auto’, limits are adjusted for every shown image, when ‘stream’, limits are adjusted on every __call__.
- downsampling
Display every n-th pixel, which can speed up the viewer
- title
Image title
- show_refresh_rate
Whether or not to show refresh rate text directly embedded into the displayed image
- class concert.ext.viewers.PyQtGraphViewer(self, limits: str = 'stream', downsampling: int = 1, title: str = '', show_refresh_rate: bool = False, force: bool = False)
Dynamic image viewer using PyQtGraph.
- class concert.ext.viewers.PyplotImageViewer(self, imshow_kwargs: dict = None, fast: bool = True, limits: str = 'stream', downsampling: int = 1, title: str = '', show_refresh_rate: bool = False, force: bool = False)
Dynamic image viewer using matplotlib.
- imshow_kwargs
matplotlib’s imshow keyword arguments
- fast
Whether to use the fast version without colorbar
- reset()
Reset the viewer’s state.
- class concert.ext.viewers.PyplotViewer(self, style: str = 'o', plot_kwargs: dict = None, autoscale: bool = True, title: str = '', force: bool = False)
Dynamic plot viewer using matplotlib.
- style
One of matplotlib’s linestyle format strings
- plt_kwargs
Keyword arguments accepted by matplotlib’s plot()
- autoscale
If True, the axes limits will be expanded as needed by the new data, otherwise the user needs to rescale the axes
- title
Plot title
- reset()
Clear the plotted data.
- class concert.ext.viewers.ViewerBase(self, force: bool = False, title: str = '')
A base class for data viewer which sends commands to a backend-specific updater which runs in a separate process.
- pause()
Pause, no images are dispayed but image commands work.
- resume()
Resume the viewer.
- await show(item, force=False)
Push item to the queue for display in a separate proces. If force is True make sure the item is displayed, otherwise it may be skipped if there is something in the queue waiting to be shown.
- exception concert.ext.viewers.ViewerError
Viewer errors.
- concert.ext.viewers.imagej(image, path='imagej')
Open image in ImageJ found by path.