From 5b021c5101e9c7c90aa266804c9f9d0c568086ac Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 19 Aug 2026 06:46:10 -0700 Subject: [PATCH] switch to streaming to disk, bump version --- .../LightSheetManagerPlugin.java | 2 +- .../acquisitions/AcquisitionEngineScape.java | 37 ++++++++++--------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/micromanager/lightsheetmanager/LightSheetManagerPlugin.java b/src/main/java/org/micromanager/lightsheetmanager/LightSheetManagerPlugin.java index c4214e9..d84020c 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/LightSheetManagerPlugin.java +++ b/src/main/java/org/micromanager/lightsheetmanager/LightSheetManagerPlugin.java @@ -15,7 +15,7 @@ public class LightSheetManagerPlugin implements MenuPlugin, SciJavaPlugin { public static final String copyright = "Applied Scientific Instrumentation (ASI), 2022-2026"; public static final String description = "A plugin to control various types of light sheet microscopes."; public static final String menuName = "Light Sheet Manager"; - public static final String version = "0.8.4"; + public static final String version = "0.8.5"; private Studio studio_; diff --git a/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineScape.java b/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineScape.java index 965fe25..d5a8484 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineScape.java +++ b/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineScape.java @@ -280,10 +280,10 @@ boolean run() { } } - // Sets MM's persisted preferred save mode. Inert today: MMAcquisition reads it only when - // SequenceSettings has save() and root() set, and we set neither, so our datastore is - // always StorageRAM and finish() passes the mode to save() explicitly. Kept because it is - // the only channel MMAcquisition offers if direct to disk is re-enabled. + // Sets MM's persisted preferred save mode. MMAcquisition reads it when SequenceSettings + // has save() and root() set, which is what the saving branch below does, so this is what + // picks ND-TIFF over multipage TIFF or a single plane series for the images written during + // the run. It is the only channel MMAcquisition offers for that choice. if (acqSettings_.saveMode() == SaveMode.ND_TIFF) { DefaultDatastore.setPreferredSaveMode(studio_, Datastore.SaveMode.ND_TIFF); } else if (acqSettings_.saveMode() == SaveMode.MULTIPAGE_TIFF) { @@ -317,6 +317,16 @@ boolean run() { // TODO(Brandon): where should i get this from? SequenceSettings.Builder sequenceSettingsBuilder = new SequenceSettings.Builder(); sequenceSettingsBuilder.shouldDisplayImages(true); + // Write images to disk as they arrive instead of accumulating the run in memory. + // MMAcquisition swaps StorageRAM for the preferred save mode set above only when both + // save() and root() are set, so setting them here is what selects streaming. This is what + // the checkbox means in 1.4 as well: checked writes during the run, unchecked keeps the + // run in memory. + if (acqSettings_.isSavingImagesDuringAcquisition()) { + sequenceSettingsBuilder.save(true) + .root(saveDir) + .prefix(saveName); + } MMAcquisition acq = new MMAcquisition(studio_, dsmd, this, sequenceSettingsBuilder.build()); @@ -768,7 +778,7 @@ void finish() { // Job A: restore hardware/system state. Must ALWAYS run: setup() can mutate hardware // before it fails, so each step self-guards on whether its state was changed. // Job B: end-of-acquisition work. Only valid if the run actually happened, so each step - // self-guards on that (don't, e.g., save a datastore that was never filled). + // self-guards on that (don't, e.g., report on an acquisition that never started). // // Adding a step? Pick its job: Job A runs unconditionally, Job B only when the run happened. // Don't interleave them. @@ -868,19 +878,10 @@ void finish() { // TODO: execute any end-acquisition runnables - // save only if this run created a store with images - if (acqSettings_.isSavingImagesDuringAcquisition() - && datastore_ != null && datastore_.getNumImages() > 0) { - final String savePath = FileUtils.createUniquePath( - acqSettings_.saveDirectory(), acqSettings_.saveNamePrefix()); - try { - // convert from DataStorage.SaveMode to Datastore.SaveMode - final Datastore.SaveMode saveMode = SaveMode.convert(acqSettings_.saveMode()); - datastore_.save(saveMode, savePath); - } catch (Exception e) { - model_.studio().logs().showError("could not save the acquisition data to: \n" + savePath); - } - } + // Nothing to save here. Images are written during the run when saving is enabled, and a + // run acquired without saving is held in memory and discarded, which is what 1.4 does. + // The unsaved case still offers the data: MM prompts to save when its window is closed, + // because StorageRAM leaves the datastore save path unset. } private boolean doHardwareCalculations(PLogicScape plc) {