OrsCellposeSAM_a5fcf863375311f196b8b0dcef6e1d2d

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 2025.

date:

Apr 13 2026 12:13

dragonflyVersion:

2026.1.0.2101

UUID:

a5fcf863375311f196b8b0dcef6e1d2d

Class Code

class OrsPythonPlugins.OrsCellposeSAM_a5fcf863375311f196b8b0dcef6e1d2d.OrsCellposeSAM_a5fcf863375311f196b8b0dcef6e1d2d.OrsCellposeSAM_a5fcf863375311f196b8b0dcef6e1d2d(*args, **kwargs)
applyFullDataset() → None

Execute full-dataset Cellpose segmentation.

Auto-selects 3D mode if the selected channel is volumetric (single channel, Z > 1). Otherwise runs 2D mode on the full channel data.

calculateAnisotropy(channel: Channel) → float

Calculate anisotropy ratio from channel voxel spacing.

Anisotropy = Z_spacing / XY_spacing. Used for 3D Cellpose. Returns 1.0 if spacing is zero or unavailable.

Parameters:

channel (Channel) – Input channel

Return:

Anisotropy ratio

Rtype:

float

canApplyFullDataset() → tuple[bool, str]

Whether the Apply Full Dataset action can run, and why not if it can’t.

Return:

(True, “”) if Apply Full Dataset can run; (False, tooltipMsgCode) otherwise, where tooltipMsgCode is an ORSMessages.xml “Tooltip” entry explaining the reason — used by the main form to disable/tag the button instead of popping an error dialog on click.

Rtype:

tuple

canPreview() → tuple[bool, str]

Whether the Preview action can run, and why not if it can’t.

Return:

(True, “”) if Preview can run; (False, tooltipMsgCode) otherwise, where tooltipMsgCode is an ORSMessages.xml “Tooltip” entry explaining the reason — used by the main form to disable/tag the button instead of popping an error dialog on click.

Rtype:

tuple

getInputChannelGUIDs() → list[str]

Return the list of selected input channel GUIDs.

Return:

List of channel GUIDs

Rtype:

list

getInputChannels() → list[Channel]

Resolve and return the list of selected Channel objects.

Return:

List of Channel objects

Rtype:

list

classmethod getMainFormClass()

Gets the class of the main form

Returns:

output –

getParameters() → CellposeSAM3DParameters | None

Collect all Cellpose parameters from the UI, via the main form.

Return:

Parameters gathered from the UI, or None if no form

Rtype:

CellposeSAM3DParameters or None

onCurrentViewChanged() → None

React to the active view changing — Preview’s enabled state depends on the current view being a 2D view with the selection visible in it.

openWidgetInParent(parent: QWidget, layout: QLayout) → None

Inject this plugin’s form into a parent widget/layout.

Called by OrsAISegmentationTools when building the Instance tab. Mirrors the pattern used by OrsSegmentEverything.

previewSegmentation() → None

Execute 2D slicewise Cellpose segmentation on the current view plane.

This is the “Preview” action — it extracts the visible 2D slice from the active view and runs Cellpose-SAM on that slice only. Results are published immediately.

resetToDefaults() → None

Reset all parameters to their default values, via the main form.

selectedObjectsChanged() → None

React to the Data panel’s object selection changing.

Cellpose-SAM has no per-role (Red/Green/Blue) picking of its own: the user selects 1 channel (grayscale) or 3 channels (RGB, any order — the model does not care which channel maps to which color) directly in the Data panel, and this method keeps _inputChannelGUIDs — and the mainform’s inputs table — in sync with that selection.

setInputChannelGUIDs(guids: list[str] | None) → None

Set the list of selected input channel GUIDs.

Selections wider than MAX_INPUT_CHANNELS are truncated to their first 3 GUIDs — Cellpose-SAM cannot consume more than an RGB triplet, and the channels have no fixed Red/Green/Blue roles, so any 3 of them are as meaningful as any other 3. “First 3” means first in the order the channels entered the selection, which is Data-panel row order for a range or select-all — not click order, and re-selecting a channel moves it to the end. Do not build a Red/Green/Blue role assignment on top of it; it is deterministic and stable across repeated calls, but it is not the order the user clicked in. The pre-truncation count is forwarded to the main form so its hint label can say that the extra channels were dropped.

Parameters:

guids (list) – List of channel GUIDs