spacr.qt.screens.mask

The modules folded onto Mask Generation: Timelapse, and OPS.

Two kinds of fold are used here, and they change this screen differently. Timelapse is a settings fold: switching it on mounts its categories on Mask’s own form and sets the pipeline gate the run reads, so its switch belongs on the masthead strip beside the heading. OPS is a page fold: it has 63 settings of its own and its own run entry point, none of which is preprocess_generate_masks, so switching it on puts it on this screen’s page strip instead and its switch sits in the actions row beside the Live and 3D buttons, in the same format. See CATEGORY_FOLDS, PAGE_FOLDS and install_ops_switch().

Spatial Mask Generation (alpha, F534) is a page fold of the same kind: its Spatial switch sits beside OPS and opens the spatial_masks settings page, which segments a whole Xenium or Visium HD slide in overlapping tiles. Both are PageFold instances; see install_spatial_masks_switch().

The Timelapse switch enables timelapse=True for the standard mask pipeline and displays the additional time-series and tracking settings on the Mask form. Settings files created for the Timelapse module remain compatible; sync_folds() restores the switch state from the pipeline gate.

The integrated tracking preview evaluates object linkage across frames, whereas the standard Mask preview evaluates segmentation of an individual field. Motility analysis remains under Measure because it quantifies existing masks and writes measurements rather than generating masks.

Category mounting and fold-state synchronization are shared with the other host screens through spacr.qt.screens.map_barcodes.

Attributes

SPATIAL_MASKS_KEY

The registry key of the page Mask Generation's Spatial switch opens.

SPATIAL_MASKS_TOGGLE_TOOLTIP

What Mask Generation's Spatial switch says on hover.

Functions

example_plate_folder(→ str)

Return the cache directory used for the example microscopy plate.

fold_previews(→ Dict[str, object])

The folded previews attached to screen, keyed by folded app.

fold_set(...)

The set of category folds installed on screen, or None.

install_example_data_button(screen)

Add an example-plate button above the source-directory setting.

install_folds(...)

Put Mask Generation's fold switches on screen's masthead.

install_ops_switch(→ Optional[_OpsPage])

Wire an actions-row switch to the OPS page.

install_spatial_masks_switch(...)

Wire Mask Generation's actions-row Spatial switch to its page.

load_the_example_images(→ Dict[str, object])

Generate an example plate and apply its settings to Mask Generation.

mark_fold_sources(→ Dict[str, Tuple[str, ...]])

Mark settings categories with their folded module icons.

ops_page(→ Optional[_OpsPage])

The OPS switch installed on screen, or None.

spatial_masks_page(...)

The Spatial Mask Generation switch installed on screen, or None.

sync_folds(→ Sequence[str])

Move the switches to match a settings dict that was just applied.

Module Contents

spacr.qt.screens.mask.example_plate_folder() → str[source]

Return the cache directory used for the example microscopy plate.

spacr.qt.screens.mask.fold_previews(screen: PySide6.QtWidgets.QWidget) → Dict[str, object][source]

The folded previews attached to screen, keyed by folded app.

Parameters:

screen – the module screen to inspect; a screen with no folded previews gives an empty dict.

spacr.qt.screens.mask.fold_set(screen: PySide6.QtWidgets.QWidget) → spacr.qt.screens.map_barcodes.CategoryFoldSet | None[source]

The set of category folds installed on screen, or None.

Parameters:

screen – the module screen to inspect.

spacr.qt.screens.mask.install_example_data_button(screen: PySide6.QtWidgets.QWidget)[source]

Add an example-plate button above the source-directory setting.

Installation is idempotent. The target section is identified from its src control so category renaming does not break placement.

Parameters:

screen – Host module screen.

Returns:

Installed button, or None if the screen has no suitable source-directory section.

spacr.qt.screens.mask.install_folds(screen: PySide6.QtWidgets.QWidget) → spacr.qt.widgets.fold_strip.FoldStrip | None[source]

