spacr.qt.widgets.umap_figure_settings¶
Every Image UMAP setting, live-editable against the STATIC figure.
The live explorer has a settings window whose display options apply to the
figure on screen. This module provides the equivalent for
the screen – the ordinary, non-live figure the run leaves in
spacr.qt.widgets.figure_queue.FigureQueue:
"the non live image UMAP figure settings should have all the image UMAP
settings live editable (you should see changes in the graph directly)"
THE COST OF A SETTING IS NOT UNIFORM, and pretending it is would make the panel unusable. Three tiers, and every field declares which one it is in:
TIER_STYLEsettable on artists that already exist – dot size, dot colour, opacity, outline width. Microseconds; nothing is re-read from disk.
TIER_REDRAWneeds the figure replotted, but from the same embedding – image count, image zoom, figure size, which layers are drawn. Tenths of a second, because the thumbnails are re-read, so these are debounced.
TIER_RERUNchanges the embedding itself –
n_neighbors,min_dist, the metric, the feature filter. There is no honest way to apply one of these to a finished figure: recomputing moves every point, and the arrangement the user was reading is the whole value of the projection. They are editable and propagated, and the panel says they land on the next run.
The tier is a fact about the artists and the data, not a policy, which is why it lives beside the field rather than in the caller.
Classes¶
One editable Image UMAP setting. |
|
Edit Image UMAP figure settings with debounced live application. |
Functions¶
|
Apply |
|
Every setting key in |
|
The settings that reach the figure already on screen. |
|
Replot |
|
Push the cheap settings onto the artists |
Module Contents¶
- class spacr.qt.widgets.umap_figure_settings.Field[source]¶
Bases:
NamedTupleOne editable Image UMAP setting.
- Parameters:
key – the settings key.
label – the label shown beside the editor.
kind – the editor type:
"int","float","bool","text"or"choice".low – lower bound for a numeric editor (unused otherwise).
high – upper bound for a numeric editor (unused otherwise).
tier – what applying it takes:
TIER_STYLE,TIER_REDRAWorTIER_RERUN.choices – the options of a
"choice"field.
- class spacr.qt.widgets.umap_figure_settings.UmapFigureSettings(values: Dict[str, Any] | None = None, parent=None)[source]¶
Bases:
PySide6.QtWidgets.QWidgetEdit Image UMAP figure settings with debounced live application.
Each change emits
settings_changedwith the complete settings dictionary afterAPPLY_DEBOUNCE_MS. The containing figure-settings window applies style and redraw tiers immediately; rerun-tier values are retained for the next embedding run. No separate Apply action is required.- Parameters:
values – the settings to open on.
Noneopens on the defaults.parent – parent widget.
Build the Image UMAP settings panel, grouped by when a change applies.
The three tiers are the point: settings that restyle the points already drawn, settings that redraw the graph from the same embedding so no point moves, and settings that only take effect on the next run.
- Parameters:
values – the settings to open with;
Noneentries fall back to the module defaults.parent – parent widget, or
None.
- spacr.qt.widgets.umap_figure_settings.apply_to_figure(fig, payload: Dict[str, Any], values: Dict[str, Any], previous: Dict[str, Any] | None = None) str[source]¶
Apply
valuesto a finished Image UMAP figure.- Parameters:
fig – the matplotlib figure the Image UMAP was drawn into.
payload – the figure’s saved embedding payload, used for a redraw.
values – setting key to value; keys that differ from
previousdecide the work: any redraw-tier key replots, otherwise any style-tier key restyles.previous – the values last applied;
Nonetreats every key as changed.
- Returns:
"redraw","style"or""– what it actually had to do, so the caller can say whether the graph followed and can skip re-rasterising when nothing changed.
- spacr.qt.widgets.umap_figure_settings.keys_for_tier(tier: str) Tuple[str, ...][source]¶
Every setting key in
tier.- Parameters:
tier –
TIER_STYLE,TIER_REDRAWorTIER_RERUN; any other value gives an empty tuple.
- spacr.qt.widgets.umap_figure_settings.live_keys() Tuple[str, ...][source]¶
The settings that reach the figure already on screen.
- spacr.qt.widgets.umap_figure_settings.redraw_umap_figure(fig, payload: Dict[str, Any], values: Dict[str, Any]) bool[source]¶
Replot
figFROM THE SAME EMBEDDING withvalues.The embedding in
payloadis read, never recomputed: this is what makes “live apply” honest on a projection. Every point keeps its coordinates and its neighbours; only what is drawn on top of them changes.- Parameters:
fig – the matplotlib figure;
Nonereturns False.payload – dict holding
embedding(array of shape (N, 2)),plot_labelsorlabels(one per point), and optionallyrecordswithimagepaths andtheme_colors. A missing or mismatched embedding or labels returns False.values – setting key to value; an unset key uses the shipped default.
- Returns:
True when the figure was replotted.
- spacr.qt.widgets.umap_figure_settings.restyle_umap_figure(fig, values: Dict[str, Any]) bool[source]¶
Push the cheap settings onto the artists
figalready carries.Nothing is re-read and nothing is recomputed, so the points cannot move.
The original per-cluster face colours are stashed on the collection the first time a fixed colour is applied. Without that, switching the dot colour to
redand back toclusterwould leave every point red: the per-cluster colours were overwritten and there is nowhere left to read them from short of replotting.- Parameters:
fig – the matplotlib figure;
Nonereturns False.values – setting key to value; only
dot_size,point_alpha,outline_widthandpoint_colorare read, and a missing key is left alone.
- Returns:
True when any artist was changed.
Nested helpers¶
- redraw_umap_figure._get(key, fallback)¶
One figure setting, or the fallback when it is unset.
spacr/qt/widgets/umap_figure_settings.py:280