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:
ChannelSortDialoglists 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 aspacr.channel_sorting.SortPlan; when the names cannot be turned into sets, the user is asked to change the regex.RegexWindowexplains 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”).ExampleSetsDialogshows 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¶
Assign the folder's images to channels, check the sets, plan the move. |
|
Three sets side by side -- every channel and its mask -- and a question. |
|
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.QDialogAssign the folder’s images to channels, check the sets, plan the move.
- Variables:
plan – the confirmed
spacr.channel_sorting.SortPlanonce 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.
- 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).
- 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.
- 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.QDialogThree 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.QDialogWrite, 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.