spacr.object_settings_table¶
Convert per-object settings between flat keys and a table with one row per question.
Per-object settings repeat questions for each object type –
cell_diameter, nucleus_diameter, pathogen_diameter and
organelle_diameter, for example. The table puts each question in one
row and each object type in one column.
The organelle count is variable, up to
spacr.organelle_types.MAX_ORGANELLES. Each added slot repeats
the primary organelle’s settings. In the table an additional organelle adds
a column while the question rows stay the same.
This module is only the model: it reads a flat settings dict into a table
and writes a table back out, losslessly. It draws nothing.
A GUI renders to_table() and calls from_table() on edit, and the
headless path never has to know the table exists – the stored keys are
unchanged, so no settings file, notebook or tutorial migrates.
Storing a nested
{question: {object: value}}structure instead would be a file-format change, and every saved settings file, every published tutorial, and the headlessspacr-runpath would have to change with it. Only the presentation changes.
Functions¶
|
Return the column header text for |
|
|
|
Flatten a table back to settings keys, over |
|
The distinct questions in |
|
Read a flat settings dict as |
|
Return a copy of |
Module Contents¶
- spacr.object_settings_table.column_label(obj: str) str[source]¶
Return the column header text for
obj.organellebis a storage spelling, not a thing a user recognises. The letter suffixes exist because object types are embedded in underscore-separated object keys andorganelle2is ambiguous with label 2 – an implementation constraint that has no business appearing in a column header.- Parameters:
obj – an object name from
OBJECT_ORDER, e.g."cell"or"organelleb". Organelle slots get their numbered label; any other name has underscores turned into spaces and is capitalised.
- spacr.object_settings_table.families(keys: Iterable[str]) Dict[str, List[str]][source]¶
{question: [objects that ask it]}, objects in display order.- Parameters:
keys – flat settings names such as
"cell_min_area","remove_background_cell","remove_background_organelle_2"and"adjust_cells". Unsupported names are skipped.
- spacr.object_settings_table.from_table(table: Mapping[str, Mapping[str, object]], base: Mapping[str, object] | None = None) Dict[str, object][source]¶
Flatten a table back to settings keys, over
baseif given.The inverse of
to_table(), without loss: the table is the settings file rearranged, not transformed, so it can be used as an editing surface. A test round-trips every default settings dict.- Parameters:
table –
{question: {object: value}}.base – the settings the table came from. Keys the table does not cover are carried through unchanged, so a caller can edit the per-object half without holding the rest.
- spacr.object_settings_table.questions(keys: Iterable[str]) List[str][source]¶
The distinct questions in
keys, in first-seen order.One entry per question, however many objects ask it:
cell_diameterandnucleus_diameterare one question,diameter.- Parameters:
keys – flat settings names such as
"cell_diameter","remove_background_cell","remove_background_organelle_2"and"adjust_cells". Unsupported names are skipped.
- spacr.object_settings_table.to_table(settings: Mapping[str, object]) Dict[str, Dict[str, object]][source]¶
Read a flat settings dict as
{question: {object: value}}.Only the keys that ARE per-object questions are taken. Everything else –
src,verbose,n_jobs– is not a table row and is left where it is; a caller wanting the whole settings dict back usesfrom_table()with the original.A question a given object does not ask is ABSENT from its row rather than present as
None.cytoplasmhas no channel, no diameter and no detection method because it is derived rather than found in a channel, and a blank cell says that where aNonewould read as “not set yet”.- Parameters:
settings – a flat settings dict, e.g. Mask’s settings; it is only read.
- spacr.object_settings_table.widen(table: Mapping[str, Mapping[str, object]], obj: str, *, like: str | None = None) Dict[str, Dict[str, object]][source]¶
Return a copy of
tablewith a column forobj, copyinglike’s answers where it has them.Adding an organelle is one call that adds one column; in the flat vocabulary it is twenty new settings that every consumer, tooltip table and translation catalog has to include.
- Parameters:
obj – the object to add, e.g.
'organellec'.like – an existing object whose answers to copy as the starting point. Defaults to the first organelle when
objis one, because a second mitochondrion should start where the first one is rather than at a global default nobody chose.
Nested helpers¶
- _filter_text._num(value)¶
One bound as compact text; blank for an unset bound.
spacr/object_settings_table.py:178
- _parse_filter_text._side(value)¶
One side of the range as a number;
Nonewhen left blank.spacr/object_settings_table.py:218