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¶
|
Fetch the FIB-SEM test volume behind the shared progress dialog. |
|
Fetch the Make Masks test data behind the shared progress dialog. |
|
Fetch the TEM test data behind the shared progress dialog. |
|
Fetch one timelapse test movie behind the shared progress dialog. |
|
Where the FIB-SEM test volume is unpacked and cached. |
|
Build Make Masks' "Load test data…" button, wired to |
|
Whether a complete copy of the test data is unpacked in |
|
Every file the dataset's |
|
Open the FIB-SEM test volume in the 3-D mask editor. |
|
Open the TEM test data in Make Masks, downloading it first when needed. |
|
Open the test data in Make Masks, downloading it first when needed. |
|
Open a timelapse test movie with its masks and lineage loaded. |
|
Where the test data is unpacked and cached. |
|
Open an unpacked copy of the test data on its first image by name. |
|
Where the TEM test data is unpacked and cached. |
|
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), asdownload_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).resultisNoneon failure or cancellation, anderrorthen 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), asdownload_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), asdownload_make_masks_example()calls it.kind –
yeast,bacteriaormammalian.
- 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 folderspacr.example_archives.EXAMPLE_SETSnames for thefibsemset, sospacr-download fibsemand 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:
Trueonly 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.csvsays 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(), downloadingFIBSEM_EXAMPLE_REPOintofibsem_example_folder()when it is not cached. Without masks the volume opens unsegmented, its drafts saved inmasks/. With masks, the published labels are copied once intocorrected_masks/and open there for correction, soground_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 ofTEM_EXAMPLE_REPO, cached intem_example_folder().- Parameters:
screen – the Make Masks screen to open the data in.
ask – replaces
download_tem_example(), for tests.folder – replaces
tem_example_folder(), for tests.
- 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:
screen – the Make Masks screen to open the data in.
ask – replaces
download_make_masks_example(), for tests. It is called asask(screen, folder, on_done).folder – replaces
make_masks_example_folder(), for tests.
- Returns:
whether this call opened the data.
Falsewhile 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(), downloadingtimelapse_<kind>intotimelapse_example_folder()when it is not cached. The published masks are copied once intomasks/, the folder the editor reads and writes, soground_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:
screen – the Make Masks screen to open the movie in.
kind –
yeast,bacteriaormammalian.ask – replaces
download_timelapse_example(), for tests. It is called asask(screen, folder, on_done).folder – replaces
timelapse_example_folder(), for tests.
- 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 folderspacr.example_archives.EXAMPLE_SETSnames for thetemset, sospacr-download temand 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 folderspacr.example_archives.EXAMPLE_SETSnames for thetimelapse_<kind>set, sospacr-downloadand the menu share one cache.- Parameters:
kind –
yeast,bacteriaormammalian.- 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