straditize.widgets.pattern_selection module

A wdiget to select patterns in the image

The PatternSelectionWidget is used by the straditize.widget.selection_toolbar.SelectionToolbar to select patterns in the straditizer image

Disclaimer

Copyright (C) 2018-2019 Philipp S. Sommer

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Classes

EmbededMplCanvas([parent])

Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).

PatternSelectionWidget(arr, data_obj[, …])

A wdiget to select patterns in the image

class straditize.widgets.pattern_selection.EmbededMplCanvas(parent=None, *args, **kwargs)[source]

Bases: matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg

Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.).

class straditize.widgets.pattern_selection.PatternSelectionWidget(arr, data_obj, remove_selection=False, *args, **kwargs)[source]

Bases: PyQt5.QtWidgets.QWidget, psyplot_gui.common.DockMixin

A wdiget to select patterns in the image

This widget consist of an EmbededMplCanvas to display the template for the pattern and uses the skimage.feature.match_template() function to identify it in the arr

See also

straditize.widget.selection_toolbar.SelectionToolbar.start_pattern_selection

Attributes

selector

The selector to select the template in the original image

sl_thresh

A QSlider to set the threshold for the template correlation

template

The template to look for in the arr

template_extents

The extents of the template in the original image

template_fig

The EmbededMplCanvas to display the template

template_im

The matplotlib artist of the template in the

Methods

cancel()

correlate_template(arr, template[, …])

Correlate a template with the arr

maybe_tabify()

modify_selection(i)

Modify the selection based on the correlation threshold

remove_plugin()

Remove this plugin and close it

start_correlation()

Look for the correlations of template and source

to_dock(main[, title, position, docktype])

toggle_correlation_plot()

Toggle the correlation plot between template and arr

toggle_selection()

Modifiy the selection (or not) based on the template correlation

toggle_template_selection()

Enable or disable the template selection

update_image(*args, **kwargs)

Update the template image based on the selector extents

Parameters
  • arr (np.ndarray of shape (Ny, Nx)) – The labeled selection array

  • data_obj (straditize.label_selection.LabelSelection) – The data object whose image shall be selected

  • remove_selection (bool) – If True, remove the selection on apply

axes = None
cancel()[source]
correlate_template(arr, template, fraction=False, increment=1, report=True)[source]

Correlate a template with the arr

This method uses the skimage.feature.match_template() function to find the given template in the source array arr.

Parameters
  • arr (np.ndarray of shape (Ny,Nx)) – The labeled selection array (see arr), the source of the given template

  • template (np.ndarray of shape (nx, ny)) – The template from arr that shall be searched

  • fraction (float) – If not null, we will look through the given fraction of the template to look for partial matches as well

  • increment (int) – The increment of the loop with the fraction.

  • report (bool) – If True and fraction is not null, a QProgressDialog is opened to inform the user about the progress

key_press_cid = None
maybe_tabify()[source]
modify_selection(i)[source]

Modify the selection based on the correlation threshold

Parameters

i (int) – An integer between 0 and 100, the value of the sl_thresh slider

remove_plugin()[source]

Remove this plugin and close it

selector = None

The selector to select the template in the original image

sl_thresh = None

A QSlider to set the threshold for the template correlation

start_correlation()[source]

Look for the correlations of template and source

template = None

The template to look for in the arr

template_extents = None

The extents of the template in the original image

template_fig = None

The EmbededMplCanvas to display the template

template_im = None

The matplotlib artist of the template in the template_fig

to_dock(main, title=None, position=None, docktype='df', *args, **kwargs)[source]
toggle_correlation_plot()[source]

Toggle the correlation plot between template and arr

toggle_selection()[source]

Modifiy the selection (or not) based on the template correlation

toggle_template_selection()[source]

Enable or disable the template selection

update_image(*args, **kwargs)[source]

Update the template image based on the selector extents