spacr.qt.make_masks_demo

Make Masks’ test data: ten Toxoplasma vacuole fields, one button away.

Ten images of the Toxoplasma PV training set are published on Hugging Face as a small test dataset for Make Masks, with a button that loads the dataset and opens its first image in Make Masks.

WHAT IS PUBLISHED. MAKE_MASKS_EXAMPLE_REPO holds ten of the lab’s own acquisitions – no figure harvested from a paper, no held-out field – at the top level, their curated label masks under ground_truth_masks/, a manifest.csv carrying each image’s row from the in-house manifest, and one archive of all of it. The images open UNSEGMENTED: Make Masks reads drafts from masks/, never from ground_truth_masks/, so the editor starts on raw fields and the truth sits beside them.

THE SAME PATTERN AS EVERY OTHER EXAMPLE SET. One uncompressed .tar per repository, streamed to a .part file on a worker thread behind the shared progress dialog, unpacked through the tar data filter (spacr.qt.hf_download._TarExampleWorker does all of that), and cached: is_present() is asked first, so a second press opens the folder without a request.

ITS OWN FOLDER, NOT THE SHARED PLATE. The Measure and Annotate sets unpack into example_plate_folder() because they compose into one plate. These ten fields are not part of that plate, and the Mask demo decides it is present by finding *.tif there, so unpacking them into it would make that demo think it had been downloaded.

WHY THIS IS A MODULE AND NOT A METHOD. The screen gets one call in its navigation row. Everything else lives here, so make_masks.py – which several items edit at once – carries a two-line hook.

Functions

download_fibsem_example(→ None)

Fetch the FIB-SEM test volume behind the shared progress dialog.

download_make_masks_example(→ None)

Fetch the Make Masks test data behind the shared progress dialog.

download_tem_example(→ None)

Fetch the TEM test data behind the shared progress dialog.

download_timelapse_example(→ None)

Fetch one timelapse test movie behind the shared progress dialog.

fibsem_example_folder(→ pathlib.Path)

Where the FIB-SEM test volume is unpacked and cached.

install_test_data_button(→ PySide6.QtWidgets.QPushButton)

Build Make Masks' "Load test data…" button, wired to screen.

is_present(→ bool)

Whether a complete copy of the test data is unpacked in folder.

listed_files(→ List[str])

Every file the dataset's manifest.csv says a complete copy holds.

load_the_fibsem_test_data(→ bool)

Open the FIB-SEM test volume in the 3-D mask editor.

load_the_tem_test_data(→ bool)

Open the TEM test data in Make Masks, downloading it first when needed.

load_the_test_data(→ bool)

Open the test data in Make Masks, downloading it first when needed.

load_the_timelapse_test_data(→ bool)

Open a timelapse test movie with its masks and lineage loaded.

make_masks_example_folder(→ pathlib.Path)

Where the test data is unpacked and cached.

open_the_test_data(→ bool)

Open an unpacked copy of the test data on its first image by name.

tem_example_folder(→ pathlib.Path)

Where the TEM test data is unpacked and cached.

timelapse_example_folder(→ pathlib.Path)

Where one timelapse test movie is unpacked and cached.

Module Contents

spacr.qt.make_masks_demo.download_fibsem_example(parent, dest, on_done: Callable[[spacr.qt.hf_download.DownloadResult | None, str], None]) → None[source]

Fetch the FIB-SEM test volume behind the shared progress dialog.

Parameters:
  • parent – the widget the progress dialog belongs to.

  • dest – the folder the archive unpacks into.

  • on_done – called on the GUI thread as on_done(result, error), as download_make_masks_example() calls it.

spacr.qt.make_masks_demo.download_make_masks_example(parent, dest, on_done: Callable[[spacr.qt.hf_download.DownloadResult | None, str], None]) → None[source]

Fetch the Make Masks test data behind the shared progress dialog.

Parameters:
  • parent – the widget the progress dialog belongs to.

  • dest – the folder the archive unpacks into.

  • on_done – called on the GUI thread as on_done(result, error). result is None on failure or cancellation, and error then says why.

spacr.qt.make_masks_demo.download_tem_example(parent, dest, on_done: Callable[[spacr.qt.hf_download.DownloadResult | None, str], None]) → None[source]

Fetch the TEM test data behind the shared progress dialog.

Parameters:
  • parent – the widget the progress dialog belongs to.

  • dest – the folder the archive unpacks into.

  • on_done – called on the GUI thread as on_done(result, error), as download_make_masks_example() calls it.

spacr.qt.make_masks_demo.download_timelapse_example(parent, dest, on_done: Callable[[spacr.qt.hf_download.DownloadResult | None, str], None], kind: str) → None[source]

Fetch one timelapse test movie behind the shared progress dialog.

Parameters:
  • parent – the widget the progress dialog belongs to.

  • dest – the folder the archive unpacks into.

  • on_done – called on the GUI thread as on_done(result, error), as download_make_masks_example() calls it.

  • kind – yeast, bacteria or mammalian.

spacr.qt.make_masks_demo.fibsem_example_folder() → pathlib.Path[source]

Where the FIB-SEM test volume is unpacked and cached.

