Processor#

The cdl.core.gui.processor package provides the processor objects for signals and images.

Processor objects are the bridge between the computation modules (in cdl.computation) and the GUI modules (in cdl.core.gui). They are used to call the computation functions and to update the GUI from inside the data panel objects.

When implementing a processing feature in DataLab, the steps are usually the following:

  • Add an action in the cdl.core.gui.actionhandler module to trigger the processing feature from the GUI (e.g. a menu item or a toolbar button).

  • Implement the computation function in the cdl.computation module (that would eventually call the algorithm from the cdl.algorithms module).

  • Implement the processor object method in this package to call the computation function and eventually update the GUI.

The processor objects are organized in submodules according to their purpose.

The following submodules are available:

Common features#

class cdl.core.gui.processor.base.Worker#

Multiprocessing worker, to run long-running tasks in a separate process

static create_pool() None#

Create multiprocessing pool

static terminate_pool(wait: bool = False) None#

Terminate multiprocessing pool.

Parameters:

wait – wait for all tasks to finish. Defaults to False.

restart_pool() None#

Terminate and recreate the pool

run(func: Callable, args: tuple[Any]) None#

Run computation.

Parameters:
  • func – function to run

  • args – arguments

close() None#

Close worker: close pool properly and wait for all tasks to finish

is_computation_finished() bool#

Return True if computation is finished.

Returns:

True if computation is finished

Return type:

bool

get_result() CompOut#

Return computation result.

Returns:

computation result

Return type:

CompOut

class cdl.core.gui.processor.base.BaseProcessor(panel: SignalPanel | ImagePanel, plotwidget: PlotWidget)#

Object handling data processing: operations, processing, computing.

Parameters:
  • panel – panel

  • plotwidget – plot widget

close()#

Close processor properly

set_process_isolation_enabled(enabled: bool) None#

Set process isolation enabled.

Parameters:

enabled – enabled

has_param_defaults(paramclass: type[DataSet]) bool#

Return True if parameter defaults are available.

Parameters:

paramclass – parameter class

Returns:

True if parameter defaults are available

Return type:

bool

update_param_defaults(param: DataSet) None#

Update parameter defaults.

Parameters:

param – parameters

init_param(param: DataSet, paramclass: type[DataSet], title: str, comment: str | None = None) tuple[bool, DataSet]#

Initialize processing parameters.

Parameters:
  • param – parameter

  • paramclass – parameter class

  • title – title

  • comment – comment

Returns:

Tuple (edit, param) where edit is True if parameters have been edited, False otherwise.

compute_11(func: Callable, param: DataSet | None = None, paramclass: DataSet | None = None, title: str | None = None, comment: str | None = None, edit: bool | None = None) None#

Compute 11 function: 1 object in β†’ 1 object out.

Parameters:
  • func – function

  • param – parameter

  • paramclass – parameter class

  • title – title

  • comment – comment

  • edit – edit parameters

compute_1n(funcs: list[Callable] | Callable, params: list | None = None, title: str | None = None, edit: bool | None = None) None#

Compute 1n function: 1 object in β†’ n objects out.

Parameters:
  • funcs – list of functions

  • params – list of parameters

  • title – title

  • edit – edit parameters

handle_output(compout: CompOut, context: str, progress: QW.QProgressDialog) SignalObj | ImageObj | ResultShape | ResultProperties | None#

Handle computation output: if error, display error message, if warning, display warning message.

Parameters:
  • compout – computation output

  • context – context (e.g. β€œComputing: Gaussian filter”)

  • progress – progress dialog

Returns:

a signal or image object, or a result shape object,

or None if error

Return type:

Output object

compute_10(func: Callable, param: DataSet | None = None, paramclass: DataSet | None = None, title: str | None = None, comment: str | None = None, edit: bool | None = None) dict[str, ResultShape | ResultProperties]#

Compute 10 function: 1 object in β†’ 0 object out (the result of this method is stored in original object’s metadata).

Parameters:
  • func – function to execute

  • param – parameters. Defaults to None.

  • paramclass – parameters class. Defaults to None.

  • title – title of progress bar. Defaults to None.

  • comment – comment. Defaults to None.

  • edit – if True, edit parameters. Defaults to None.

Returns:

