PartSeg.common_backend package

Module contents

This module contains non gui Qt based components

PartSeg.common_backend.napari_get_settings(path=None)[source]
Return type:

NapariSettings

Submodules

PartSeg.common_backend.abstract_class module

class PartSeg.common_backend.abstract_class.QtMeta(name, bases, namespace, /, **kwargs)[source]

Bases: wrappertype, ABCMeta

Class to solve metaclass conflict for multiple inheritance:

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclass of all its bases

>>> class A:
...    pass
...
>>> class Test(QObject, A, metaclass=QtMeta):
...    pass

PartSeg.common_backend.base_argparser module

class PartSeg.common_backend.base_argparser.CustomParser(*args, **kwargs)[source]

Bases: ArgumentParser

Argument parser with set of predefined flags:

  1. --no_report - disable error reporting, still showing dialog with information. Set state_store.report_errors.

  2. --no_dialog - disable error reporting and showing dialog. Exceptions will be printed on stderr. Set state_store.show_error_dialog.

  3. --no_update - disable check for updates on application startup

    Set state_store.check_for_updates.

  4. --save_suffix - add special suffix to directory contains saved state. designed to allow separate projects.

    Set state_store.save_suffix.

  5. --save_directory - set custom save directory. default can be previewed in Help > State directory

    from PartSeg main menu, Set state_store.save_folder.

  6. --inner_plugins - designed to hide part plugin from default start.

    Set state_store.custom_plugin_load.

  7. --develop – for developer purpose. Allow to reload part of Program without restarting. May be unstable.

    Set state_store.develop. Base on this PartSeg.common_gui.advanced_tabs.AdvancedWindow constructor add developer tab.

parse_args(args=None, namespace=None)[source]

overload of argparse.ArgumentParser.parse_args(). Set flags like described in class documentation.

PartSeg.common_backend.base_argparser.proper_path(val)[source]

Check if val is proper path in current system

Raises:

argparse.ArgumentTypeError – on validation error

PartSeg.common_backend.base_argparser.proper_suffix(val)[source]

check if val contains only alphanumeric characters

Raises:

argparse.ArgumentTypeError – on validation error

PartSeg.common_backend.base_settings module

PartSeg.common_backend.except_hook module

PartSeg.common_backend.except_hook.my_excepthook(type_, value, trace_back)[source]

Custom excepthook. Close application on KeyboardInterrupt.

If PartSeg.state_store.always_report is set then just sent report using sentry. otherwise show dialog with information about error and ask user if he wants to send report using show_error().

PartSeg.common_backend.except_hook.show_error(error=None)[source]

For SegmentationLimitException and TiffFileException show dialog with information about problem.

For other exceptions show ErrorDialog dialog with information about error that allow to report it.

Parameters:

error – exception to show

PartSeg.common_backend.except_hook.show_warning(header=None, text=None, exception=None)[source]

Show warning QMessageBox

This function is to ensure creation warning dialog in main thread.

PartSeg.common_backend.load_backup module

PartSeg.common_backend.load_backup.import_config()[source]

Check if settings folder for current version already exists.

Otherwise, when settings for previous PartSeg version exists, ask user if he would to import settings from the newest one.

PartSeg.common_backend.partially_const_dict module

class PartSeg.common_backend.partially_const_dict.PartiallyConstDict(editable_items)[source]

Base class for creating dict to mixin predefined and user defined variables.

const_item_dict: ClassVar[Dict[str, Any]] = {}

Dict with non removable elements

get_position(key)[source]

Get item position as unique int. For sorting purpose

Raises:

KeyError – if element not in dict

Return type:

int

item_added(object)

Signal with item added to dict

item_removed(object)

Signal with item remove from dict

PartSeg.common_backend.progress_thread module

class PartSeg.common_backend.progress_thread.ExecuteFunctionThread(fun, args=None, kwargs=None)[source]

Bases: ProgressTread

Generic Thread to execute

run(self)[source]
class PartSeg.common_backend.progress_thread.ProgressTread[source]

Bases: QThread

error_signal(Exception)

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

info_function(label, val)[source]
range_changed(int, int)

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

step_changed(int)

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

PartSeg.common_backend.segmentation_thread module

class PartSeg.common_backend.segmentation_thread.SegmentationThread(algorithm)[source]

Bases: QThread

Method to run calculation task in separated Thread. This allows to not freeze main window. To get info if calculation is done connect to finished.

clean()[source]

clean cache if thread is running. Call SegmentationAlgorithm.clean() otherwise. :

exception_occurred(Exception)

Signal emitted when some exception occur during calculation.

execution_done(ROIExtractionResult)

Signal contains result of segmentation algorithm. Emitted if calculation ends without exception and SegmentationAlgorithm.calculation_run() return not None result.

finished_task()[source]

Called on calculation finished. Check if cache is not empty. In such case start calculation again with new parameters.

get_info_text()[source]

Proxy for SegmentationAlgorithm.get_info_text().

progress_signal(str, int)

Signal with information about progress. This is proxy for SegmentationAlgorithm.calculation_run() report_fun parameter`

run()[source]

the calculation are done here

set_image(image)[source]

check if calculation is running. If yes then cache parameters until it finish, otherwise call SegmentationAlgorithm.set_image() :type image: :param image: image to be set

set_mask(mask)[source]

check if calculation is running. If yes then cache parameters until it finish, otherwise call SegmentationAlgorithm.set_mask() :type mask: :param mask: mask to be set

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

check if calculation is running. If yes then cache parameters until it finish, otherwise call SegmentationAlgorithm.set_parameters()

start(priority=7)[source]

If calculation is running remember to restart it with new parameters.

Otherwise start immediately.