Put Mask Generation’s fold switches on screen’s masthead.

And the example-plate button on its form: this is the one walk that reaches this screen from outside, so everything hung on Mask Generation is hung here. See install_example_data_button().

Idempotent, and errors are not raised, so a failure leaves the screen without its switches rather than stopping it from opening.

Parameters:

screen – the host module’s screen.

Returns:

the strip, or None when this screen cannot carry one – it is not the host, it has no masthead, one is already installed, or no folded module had a category of its own to add.

spacr.qt.screens.mask.install_ops_switch(screen: PySide6.QtWidgets.QWidget, switch) → _OpsPage | None[source]

Wire an actions-row switch to the OPS page.

Idempotent: a second call on the same screen returns the first installation and connects nothing further.

Parameters:
  • screen – the Mask Generation screen.

  • switch – the toggle to connect.

Returns:

the installation, or None when this is not the host screen.

spacr.qt.screens.mask.install_spatial_masks_switch(screen: PySide6.QtWidgets.QWidget, switch) → spacr.qt.screens.map_barcodes.PageFold | None[source]

Wire Mask Generation’s actions-row Spatial switch to its page.

The switch is alpha: it is named for the alpha gate here and hidden at once unless Preferences -> Show alpha features is on.

Parameters:
  • screen – the Mask Generation screen.

  • switch – the toggle to connect.

Returns:

the installation, or None when this is not the host screen.

spacr.qt.screens.mask.load_the_example_images(screen: PySide6.QtWidgets.QWidget, folder: str = '') → Dict[str, object][source]

Generate an example plate and apply its settings to Mask Generation.

The reproducible synthetic fields follow the filename and channel layout expected by the default pipeline. A summary of written images, applied settings, and unavailable controls is displayed in the screen console.

Parameters:
Returns:

Result containing folder, images, written, applied, filled, and unplaced. Returns an empty mapping if the plate could not be written.

spacr.qt.screens.mask.mark_fold_sources(screen: PySide6.QtWidgets.QWidget) → Dict[str, Tuple[str, ...]][source]

Mark settings categories with their folded module icons.

Both mounted categories and host categories listed in FOLD_CATEGORIES are marked. Repeated calls are idempotent, and a missing icon does not interrupt screen construction.

Parameters:

screen – Host module screen.

Returns:

Mapping from folded application keys to marked category titles.

spacr.qt.screens.mask.ops_page(screen: PySide6.QtWidgets.QWidget) → _OpsPage | None[source]

The OPS switch installed on screen, or None.

Parameters:

screen – the module screen to inspect.

spacr.qt.screens.mask.spatial_masks_page(screen: PySide6.QtWidgets.QWidget) → spacr.qt.screens.map_barcodes.PageFold | None[source]

The Spatial Mask Generation switch installed on screen, or None.

Parameters:

screen – the module screen to inspect.

spacr.qt.screens.mask.sync_folds(screen: PySide6.QtWidgets.QWidget, settings: Dict[str, object]) → Sequence[str][source]

Move the switches to match a settings dict that was just applied.

The tracking and assay CONTROLS take their values through the ordinary bulk apply, because they are ordinary controls on this form. Their gates are not controls – the switch is – so a Timelapse settings file would otherwise fill in every tracking setting and leave tracking off.

Safe to call on any screen: one that has no category folds returns an empty tuple.

Parameters:
  • screen – the screen the settings were applied to.

  • settings – the dict that was applied.

Returns:

the folded keys the settings switched on.

spacr.qt.screens.mask.SPATIAL_MASKS_KEY: str = 'spatial_masks'[source]

The registry key of the page Mask Generation’s Spatial switch opens.

spacr.qt.screens.mask.SPATIAL_MASKS_TOGGLE_TOOLTIP = "Show or hide the Spatial Mask Generation page: segment a whole Xenium morphology or Visium HD...[source]

What Mask Generation’s Spatial switch says on hover.