InstanceLabeler_ff91790a673011ebb3c74ccc6ab1221c

InstanceLabeler Plugin

This plugin provides functionality for classifying objects in images. It allows users to: - Create and manage classification labels - Assign labels to objects in images - Navigate through labeled instances

author:

Dragonfly Team

contact:

https://dragonfly.comet.tech

email:

support.dragonfly@comet.tech

organization:

Comet Technologies Canada Inc.

address:

460 Ste-Catherine Ouest, suite 600, Montréal, Québec, Canada, H3B 1A7

copyright:

Comet Technologies Canada Inc. All rights reserved 2023.

date:

Feb 04 2021 16:36

dragonflyVersion:

2021.1.0.972 (D)

UUID:

ff91790a673011ebb3c74ccc6ab1221c

Class Code

class OrsPythonPlugins.InstanceLabeler_ff91790a673011ebb3c74ccc6ab1221c.InstanceLabeler_ff91790a673011ebb3c74ccc6ab1221c.InstanceLabeler_ff91790a673011ebb3c74ccc6ab1221c(*args, **kwargs)

Main plugin class for the Instance Labeler functionality.

This plugin allows users to classify objects in images by assigning labels to regions of interest (ROIs) in a MultiROI object.

addDisplayCallback() → None

Add a callback for display view mode changes.

This callback updates the MultiROI visibility when the view mode changes.

addLayoutChangeCallback() → None

Add a callback for layout changes.

This callback updates the MultiROI visibility and adjusts the view when the layout changes.

addNewMultiROISlot(slotName: str) → int | None

Add a new scalar value slot to the MultiROI.

Args:

slotName: The name of the new slot

Returns:

The index of the new slot or None if the MultiROI is None

cleanup() → None

Clean up resources used by this plugin.

This method is called when the plugin is being destroyed.

createLabeledMultiROIFromLabels() → MultiROI | None

Create a new MultiROI labeled with the scalar value labelization.

This method creates a new MultiROI with the same dimensions as the current one, and copies the labels from the current MultiROI to the new one.

fitViewAndLookAtROI() → None

Fit the view to the current ROI and look at it.

This method adjusts the view to focus on the current label’s ROI. If there is no current label, it resets the view to show the full MultiROI.

getChannel() → Channel | None

Get the current Channel object.

Returns:

The Channel object or None if not set

getClassColor(idx: int) → str

Get the color of the specified class.

Args:

idx: The index of the class

Returns:

The color of the class as a string, or an empty string if the class doesn’t exist

getClassCount() → int

Get the number of classes defined for the current scalar value slot.

Returns:

The number of classes, or 0 if no classes are defined

getClassName(idx: int) → str

Get the name of the specified class.

Args:

idx: The index of the class

Returns:

The name of the class as a string, or an empty string if the class doesn’t exist

classmethod getContextName() → str

Get the context name for this plugin.

Returns:

The context name string

getCurrentLabel() → int

Get the current label.

Returns:

The current label or -1 if there is no current label

getCurrentLabelIndex() → int

Get the current label index.

Returns:

The current label index

getCurrentScalarValueSlotIndex() → int

Get the current scalar value slot index.

Returns:

The current scalar value slot index

getLegend(forceCreation: bool = True) → VisualLegend | None

Get the legend for the current scalar value slot.

If the legend doesn’t exist and forceCreation is True, a new legend will be created.

Args:

forceCreation: Whether to create a new legend if it doesn’t exist

Returns:

The VisualLegend object or None if it doesn’t exist and forceCreation is False

classmethod getMainFormClass() → Any

Get the main form class for this plugin.

Returns:

The MainForm class

getMultiROI() → MultiROI | None

Get the current MultiROI object.

Returns:

The MultiROI object or None if not set

getMultiROISlotCount() → int

Get the number of scalar value slots defined for the MultiROI.

Returns:

The number of scalar value slots

getMultiROISlots() → Dict[int, str]

Get a dictionary of scalar value slots and their descriptions.

Returns:

A dictionary mapping slot indices to their descriptions

loadClassificationMetadata() → bool

Load classification metadata from the MultiROI user info.

Returns:

True if metadata was loaded successfully, False otherwise

loadClassificationMetadataFromFile(filename: str) → bool

Load classification metadata from a file.

Args:

filename: The path to the file to load metadata from

Returns:

True if metadata was loaded successfully, False otherwise

lookAtROI(label: int) → None

Adjust the 3D view to look at the specified ROI.

