spacr.qt.ingest_preview¶
Extraction-preview bridge.
Turns a described dataset — either a container file (nd2 / czi / lif /
multi-page tiff / npz) inspected by spacr.qt.multi_format, or a
folder-structured layout recognised by spacr.qt.folder_metadata
— into a flat list of the individual image “planes” it would expand to,
without reading any pixel data.
Each plane is a plain dict row:
{"original": <source path or series>,
"plate": "plate1",
"well": "plate1_A01",
"field": 1,
"channel": 1,
"time": 1,
"canonical": "plate1_A01_T0001F001L01C01.tif"}
The canonical names match spacr.io.convert_to_yokogawa() (the
pipeline’s own container extractor) so the preview the user edits is the
layout the extraction will actually produce. The rows feed the editable
metadata table (spacr.qt.widgets.metadata_table) and can be written
to a filename_map.csv via rows_to_mappings() +
spacr.qt.folder_metadata.save_filename_map().
Functions¶
|
Convert a |
|
Enumerate the planes a container file would expand into. |
|
Enumerate the planes a folder-structured dataset would map to. |
|
Convert edited table rows back into |
|
One-line count summary of a preview (wells / fields / channels). |
Module Contents¶
- spacr.qt.ingest_preview.mapping_to_row(m: Any) Dict[str, Any][source]¶
Convert a
spacr.qt.folder_metadata.NameMappingto a row dict.- Parameters:
m – mapping object, read by attribute; a missing attribute falls back to
""(paths, well),"plate1"or1(field, channel, time). The row’s keys areROW_COLUMNS.
- spacr.qt.ingest_preview.plan_container_extraction(desc: Any, plate: str = 'plate1', well: str = 'A01') List[Dict[str, Any]][source]¶
Enumerate the planes a container file would expand into.
Mirrors
spacr.io.convert_to_yokogawa(): a single container file is assigned one well, and its fields / channels / timepoints become theF/C/Tindices of the generated TIFFs. Z-slices are max-projected (MIP) by the converter, so they are not enumerated here.- Parameters:
desc – a
DatasetDescription(needsn_fields,n_channels,n_timepointsandpath).plate – plate id for the canonical name.
well – bare well id (
A01); combined withplateinto the Yokogawa well tokenplate1_A01.
- Returns:
one row dict per (time, field, channel) plane.
- spacr.qt.ingest_preview.plan_folder_extraction(root: Any, plate: str = 'plate1', limit: int | None = 200, files: Iterable[pathlib.Path] | None = None, template: Any = _UNSET) List[Dict[str, Any]][source]¶
Enumerate the planes a folder-structured dataset would map to.
Uses
spacr.qt.folder_metadata.detect_folder_metadata()to decide which fields the folder tree already provides, thenspacr.qt.folder_metadata.assign_missing_fields()to mint the rest (stable, sorted order). Every image file becomes one row.- Parameters:
root – dropped folder.
plate – plate id used in the canonical names.
limit – cap on the number of rows returned (the table only needs a representative preview).
Nonefor no cap.files – image paths to plan from, instead of walking
root. May be a generator — it is consumed here. A caller that has already walked the tree (seespacr.qt.folder_metadata.iter_image_files()) passes it in so the tree is not walked a second time.template – an already-detected
FolderTemplate, orNonefor “detection ran and found nothing”. Omit to detect here — which walks the tree again, so a caller that already has one should pass it.
- Returns:
one row dict per source image, or
[]if nothing matched.
- spacr.qt.ingest_preview.rows_to_mappings(rows: Sequence[Dict[str, Any]]) List[Any][source]¶
Convert edited table rows back into
NameMappingobjects ready forspacr.qt.folder_metadata.save_filename_map().- Parameters:
rows – row dicts keyed by
ROW_COLUMNS; missing text keys become""(platebecomes"plate1") and a missing or empty field, channel or time becomes1.
- spacr.qt.ingest_preview.summarize_rows(rows: Sequence[Dict[str, Any]]) str[source]¶
One-line count summary of a preview (wells / fields / channels).
- Parameters:
rows – preview row dicts; distinct
well,field,channelandtimevalues are counted, and timepoints are only mentioned when there is more than one.