~/.cache/spacr/example_data/make_masks_fibsem, the folder spacr.example_archives.EXAMPLE_SETS names for the fibsem set, so spacr-download fibsem and the menu share one cache.

Returns:

the folder. It is not created here.

spacr.qt.make_masks_demo.install_test_data_button(screen) → PySide6.QtWidgets.QPushButton[source]

Build Make Masks’ “Load test data…” button, wired to screen.

Parameters:

screen – the Make Masks screen the data opens in. The button is kept on it as _btn_test_data, so a load can disable it while the download runs.

Returns:

the button, for the caller to place.

spacr.qt.make_masks_demo.is_present(folder) → bool[source]

Whether a complete copy of the test data is unpacked in folder.

Parameters:

folder – where the dataset is expected.

Returns:

True only when the manifest exists and every image and mask it lists is a file. A half-unpacked set reads as absent, which is the answer that gets it downloaded again.

spacr.qt.make_masks_demo.listed_files(folder) → List[str][source]

Every file the dataset’s manifest.csv says a complete copy holds.

Parameters:

folder – where the dataset was unpacked.

Returns:

paths relative to folder, each image followed by its ground-truth mask, in manifest order. Empty when there is no readable manifest, or when any row names no image, so that an incomplete or unrecognised folder is never mistaken for the dataset.

spacr.qt.make_masks_demo.load_the_fibsem_test_data(screen, *, with_masks=False, ask=None, folder=None) → bool[source]

Open the FIB-SEM test volume in the 3-D mask editor.

The same sequence as load_the_test_data(), downloading FIBSEM_EXAMPLE_REPO into fibsem_example_folder() when it is not cached. Without masks the volume opens unsegmented, its drafts saved in masks/. With masks, the published labels are copied once into corrected_masks/ and open there for correction, so ground_truth_masks/ is never overwritten.

Parameters:
  • screen – the Make Masks screen whose 3-D editor opens the volume.

  • with_masks – open the volume with its mitochondria labels loaded.

  • ask – replaces download_fibsem_example(), for tests.

  • folder – replaces fibsem_example_folder(), for tests.

Returns:

whether this call opened the volume.

spacr.qt.make_masks_demo.load_the_tem_test_data(screen, *, ask=None, folder=None) → bool[source]

Open the TEM test data in Make Masks, downloading it first when needed.

The same sequence as load_the_test_data() – cache check, button disabled while the download runs, the first image by name, a failure said with its reason – for the ten micrographs of TEM_EXAMPLE_REPO, cached in tem_example_folder().

Parameters:
Returns:

whether this call opened the data.

spacr.qt.make_masks_demo.load_the_test_data(screen, *, ask=None, folder=None) → bool[source]

Open the test data in Make Masks, downloading it first when needed.

A cached copy opens at once. Otherwise the button is disabled, the status line says a download is running, and the download runs on a worker thread behind a progress dialog. When it finishes, the folder opens on its first image by name. A failure is reported with the reason the downloader gave, on the status line and, when there is a display to show one, in a warning.

Parameters:
Returns:

whether this call opened the data. False while a download is still running, and after a failure.

spacr.qt.make_masks_demo.load_the_timelapse_test_data(screen, kind: str, *, ask=None, folder=None) → bool[source]

Open a timelapse test movie with its masks and lineage loaded.

The same sequence as load_the_test_data(), downloading timelapse_<kind> into timelapse_example_folder() when it is not cached. The published masks are copied once into masks/, the folder the editor reads and writes, so ground_truth_masks/ is never overwritten. Their embedded lineage opens with the first frame, so the divisions are on the lineage menu and Time can be switched on at once.

Parameters:
Returns:

whether this call opened the movie.

spacr.qt.make_masks_demo.make_masks_example_folder() → pathlib.Path[source]

Where the test data is unpacked and cached.

~/.cache/spacr/example_data/make_masks_toxo_pv, beside the shared example plate rather than inside it. See the module docstring for why.

Returns:

the folder. It is not created here.

spacr.qt.make_masks_demo.open_the_test_data(screen, folder) → bool[source]

Open an unpacked copy of the test data on its first image by name.

Parameters:
  • screen – the Make Masks screen.

  • folder – where the data was unpacked.

Returns:

whether the screen is now on it. An incomplete copy is reported rather than opened, because half the fields would pass for the whole set.

spacr.qt.make_masks_demo.tem_example_folder() → pathlib.Path[source]

Where the TEM test data is unpacked and cached.

~/.cache/spacr/example_data/make_masks_tem, the folder spacr.example_archives.EXAMPLE_SETS names for the tem set, so spacr-download tem and the button share one cache.

Returns:

the folder. It is not created here.

spacr.qt.make_masks_demo.timelapse_example_folder(kind: str) → pathlib.Path[source]

Where one timelapse test movie is unpacked and cached.

~/.cache/spacr/example_data/make_masks_timelapse_<kind>, the folder spacr.example_archives.EXAMPLE_SETS names for the timelapse_<kind> set, so spacr-download and the menu share one cache.

Parameters:

kind – yeast, bacteria or mammalian.

Returns:

the folder. It is not created here.

Raises:

KeyError – for any other kind.

Nested helpers

_load_example._done(result, error)

Put the button back, then open the data or say why it did not.

spacr/qt/make_masks_demo.py:488