object uuid, values: ResultShape or

ResultProperties objects)

Return type:

Dictionary of results (keys

compute_n1(name: str, func: Callable, param: DataSet | None = None, paramclass: DataSet | None = None, title: str | None = None, comment: str | None = None, func_objs: Callable | None = None, edit: bool | None = None) None#

Compute n1 function: N(>=2) objects in β†’ 1 object out.

Parameters:
  • name – name of function

  • func – function to execute

  • param – parameters. Defaults to None.

  • paramclass – parameters class. Defaults to None.

  • title – title of progress bar. Defaults to None.

  • comment – comment. Defaults to None.

  • func_objs – function to execute on objects. Defaults to None.

  • edit – if True, edit parameters. Defaults to None.

compute_n1n(obj2: Obj | None, obj2_name: str, func: Callable, param: gds.DataSet | None = None, paramclass: gds.DataSet | None = None, title: str | None = None, comment: str | None = None, edit: bool | None = None) None#

Compute n1n function: N(>=1) objects + 1 object in β†’ N objects out.

Examples: subtract, divide

Parameters:
  • obj2 – second object

  • obj2_name – name of second object

  • func – function to execute

  • param – parameters. Defaults to None.

  • paramclass – parameters class. Defaults to None.

  • title – title of progress bar. Defaults to None.

  • comment – comment. Defaults to None.

  • edit – if True, edit parameters. Defaults to None.

abstract compute_sum() None#

Compute sum

abstract compute_normalize(param: NormalizeParam | None = None) None#

Normalize data

abstract compute_average() None#

Compute average

abstract compute_product() None#

Compute product

abstract compute_difference(obj2: Obj | None = None) None#

Compute difference

abstract compute_quadratic_difference(obj2: Obj | None = None) None#

Compute quadratic difference

abstract compute_division(obj2: Obj | None = None) None#

Compute division

abstract compute_roi_extraction(param=None) None#

Extract Region Of Interest (ROI) from data

abstract compute_swap_axes() None#

Swap data axes

abstract compute_abs() None#

Compute absolute value

abstract compute_re() None#

Compute real part

abstract compute_im() None#

Compute imaginary part

abstract compute_astype() None#

Convert data type

abstract compute_log10() None#

Compute Log10

abstract compute_exp() None#

Compute exponential

abstract compute_calibration(param=None) None#

Compute data linear calibration

abstract compute_clip(param: ClipParam | None = None) None#

Compute maximum data clipping

abstract compute_gaussian_filter(param: GaussianParam | None = None) None#

Compute gaussian filter

abstract compute_moving_average(param: MovingAverageParam | None = None) None#

Compute moving average

abstract compute_moving_median(param: MovingMedianParam | None = None) None#

Compute moving median

abstract compute_wiener() None#

Compute Wiener filter

abstract compute_fft() None#

Compute iFFT

abstract compute_ifft() None#

Compute FFT

abstract compute_addition_constant(param: ConstantOperationParam) None#

Compute sum with a constant

abstract compute_difference_constant(param: ConstantOperationParam) None#

Compute difference with a constant

abstract compute_product_constant(param: ConstantOperationParam) None#

Compute product with a constant

abstract compute_division_constant(param: ConstantOperationParam) None#

Compute division by a constant

edit_regions_of_interest(extract: bool = False, singleobj: bool | None = None, add_roi: bool = False) ROIDataParam | None#

Define Region Of Interest (ROI) for computing functions.

Parameters:
  • extract – If True, ROI is extracted from data. Defaults to False.

  • singleobj – If True, ROI is extracted from first selected object only. If False, ROI is extracted from all selected objects. If None, ROI is extracted from all selected objects only if they all have the same ROI. Defaults to None.

  • add_roi – If True, add ROI to data immediately after opening the ROI editor. Defaults to False.

Returns:

ROI data parameters or None if ROI dialog has been canceled.

delete_regions_of_interest() None#

Delete Regions Of Interest

abstract compute_stats() dict[str, ResultShape]#

Compute data statistics

Signal processing features#

class cdl.core.gui.processor.signal.SignalProcessor(panel: SignalPanel | ImagePanel, plotwidget: PlotWidget)#

Object handling signal processing: operations, processing, computing

compute_sum() None#

Compute sum

compute_addition_constant(param: ConstantOperationParam | None = None) None#

Compute sum with a constant

compute_average() None#

Compute average

compute_product() None#

Compute product

compute_product_constant(param: ConstantOperationParam | None = None) None#

Compute product with a constant

compute_roi_extraction(param: ROIDataParam | None = None) None#

Extract Region Of Interest (ROI) from data

compute_swap_axes() None#

Swap data axes

compute_abs() None#

Compute absolute value

compute_re() None#

Compute real part

compute_im() None#

Compute imaginary part

compute_astype(param: DataTypeSParam | None = None) None#

Convert data type

compute_log10() None#

Compute Log10

compute_exp() None#

Compute Log10

compute_sqrt() None#

Compute square root

compute_power(param: PowerParam | None = None) None#

Compute power

compute_difference(obj2: SignalObj | None = None) None#

Compute difference between two signals

compute_difference_constant(param: ConstantOperationParam | None = None) None#

Compute difference with a constant

compute_quadratic_difference(obj2: SignalObj | None = None) None#

Compute quadratic difference between two signals

compute_division(obj2: SignalObj | None = None) None#

Compute division between two signals

compute_division_constant(param: ConstantOperationParam | None = None) None#

Compute division by a constant

compute_peak_detection(param: PeakDetectionParam | None = None) None#

Detect peaks from data

compute_reverse_x() None#

Reverse X axis

compute_normalize(param: NormalizeParam | None = None) None#

Normalize data

compute_derivative() None#

Compute derivative

compute_integral() None#

Compute integral

compute_calibration(param: XYCalibrateParam | None = None) None#

Compute data linear calibration

compute_clip(param: ClipParam | None = None) None#

Compute maximum data clipping

compute_offset_correction(param: ROI1DParam | None = None) None#

Compute offset correction

compute_gaussian_filter(param: GaussianParam | None = None) None#

Compute gaussian filter

compute_moving_average(param: MovingAverageParam | None = None) None#

Compute moving average

compute_moving_median(param: MovingMedianParam | None = None) None#

Compute moving median

compute_wiener() None#

Compute Wiener filter

compute_lowpass(param: LowPassFilterParam | None = None) None#

Compute high-pass filter

compute_highpass(param: HighPassFilterParam | None = None) None#

Compute high-pass filter

compute_bandpass(param: BandPassFilterParam | None = None) None#

Compute band-pass filter

compute_bandstop(param: BandStopFilterParam | None = None) None#

Compute band-stop filter

compute_fft(param: FFTParam | None = None) None#

Compute iFFT

compute_ifft(param: FFTParam | None = None) None#

Compute FFT

compute_magnitude_spectrum(param: SpectrumParam | None = None) None#

Compute magnitude spectrum

compute_phase_spectrum() None#

Compute phase spectrum

compute_psd(param: SpectrumParam | None = None) None#

Compute power spectral density

compute_interpolation(obj2: SignalObj | None = None, param: InterpolationParam | None = None)#

Compute interpolation

compute_resampling(param: ResamplingParam | None = None)#

Compute resampling

compute_detrending(param: DetrendingParam | None = None)#

Compute detrending

compute_convolution(obj2: SignalObj | None = None) None#

Compute convolution

compute_windowing(param: WindowingParam | None = None) None#

Compute windowing

compute_fit(name, fitdlgfunc)#

Compute fitting curve

compute_polyfit(param: PolynomialFitParam | None = None) None#

Compute polynomial fitting curve

compute_multigaussianfit() None#

Compute multi-Gaussian fitting curve

compute_fwhm(param: FWHMParam | None = None) dict[str, ResultShape]#

Compute FWHM

compute_fw1e2() dict[str, ResultShape]#

Compute FW at 1/eΒ²

compute_stats() dict[str, ResultProperties]#

Compute data statistics

compute_histogram(param: HistogramParam | None = None) dict[str, ResultShape]#

Compute histogram

compute_contrast() dict[str, ResultProperties]#

Compute contrast

compute_x_at_minmax() dict[str, ResultProperties]#

Compute x at min/max

compute_sampling_rate_period() dict[str, ResultProperties]#

Compute sampling rate and period (mean and std)

compute_bandwidth_3db() None#

Compute bandwidth

compute_dynamic_parameters(param: DynamicParam | None = None) dict[str, ResultProperties]#

Compute Dynamic Parameters (ENOB, SINAD, THD, SFDR, SNR)

Image processing features#

class cdl.core.gui.processor.image.ImageProcessor(panel: SignalPanel | ImagePanel, plotwidget: PlotWidget)#

Object handling image processing: operations, processing, computing

compute_normalize(param: NormalizeParam | None = None) None#

Normalize data

compute_sum() None#

Compute sum

compute_addition_constant(param: ConstantOperationParam | None = None) None#

Compute sum with a constant

compute_average() None#

Compute average

compute_product() None#

Compute product

compute_product_constant(param: ConstantOperationParam | None = None) None#

Compute product with a constant

compute_logp1(param: LogP1Param | None = None) None#

Compute base 10 logarithm

compute_rotate(param: RotateParam | None = None) None#

Rotate data arbitrarily

compute_rotate90() None#

Rotate data 90Β°

compute_rotate270() None#

Rotate data 270Β°

compute_fliph() None#

Flip data horizontally

compute_flipv() None#

Flip data vertically

distribute_on_grid(param: GridParam | None = None) None#

Distribute images on a grid

reset_positions() None#

Reset image positions

compute_resize(param: ResizeParam | None = None) None#

Resize image

compute_binning(param: BinningParam | None = None) None#

Binning image

compute_roi_extraction(param: ROIDataParam | None = None) None#

Extract Region Of Interest (ROI) from data

compute_line_profile(param: LineProfileParam | None = None) None#

Compute profile along a vertical or horizontal line

compute_segment_profile(param: SegmentProfileParam | None = None)#

Compute profile along a segment

compute_average_profile(param: AverageProfileParam | None = None) None#

Compute average profile

compute_radial_profile(param: RadialProfileParam | None = None) None#

Compute radial profile

compute_histogram(param: HistogramParam | None = None) None#

Compute histogram

compute_swap_axes() None#

Swap data axes

compute_abs() None#

Compute absolute value

compute_re() None#

Compute real part

compute_im() None#

Compute imaginary part

compute_astype(param: DataTypeIParam | None = None) None#

Convert data type

compute_log10() None#

Compute Log10

compute_exp() None#

Compute Log10

compute_difference(obj2: ImageObj | None = None) None#

Compute difference between two images

compute_difference_constant(param: ConstantOperationParam | None = None) None#

Compute difference with a constant

compute_quadratic_difference(obj2: ImageObj | None = None) None#

Compute quadratic difference between two images

compute_division(obj2: ImageObj | None = None) None#

Compute division between two images

compute_division_constant(param: ConstantOperationParam | None = None) None#

Compute division by a constant

compute_flatfield(obj2: ImageObj | None = None, param: FlatFieldParam | None = None) None#

Compute flat field correction

compute_calibration(param: ZCalibrateParam | None = None) None#

Compute data linear calibration

compute_clip(param: ClipParam | None = None) None#

Compute maximum data clipping

compute_offset_correction(param: ROI2DParam | None = None) None#

Compute offset correction

compute_gaussian_filter(param: GaussianParam | None = None) None#

Compute gaussian filter

compute_moving_average(param: MovingAverageParam | None = None) None#

Compute moving average

compute_moving_median(param: MovingMedianParam | None = None) None#

Compute moving median

compute_wiener() None#

Compute Wiener filter

compute_fft(param: FFTParam | None = None) None#

Compute FFT

compute_ifft(param: FFTParam | None = None) None#

Compute iFFT

compute_magnitude_spectrum(param: SpectrumParam | None = None) None#

Compute magnitude spectrum

compute_phase_spectrum() None#

Compute phase spectrum

compute_psd(param: SpectrumParam | None = None) None#

Compute Power Spectral Density (PSD)

compute_butterworth(param: ButterworthParam | None = None) None#

Compute Butterworth filter

compute_threshold(param: ThresholdParam | None = None) None#

Compute parametric threshold

compute_threshold_isodata() None#

Compute threshold using Isodata algorithm

compute_threshold_li() None#

Compute threshold using Li algorithm

compute_threshold_mean() None#

Compute threshold using Mean algorithm

compute_threshold_minimum() None#

Compute threshold using Minimum algorithm

compute_threshold_otsu() None#

Compute threshold using Otsu algorithm

compute_threshold_triangle() None#

Compute threshold using Triangle algorithm

compute_threshold_yen() None#

Compute threshold using Yen algorithm

compute_all_threshold() None#

Compute all threshold algorithms

compute_adjust_gamma(param: AdjustGammaParam | None = None) None#

Compute gamma correction

compute_adjust_log(param: AdjustLogParam | None = None) None#

Compute log correction

compute_adjust_sigmoid(param: AdjustSigmoidParam | None = None) None#

Compute sigmoid correction

compute_rescale_intensity(param: RescaleIntensityParam | None = None) None#

Rescale image intensity levels

compute_equalize_hist(param: EqualizeHistParam | None = None) None#

Histogram equalization

compute_equalize_adapthist(param: EqualizeAdaptHistParam | None = None) None#

Adaptive histogram equalization

compute_denoise_tv(param: DenoiseTVParam | None = None) None#

Compute Total Variation denoising

compute_denoise_bilateral(param: DenoiseBilateralParam | None = None) None#

Compute bilateral filter denoising

compute_denoise_wavelet(param: DenoiseWaveletParam | None = None) None#

Compute Wavelet denoising

compute_denoise_tophat(param: MorphologyParam | None = None) None#

Denoise using White Top-Hat

compute_all_denoise(params: list | None = None) None#

Compute all denoising filters

compute_white_tophat(param: MorphologyParam | None = None) None#

Compute White Top-Hat

compute_black_tophat(param: MorphologyParam | None = None) None#

Compute Black Top-Hat

compute_erosion(param: MorphologyParam | None = None) None#

Compute Erosion

compute_dilation(param: MorphologyParam | None = None) None#

Compute Dilation

compute_opening(param: MorphologyParam | None = None) None#

Compute morphological opening

compute_closing(param: MorphologyParam | None = None) None#

Compute morphological closing

compute_all_morphology(param: MorphologyParam | None = None) None#

Compute all morphology filters

compute_canny(param: CannyParam | None = None) None#

Compute Canny filter

compute_roberts() None#

Compute Roberts filter

compute_prewitt() None#

Compute Prewitt filter

compute_prewitt_h() None#

Compute Prewitt filter (horizontal)

compute_prewitt_v() None#

Compute Prewitt filter (vertical)

compute_sobel() None#

Compute Sobel filter

compute_sobel_h() None#

Compute Sobel filter (horizontal)

compute_sobel_v() None#

Compute Sobel filter (vertical)

compute_scharr() None#

Compute Scharr filter

compute_scharr_h() None#

Compute Scharr filter (horizontal)

compute_scharr_v() None#

Compute Scharr filter (vertical)

compute_farid() None#

Compute Farid filter

compute_farid_h() None#

Compute Farid filter (horizontal)

compute_farid_v() None#

Compute Farid filter (vertical)

compute_laplace() None#

Compute Laplace filter

compute_all_edges() None#

Compute all edges

compute_stats() dict[str, ResultProperties]#

Compute data statistics

compute_centroid() dict[str, ResultShape]#

Compute image centroid

compute_enclosing_circle() dict[str, ResultShape]#

Compute minimum enclosing circle

compute_peak_detection(param: Peak2DDetectionParam | None = None) dict[str, ResultShape]#

Compute 2D peak detection

compute_contour_shape(param: ContourShapeParam | None = None) dict[str, ResultShape]#

Compute contour shape fit

compute_hough_circle_peaks(param: HoughCircleParam | None = None) dict[str, ResultShape]#

Compute peak detection based on a circle Hough transform

compute_blob_dog(param: BlobDOGParam | None = None) dict[str, ResultShape]#

Compute blob detection using Difference of Gaussian method

compute_blob_doh(param: BlobDOHParam | None = None) dict[str, ResultShape]#

Compute blob detection using Determinant of Hessian method

compute_blob_log(param: BlobLOGParam | None = None) dict[str, ResultShape]#

Compute blob detection using Laplacian of Gaussian method

compute_blob_opencv(param: BlobOpenCVParam | None = None) dict[str, ResultShape]#

Compute blob detection using OpenCV