spacr.qt.synthetic
Synthetic datasets + saved settings for exercising every pipeline app.
The goal: give a developer (or a bug reporter) a one-line way to generate a demo folder that flows cleanly through every spacr pipeline — mask, measure, crop, classify, timelapse — plus a matching settings CSV that plugs into the “Import settings…” button on each app screen.
Everything is reverse-engineered from what the pipelines actually consume:
Filenames match the cellvoyager regex in spacr.utils._get_regex(‘.tif’, ‘cellvoyager’):
<plateID>_<wellID>_T<timeID>F<fieldID>L<laserID>A<AID>Z<sliceID>C<chanID>.tif
- Channels are laid out in the order every mask default expects:
C0 = nucleus, C1 = cell, C2 = pathogen, C3 = organelle
Images are 16-bit uint16 with realistic-looking Gaussian blobs so the segmentation apps don’t just see noise.
Settings CSVs are written in the two-column “Key,Value” format that spacr.utils.load_settings reads. Loading via the AppScreen’s “Import settings…” button restores every value into the form.
- Public API:
generate_mask_demo(dst, …) -> DemoLayout generate_measure_demo(dst, …) -> DemoLayout generate_crop_demo(dst, …) -> DemoLayout generate_classify_demo(dst, …) -> DemoLayout generate_timelapse_demo(dst, …) -> DemoLayout save_settings_csv(dst, settings) -> Path demo_settings(app_key, src) -> Dict[str, Any]
- CLI:
python -m spacr.qt.synthetic mask /tmp/demo python -m spacr.qt.synthetic all /tmp/demo
Module Contents
- spacr.qt.synthetic.cellvoyager_filename(plate: str = 'plate1', well: str = 'A01', time: int = 1, field: int = 1, laser: int = 1, a: int = 1, slice_: int = 1, chan: int = 1, ext: str = 'tif') str[source]
Return a filename matching: <plateID>_<wellID>_T<timeID>F<fieldID>L<laserID>A<AID>Z<sliceID>C<chanID>.<ext>
- spacr.qt.synthetic.generate_mask_demo(dst: pathlib.Path, plate: str = 'plate1', wells: Iterable[str] = ('A01', 'A02'), fields: int = 2, channels: Iterable[int] = (0, 1, 2, 3)) DemoLayout[source]
Populate dst with a folder that runs cleanly through the Mask app. Layout:
- dst/
<plateID>_<wellID>_T01F<field>L01A01Z01C<chan>.tif settings_mask.csv
- spacr.qt.synthetic.generate_measure_demo(dst: pathlib.Path, **kw) DemoLayout[source]
Measure consumes what mask produces: images + masks/ subfolder + a measurements/measurements.db scaffold. We pre-build the masks so a user can jump straight into Measure.
- spacr.qt.synthetic.generate_crop_demo(dst: pathlib.Path, **kw) DemoLayout[source]
Same as measure — Crop reads images + masks and writes PNG crops into data/ alongside the DB.
- spacr.qt.synthetic.generate_classify_demo(dst: pathlib.Path, n_crops: int = 16) DemoLayout[source]
Classify wants PNG single-object crops + a measurements.db with a png_list table + an annotate column carrying class labels for training/testing.
- spacr.qt.synthetic.generate_timelapse_demo(dst: pathlib.Path, plate: str = 'plate1', wells: Iterable[str] = ('A01',), fields: int = 1, times: int = 8, channels: Iterable[int] = (0, 1)) DemoLayout[source]
Timelapse needs multi-T frames per (well, field) so tracking has something to lock onto. Same cellvoyager naming, just with T01..T<N>.
- spacr.qt.synthetic.demo_settings(app_key: str, src: str) Dict[str, Any][source]
Return a spacr settings dict tailored for the demo dataset generated by generate_<app>_demo.
Values are the minimum needed to make the pipeline flow — real users will tweak thresholds + channel numbers to fit their data.