This method adjusts the 3D view to focus on the specified label’s ROI.

Args:

label: The label to look at

classmethod openInstanceLabelerContext(listSelectedObjectsRepr: str) → Menu | None

Create a menu item for opening the Instance Labeler context.

This method is called when the user right-clicks on selected objects in the Dragonfly interface. It checks if the selection is valid for opening the Instance Labeler context (one Channel and one MultiROI) and returns a menu item if it is.

Args:

listSelectedObjectsRepr: A string representation of the list of selected object GUIDs

Returns:

A Menu item if the selection is valid, None otherwise

saveClassificationMetadata() → bool

Save classification metadata to the MultiROI user info.

Returns:

True if metadata was saved successfully, False otherwise

saveClassificationMetadataToFile(filename: str) → None

Save classification metadata to a file.

Args:

filename: The path to the file to save metadata to

selectMultiROISlot(slotIndex: int) → None

Select a scalar value slot in the MultiROI.

This method sets the current scalar value slot and updates the colors.

Args:

slotIndex: The index of the slot to select

sendObjectToClassEightAction() → Action

Create an action to move the current object to class 8

sendObjectToClassFiveAction() → Action

Create an action to move the current object to class 5

sendObjectToClassFourAction() → Action

Create an action to move the current object to class 4

sendObjectToClassNineAction() → Action

Create an action to move the current object to class 9

sendObjectToClassOneAction() → Action

Create an action to move the current object to class 1

sendObjectToClassSevenAction() → Action

Create an action to move the current object to class 7

sendObjectToClassSixAction() → Action

Create an action to move the current object to class 6

sendObjectToClassThreeAction() → Action

Create an action to move the current object to class 3

sendObjectToClassTwoAction() → Action

Create an action to move the current object to class 2

setChannel(channel: Channel | None) → None

Set the Channel object to be used for classification.

Args:

channel: The Channel object

setClassColor(idx: int, color: str, save: bool = True) → None

Set the color of the specified class.

Args:

idx: The index of the class color: The color to set save: Whether to save the classification metadata after setting the color

setClassName(idx: int, name: str, save: bool = True) → None

Set the name of the specified class.

Args:

idx: The index of the class name: The name to set save: Whether to save the classification metadata after setting the name

setCurrentLabelIndexOffset(currentLabelIndexOffset: int) → None

Set the current label index by applying an offset to the current index.

Args:

currentLabelIndexOffset: The offset to apply to the current label index

setLabelListSorting(sorting: int) → None

Set the sorting method for the label list.

Args:

sorting: The sorting method to use (SORTING_NORMAL, SORTING_RANDOM, SORTING_REVERSE, or SORTING_SPATIAL)

setMetadataDict(metadataDict: Dict[str, Any], createScalars: bool = False) → None

Set the classification metadata from a dictionary.

This method updates the plugin’s state with the provided metadata. If createScalars is True, it will create new scalar value slots in the MultiROI based on the metadata.

Args:

metadataDict: The metadata dictionary createScalars: Whether to create scalar value slots in the MultiROI

setMultiROI(multiROI: MultiROI | None) → None

Set the MultiROI object to be used for classification.

Args:

multiROI: The MultiROI object

setupContext(openMainForm: bool = True) → None

Set up the context for this plugin.

This method initializes the plugin context by instantiating context plugins, allowing context plugins, and opening the main form.

Args:

openMainForm: Whether to open the main form

classmethod startInstanceLabelerFromSelection(multiROI: MultiROI, channel: Channel, openMainForm: bool = True) → InstanceLabeler_ff91790a673011ebb3c74ccc6ab1221c

Start the Instance Labeler from a selection of MultiROI and Channel.

This class method creates a new instance of the Instance Labeler plugin and sets it up with the specified MultiROI and Channel.

Args:

multiROI: The MultiROI object to use channel: The Channel object to use openMainForm: Whether to open the main form

Returns:

A new instance of the Instance Labeler plugin

updateLUT() → None

Update the lookup table (LUT) for the current scalar value slot.

This method updates the legend’s lookup table with the current class colors.

updateMultiROIColors(numberOfColor: int = 10) → None

Update the colors of the MultiROI based on the current scalar values.

This method maps the scalar values to discrete colors using the legend’s lookup table.

Args:

numberOfColor: The number of colors to use

updateMultiROIVisibility() → None

Update the visibility of the MultiROI in all views.

This method sets the visibility of the MultiROI in 2D and 3D views based on the current visibility settings.