spacr.qt.widgets.channel_sort_dialog

Make Masks’ “Sort into channels…” dialog, its regex window and its set check.

Thin Qt over spacr.channel_sorting, which holds every decision:

  • ChannelSortDialog lists the open folder’s images with thumbnails and whether each has a mask. Images are selected (click, Shift, Ctrl, Select all) and assigned to a channel – the SELECTION strategy – and a regex can assign every image instead – the REGEX strategy. Apply builds a spacr.channel_sorting.SortPlan; when the names cannot be turned into sets, the user is asked to change the regex.

  • RegexWindow explains the named groups, tests a regex live against every file name, proposes one (“Auto regex”) or pairs images by similarity and size, ignoring names (“Detect sets”).

  • ExampleSetsDialog shows three detected sets side by side, every channel with its mask, and asks whether they are right.

Nothing here moves a file. The dialog hands back a plan; the screen applies it off the GUI thread.

Classes

ChannelSortDialog

Assign the folder's images to channels, check the sets, plan the move.

ExampleSetsDialog

Three sets side by side -- every channel and its mask -- and a question.

RegexWindow

Write, test, infer or bypass the regex that sorts images into sets.

Module Contents

class spacr.qt.widgets.channel_sort_dialog.ChannelSortDialog(folder: str, masks_dir: str | None = None, parent=None)[source]

Bases: PySide6.QtWidgets.QDialog

Assign the folder’s images to channels, check the sets, plan the move.

Variables:

plan – the confirmed spacr.channel_sorting.SortPlan once the dialog is accepted, else None.

List the folder and propose a regex.

Parameters:
  • folder – the folder Make Masks has open.

  • masks_dir – its masks folder, when not <folder>/masks.

  • parent – the Qt parent.

add_channel() → int[source]

Offer one more channel.

Returns:

the new channel’s number.

assign_selected(channel: int | None) → None[source]

Assign the selected images to channel; None clears them.

Assigning by hand replaces any sets “Detect sets” found.

Parameters:

channel – the 1-based channel, or None.

current_sets()[source]

The sets Apply would use, and what is wrong when there are none.

Returns:

(sets or None, report text).

mask_roles() → Dict[int, str][source]

{channel: role} as chosen, leaving out none.

parsed() → List[spacr.channel_sorting.ParsedName][source]

Every image read through the regex, with the selection’s channels.

prepare_plan(convert: bool = False) → spacr.channel_sorting.SortPlan | None[source]

Build the plan from the current sets, or None when there are none.

Parameters:

convert – convert RGB images and z-stacks to one plane.

Returns:

the plan, which may still carry problems.

refresh() → None[source]

Redraw the list texts, the mask-role choices and the status line.

selected_names() → List[str][source]

The selected images’ names, in list order.

set_regex(regex: str) → None[source]

Use regex for channels and sets from now on.

Parameters:

regex – the pattern.

class spacr.qt.widgets.channel_sort_dialog.ExampleSetsDialog(folder: str, sets: Dict[spacr.channel_sorting.SetKey, Dict[int, str]], masks_dir: str | None = None, parent=None)[source]

Bases: PySide6.QtWidgets.QDialog

Three sets side by side – every channel and its mask – and a question.

Lay out up to three sets: the first, the middle and the last.

Parameters:
  • folder – the image folder.

  • sets – {set key: {channel: name}}.

  • masks_dir – an explicit masks folder.

  • parent – the Qt parent.

class spacr.qt.widgets.channel_sort_dialog.RegexWindow(folder: str, names: List[str], channels: Dict[str, int] | None = None, regex: str = '', masks_dir: str | None = None, parent=None)[source]

Bases: PySide6.QtWidgets.QDialog

Write, test, infer or bypass the regex that sorts images into sets.

Variables:
  • regex – the regex when the window is accepted with “Use this regex”.

  • detected – the sets “Detect sets” found and the user confirmed, or None.

Build the window and run the test once.

Parameters:
  • folder – the image folder.

  • names – the image names to test against.

  • channels – {name: channel} from the selection.

  • regex – the regex to start from.

  • masks_dir – an explicit masks folder.

  • parent – the Qt parent.

auto_regex() → str | None[source]

Propose a regex, put it in the field and test it.

Returns:

the regex, or None when none was found.

detect() → Dict[spacr.channel_sorting.SetKey, Dict[int, str]] | None[source]

Pair images into sets, show three, and keep them when confirmed.

Returns:

the sets when the user said they are right, else None.

run_test() → spacr.channel_sorting.SetReport[source]

Parse every name with the regex and fill the table and summary.

Returns:

the set report.