diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/AutofocusManager.java b/src/main/java/org/micromanager/lightsheetmanager/api/AutofocusManager.java index 2d8f3ab..ccf586d 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/AutofocusManager.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/AutofocusManager.java @@ -7,7 +7,7 @@ */ public interface AutofocusManager { - CalibrationSettings calibrate(AutofocusSettings settings); + //CalibrationSettings calibrate(AutofocusSettings settings); } // TODO: moved from AutofocusSettings diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/AutofocusSettings.java b/src/main/java/org/micromanager/lightsheetmanager/api/AutofocusSettings.java index 035df4c..239329a 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/AutofocusSettings.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/AutofocusSettings.java @@ -8,6 +8,59 @@ */ public interface AutofocusSettings { + /** + * Returns a builder initialized with the current settings. + * + * @return a builder to create a modified copy of these settings + */ + Builder copyBuilder(); + + /** + * Return true if channels are enabled. + * + * @return true if channels are enabled + */ + boolean enabled(); + + /** + * Returns the number of images used in for autofocus routine. + * + * @return the number of images + */ + int numImages(); + + /** + * Returns the step size between images in microns. + * + * @return the step size in microns + */ + double stepSizeUm(); + + /** + * Returns the autofocus mode being used. + * + * @return the autofocus mode + */ + AutofocusMode mode(); + + /** + * Returns the type of scoring algorithm used for autofocus. + * + * @return the type of scoring algorithm + */ + AutofocusType scoringMethod(); + + /** + * Returns the channel autofocus is being run on. + * + * @return the autofocus channel + */ + String channel(); + + boolean showGraph(); + + boolean showImages(); + interface Builder { /** @@ -31,13 +84,6 @@ interface Builder { */ Builder stepSizeUm(final double stepSize); -// /** -// * Sets the tolerance in microns for the autofocus algorithm. -// * -// * @param value the tolerance in microns -// */ -// Builder toleranceUm(final double value); - /** * Set to {@code true} to show the images in the live view window. * @@ -73,29 +119,6 @@ interface Builder { */ Builder channel(final String channel); - // TODO: maybe denote that these are related to acquisitions - -// /** -// * Run autofocus every time we move to the next channel during an acquisition. -// * -// * @param state true to enable autofocus every stage pass -// */ -// Builder useEveryStagePass(final boolean state); -// -// /** -// * Run an autofocus routine before starting the acquisition. -// * -// * @param state true or false -// */ -// Builder useBeforeAcquisition(final boolean state); - - -// Builder maxOffset(final double maxOffset); // +/- um -// -// Builder autoUpdateOffset(final boolean state); -// -// Builder autoUpdateMaxOffset(final double um); - /** * Creates an immutable instance of AutofocusSettings * @@ -104,85 +127,4 @@ interface Builder { AutofocusSettings build(); } - /** - * Returns a builder initialized with the current settings. - * - * @return a builder to create a modified copy of these settings - */ - Builder copyBuilder(); - - /** - * Return true if channels are enabled. - * - * @return true if channels are enabled - */ - boolean enabled(); - - /** - * Returns the number of images used in for autofocus routine. - * - * @return the number of images - */ - int numImages(); - - /** - * Returns the step size between images in microns. - * - * @return the step size in microns - */ - double stepSizeUm(); - -// /** -// * Returns the coefficient of determination used in the autofocus routine. -// * -// * @return the coefficient of determination -// */ -// double toleranceUm(); - - /** - * Returns the autofocus mode being used. - * - * @return the autofocus mode - */ - AutofocusMode mode(); - - /** - * Returns the type of scoring algorithm used for autofocus. - * - * @return the type of scoring algorithm - */ - AutofocusType scoringMethod(); - - /** - * Returns the channel autofocus is being run on. - * - * @return the autofocus channel - */ - String channel(); - -// /** -// * Returns true if autofocus is run every stage pass. -// * -// * @return true if autofocus is run every stage pass -// */ -// boolean useEveryStagePass(); -// -// /** -// * Returns true if we run an autofocus routine before starting an acquisition. -// * -// * @return true if enabled -// */ -// boolean useBeforeAcquisition(); - - /** - * What is this? - * - * @return - */ -// double maxOffset(); // used during acquisitions -// -// boolean autoUpdateOffset(); -// -// double autoUpdateMaxOffset(); - } diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/SheetCalibration.java b/src/main/java/org/micromanager/lightsheetmanager/api/SheetCalibration.java index 91c2e9b..a5d4871 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/SheetCalibration.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/SheetCalibration.java @@ -1,12 +1,23 @@ package org.micromanager.lightsheetmanager.api; -import org.micromanager.lightsheetmanager.api.internal.DefaultSheetCalibration; - /** * Light Sheet Synchronization on "Setup Path #" tabs. */ public interface SheetCalibration { + Builder copyBuilder(); + + // normal camera trigger modes + double imagingCenter(); + double sheetWidth(); + double sheetOffset(); + boolean autoSheetWidthEnabled(); + double autoSheetWidthPerPixel(); + + // virtual slit camera trigger mode + double scanSpeed(); + double scanOffset(); + interface Builder { Builder imagingCenter(final double center); @@ -30,7 +41,7 @@ interface Builder { * * @param state true to automatically set sheet width */ - Builder useAutoSheetWidth(final boolean state); + Builder autoSheetWidthEnabled(final boolean state); /** * Sets the width per pixel when isUsingAutoSheetWidth is true. @@ -62,17 +73,4 @@ interface Builder { } - Builder copyBuilder(); - - // normal camera trigger modes - double imagingCenter(); - double sheetWidth(); - double sheetOffset(); - boolean isUsingAutoSheetWidth(); - double autoSheetWidthPerPixel(); - - // virtual slit camera trigger mode - double scanSpeed(); - double scanOffset(); - } diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/SliceCalibration.java b/src/main/java/org/micromanager/lightsheetmanager/api/SliceCalibration.java index 17d4638..6048eae 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/SliceCalibration.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/SliceCalibration.java @@ -9,11 +9,16 @@ */ public interface SliceCalibration { + Builder copyBuilder(); + + double slope(); + double offset(); + interface Builder { - Builder sliceSlope(final double slope); + Builder slope(final double slope); - Builder sliceOffset(final double offset); + Builder offset(final double offset); /** * Creates an immutable instance of DefaultSliceCalibration @@ -23,10 +28,4 @@ interface Builder { DefaultSliceCalibration build(); } - Builder copyBuilder(); - - double sliceSlope(); - double sliceOffset(); - - } diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/SliceSettings.java b/src/main/java/org/micromanager/lightsheetmanager/api/SliceSettings.java index f66bd10..66a84e8 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/SliceSettings.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/SliceSettings.java @@ -2,7 +2,36 @@ public interface SliceSettings { + /** + * Returns a builder initialized with the current settings. + * + * @return a builder to create a modified copy of these settings + */ + Builder copyBuilder(); + + /** + * Returns the slice period in milliseconds. + * + * @return the slice period in milliseconds + */ + double period(); + + /** + * Returns the sample exposure time in milliseconds. + * + * @return the exposure time in milliseconds + */ + double sampleExposure(); + + /** + * Returns true if the slice period is minimized. + * + * @return true if slice period is minimized + */ + boolean periodMinimized(); + interface Builder { + /** * Sets the slice period in milliseconds. * @@ -22,7 +51,7 @@ interface Builder { * * @param state true to minimize the slice period */ - Builder minimizePeriod(final boolean state); + Builder periodMinimized(final boolean state); /** * Creates an immutable instance of SliceSettings @@ -30,33 +59,7 @@ interface Builder { * @return Immutable version of SliceSettings */ SliceSettings build(); - } - - /** - * Returns a builder initialized with the current settings. - * - * @return a builder to create a modified copy of these settings - */ - Builder copyBuilder(); - - /** - * Returns the slice period in milliseconds. - * - * @return the slice period in milliseconds - */ - double period(); - /** - * Returns the sample exposure time in milliseconds. - * - * @return the exposure time in milliseconds - */ - double sampleExposure(); + } - /** - * Returns true if the slice period is minimized. - * - * @return true if slice period is minimized - */ - boolean periodMinimized(); } diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/TimingSettings.java b/src/main/java/org/micromanager/lightsheetmanager/api/TimingSettings.java index b4a8dcc..c24eed1 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/TimingSettings.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/TimingSettings.java @@ -2,6 +2,83 @@ public interface TimingSettings { + /** + * Returns a builder initialized with the current settings. + * + * @return a builder to create a modified copy of these settings + */ + Builder copyBuilder(); + + /** + * Returns the delay time in milliseconds before the scan begins. + * + * @return the delay time in milliseconds + */ + double delayBeforeScan(); + + /** + * Returns the number of one way beam scans per slice. + * + * @return the number of one way beam scans per slice + */ + int scansPerSlice(); + + /** + * Returns the time in milliseconds of one beam scan sweep. + * + * @return the time in milliseconds of one beam scan sweep + */ + double scanDuration(); + + /** + * Returns the delay time in milliseconds before the laser trigger. + * + * @return the delay time in milliseconds before the laser trigger + */ + double delayBeforeLaser(); + + /** + * Returns the laser trigger duration in milliseconds. + * + * @return the laser trigger duration in milliseconds + */ + double laserTriggerDuration(); + + /** + * Returns the delay time in milliseconds before the camera is triggered. + * + * @return the delay time in milliseconds before the camera is triggered + */ + double delayBeforeCamera(); + + /** + * Returns the camera trigger duration in milliseconds. + * + * @return the camera trigger duration in milliseconds + */ + double cameraTriggerDuration(); + + /** + * Returns the duration in milliseconds that the camera shutter is open. + * + * @return the duration in milliseconds that the camera shutter is open + */ + double cameraExposure(); + + /** + * Returns the duration in milliseconds of each slice. + * + * @return the duration in milliseconds of each slice + */ + double sliceDuration(); + + /** + * Returns true if the scan direction is inverted. + * + * @return true if the scan direction is inverted + */ + boolean useAlternateScanDirection(); + interface Builder { /** @@ -78,82 +155,7 @@ interface Builder { * @return Immutable version of TimingSettings */ TimingSettings build(); - } - - /** - * Returns a builder initialized with the current settings. - * - * @return a builder to create a modified copy of these settings - */ - Builder copyBuilder(); - - /** - * Returns the delay time in milliseconds before the scan begins. - * - * @return the delay time in milliseconds - */ - double delayBeforeScan(); - /** - * Returns the number of one way beam scans per slice. - * - * @return the number of one way beam scans per slice - */ - int scansPerSlice(); - - /** - * Returns the time in milliseconds of one beam scan sweep. - * - * @return the time in milliseconds of one beam scan sweep - */ - double scanDuration(); - - /** - * Returns the delay time in milliseconds before the laser trigger. - * - * @return the delay time in milliseconds before the laser trigger - */ - double delayBeforeLaser(); - - /** - * Returns the laser trigger duration in milliseconds. - * - * @return the laser trigger duration in milliseconds - */ - double laserTriggerDuration(); - - /** - * Returns the delay time in milliseconds before the camera is triggered. - * - * @return the delay time in milliseconds before the camera is triggered - */ - double delayBeforeCamera(); - - /** - * Returns the camera trigger duration in milliseconds. - * - * @return the camera trigger duration in milliseconds - */ - double cameraTriggerDuration(); - - /** - * Returns the duration in milliseconds that the camera shutter is open. - * - * @return the duration in milliseconds that the camera shutter is open - */ - double cameraExposure(); - - /** - * Returns the duration in milliseconds of each slice. - * - * @return the duration in milliseconds of each slice - */ - double sliceDuration(); + } - /** - * Returns true if the scan direction is inverted. - * - * @return true if the scan direction is inverted - */ - boolean useAlternateScanDirection(); } diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/VolumeSettings.java b/src/main/java/org/micromanager/lightsheetmanager/api/VolumeSettings.java index 27a4da7..a8ed47d 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/VolumeSettings.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/VolumeSettings.java @@ -1,74 +1,10 @@ package org.micromanager.lightsheetmanager.api; -// TODO: some way of specifying the view order for systems with up to 8 cameras - /** * Volume settings for microscope geometries that support volumetric imaging. */ public interface VolumeSettings { - interface Builder { - - /** - * Sets the number of views to use during an acquisition. - * - * @param numViews the number of views - */ - Builder numViews(final int numViews); - - /** - * Sets the imaging path to start the acquisition with. - * - * @param firstView the first view - */ - Builder firstView(final int firstView); - - /** - * Sets the delay between switching imaging paths in milliseconds. - * - * @param viewDelayMs the delay in milliseconds - */ - Builder delayBeforeView(final double viewDelayMs); - - Builder slicesPerView(final int n); - - Builder sliceStepSize(final double um); - - /** - * Sets the volume bounds, automatically computing numSlices and centerPosition. - * - * @param startPosition the start position - * @param endPosition the end position - * @param stepSizeUm the step size in micron - */ - Builder volumeBounds(final double startPosition, final double endPosition, final double stepSizeUm); - - /** - * Sets the volume bounds, automatically computing stepSizeUm and centerPosition. - * - * @param startPosition the start position - * @param endPosition the end position - * @param numSlices the number of slices - */ - Builder volumeBounds(final double startPosition, final double endPosition, final int numSlices); - - /** - * Sets the volume bounds, automatically computing startPosition and endPosition. - * - * @param centerPosition the center position - * @param numSlices the number of slices - * @param stepSizeUm the step size in microns - */ - Builder volumeBounds(final double centerPosition, final int numSlices, final double stepSizeUm); - - /** - * Creates an immutable instance of VolumeSettings - * - * @return Immutable version of VolumeSettings - */ - VolumeSettings build(); - } - /** * Returns a builder initialized with the current settings. * @@ -132,4 +68,68 @@ interface Builder { */ double endPosition(); + + interface Builder { + + /** + * Sets the number of views to use during an acquisition. + * + * @param numViews the number of views + */ + Builder numViews(final int numViews); + + /** + * Sets the imaging path to start the acquisition with. + * + * @param firstView the first view + */ + Builder firstView(final int firstView); + + /** + * Sets the delay between switching imaging paths in milliseconds. + * + * @param viewDelayMs the delay in milliseconds + */ + Builder delayBeforeView(final double viewDelayMs); + + Builder slicesPerView(final int n); + + Builder sliceStepSize(final double um); + + /** + * Sets the volume bounds, automatically computing numSlices and centerPosition. + * + * @param startPosition the start position + * @param endPosition the end position + * @param stepSizeUm the step size in micron + */ + Builder volumeBounds(final double startPosition, final double endPosition, final double stepSizeUm); + + /** + * Sets the volume bounds, automatically computing stepSizeUm and centerPosition. + * + * @param startPosition the start position + * @param endPosition the end position + * @param numSlices the number of slices + */ + Builder volumeBounds(final double startPosition, final double endPosition, final int numSlices); + + /** + * Sets the volume bounds, automatically computing startPosition and endPosition. + * + * @param centerPosition the center position + * @param numSlices the number of slices + * @param stepSizeUm the step size in microns + */ + Builder volumeBounds(final double centerPosition, final int numSlices, final double stepSizeUm); + + /** + * Creates an immutable instance of VolumeSettings + * + * @return Immutable version of VolumeSettings + */ + VolumeSettings build(); + + } + } diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultAutofocusSettings.java b/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultAutofocusSettings.java index 061cf7a..e7b9bd2 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultAutofocusSettings.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultAutofocusSettings.java @@ -4,47 +4,173 @@ import org.micromanager.lightsheetmanager.api.data.AutofocusMode; import org.micromanager.lightsheetmanager.api.data.AutofocusType; +import java.util.Objects; + public class DefaultAutofocusSettings implements AutofocusSettings { + private final boolean enabled_; + private final int numImages_; + private final double stepSizeUm_; + private final boolean showImages_; + private final boolean showGraph_; + private final AutofocusMode mode_; + private final AutofocusType scoringMethod_; + private final String channel_; + + private DefaultAutofocusSettings(Builder builder) { + enabled_ = builder.enabled_; + numImages_ = builder.numImages_; + stepSizeUm_ = builder.stepSizeUm_; + showImages_ = builder.showImages_; + showGraph_ = builder.showGraph_; + mode_ = builder.mode_; + scoringMethod_ = builder.scoringMethod_; + channel_ = builder.channel_; + } + public static Builder builder() { return new Builder(); } + public static Builder builder(AutofocusSettings settings) { + Objects.requireNonNull(settings, "Cannot copy from null settings"); + return new Builder(settings); + } + + @Override + public Builder copyBuilder() { + return new Builder(this); + } + + @Override + public boolean enabled() { + return enabled_; + } + + /** + * Returns the number of images used for autofocus routine. + * + * @return the number of images + */ + @Override + public int numImages() { + return numImages_; + } + + /** + * Returns the step size between images in microns. + * + * @return the step size in microns + */ + @Override + public double stepSizeUm() { + return stepSizeUm_; + } + + /** + * Returns the autofocus mode being used. + * + * @return the autofocus mode + */ + @Override + public AutofocusMode mode() { + return mode_; + } + + /** + * Returns {@code true} if showing images in the live view window. + * + * @return {@code true} if displaying images + */ + public boolean showImages() { + return showImages_; + } + + /** + * Returns {@code true} if the graph will be displayed after the autofocus routine. + * + * @return {@code true} if displaying the graph + */ + public boolean showGraph() { + return showGraph_; + } + + /** + * Returns the type of scoring algorithm used for autofocus. + * + * @return the type of scoring algorithm + */ + @Override + public AutofocusType scoringMethod() { + return scoringMethod_; + } + + /** + * Returns the channel autofocus is being run on. + * + * @return the autofocus channel + */ + @Override + public String channel() { + return channel_; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + DefaultAutofocusSettings other = (DefaultAutofocusSettings) obj; + return enabled_ == other.enabled_ && + numImages_ == other.numImages_ && + Double.compare(stepSizeUm_, other.stepSizeUm_) == 0 && + showImages_ == other.showImages_ && + showGraph_ == other.showGraph_ && + mode_ == other.mode_ && + scoringMethod_ == other.scoringMethod_ && + channel_.equals(other.channel_); + } + + @Override + public int hashCode() { + return Objects.hash(enabled_, numImages_, stepSizeUm_, + showImages_, showGraph_, mode_, scoringMethod_, channel_); + } + + @Override + public String toString() { + return String.format("%s[enabled=%s, numImages=%s, stepSizeUm=%s, " + + "showImages=%s, showGraph=%s, mode=%s, scoringMethod=%s, channel=%s]", + getClass().getSimpleName(), + enabled_, numImages_, stepSizeUm_, showImages_, showGraph_, mode_, scoringMethod_, channel_); + } + public static class Builder implements AutofocusSettings.Builder { private boolean enabled_ = false; private int numImages_ = 10; private double stepSizeUm_ = 1.0; - //private double toleranceUm_ = 1.0; private boolean showImages_ = false; private boolean showGraph_ = false; private AutofocusMode mode_ = AutofocusMode.FIXED_PIEZO_SWEEP_SLICE; private AutofocusType scoringMethod_ = AutofocusType.VOLATH5; private String channel_ = ""; -// private boolean useEveryStagePass_ = false; -// private boolean useBeforeAcquisition_ = false; -// private double maxOffset_ = 1.0; -// private boolean autoUpdateOffset_ = true; -// private double autoUpdateMaxOffset_ = 5.0; private Builder() { } - private Builder(final DefaultAutofocusSettings settings) { - enabled_ = settings.enabled_; - numImages_ = settings.numImages_; - stepSizeUm_ = settings.stepSizeUm_; - //toleranceUm_ = autofocusSettings.toleranceUm_; - showImages_ = settings.showImages_; - showGraph_ = settings.showGraph_; - mode_ = settings.mode_; - scoringMethod_ = settings.scoringMethod_; - channel_ = settings.channel_; - //useEveryStagePass_ = autofocusSettings.useEveryStagePass_; - //useBeforeAcquisition_ = autofocusSettings.useBeforeAcquisition_; -// maxOffset_ = autoUpdateMaxOffset_; -// autoUpdateOffset_ = autofocusSettings.autoUpdateOffset_; -// autoUpdateMaxOffset_ = autofocusSettings.autoUpdateMaxOffset_; + private Builder(final AutofocusSettings settings) { + enabled_ = settings.enabled(); + numImages_ = settings.numImages(); + stepSizeUm_ = settings.stepSizeUm(); + showImages_ = settings.showImages(); + showGraph_ = settings.showGraph(); + mode_ = settings.mode(); + scoringMethod_ = settings.scoringMethod(); + channel_ = settings.channel(); } @Override @@ -75,17 +201,6 @@ public Builder stepSizeUm(final double stepSize) { return this; } -// /** -// * Sets the tolerance in microns for the autofocus algorithm. -// * -// * @param value the tolerance in microns -// */ -// @Override -// public Builder toleranceUm(final double value) { -// toleranceUm_ = value; -// return this; -// } - /** * Set to {@code true} to show the images in the live view window. * @@ -141,46 +256,6 @@ public Builder channel(final String channel) { return this; } -// /** -// * Run autofocus every time we move to the next channel during an acquisition. -// * -// * @param state true to enable autofocus every stage pass -// */ -// @Override -// public Builder useEveryStagePass(final boolean state) { -// useEveryStagePass_ = state; -// return this; -// } -// -// /** -// * Run an autofocus routine before starting the acquisition. -// * -// * @param state true or false -// */ -// @Override -// public Builder useBeforeAcquisition(final boolean state) { -// useBeforeAcquisition_ = state; -// return this; -// } - -// @Override -// public Builder maxOffset(final double maxOffset) { -// maxOffset_ = maxOffset; -// return this; -// } -// -// @Override -// public Builder autoUpdateOffset(final boolean state) { -// autoUpdateOffset_ = state; -// return this; -// } -// -// @Override -// public Builder autoUpdateMaxOffset(final double um) { -// autoUpdateMaxOffset_ = um; -// return this; -// } - /** * Creates an immutable instance of AutofocusSettings * @@ -190,167 +265,7 @@ public Builder channel(final String channel) { public DefaultAutofocusSettings build() { return new DefaultAutofocusSettings(this); } - } - - - private final boolean enabled_; - private final int numImages_; - private final double stepSizeUm_; -// private final double toleranceUm_; - private final boolean showImages_; - private final boolean showGraph_; - private final AutofocusMode mode_; - private final AutofocusType scoringMethod_; - private final String channel_; -// private final boolean useEveryStagePass_; -// private final boolean useBeforeAcquisition_; -// private final double maxOffset_; -// private final boolean autoUpdateOffset_; -// private final double autoUpdateMaxOffset_; - - private DefaultAutofocusSettings(Builder builder) { - enabled_ = builder.enabled_; - numImages_ = builder.numImages_; - stepSizeUm_ = builder.stepSizeUm_; - // toleranceUm_ = builder.toleranceUm_; - showImages_ = builder.showImages_; - showGraph_ = builder.showGraph_; - mode_ = builder.mode_; - scoringMethod_ = builder.scoringMethod_; - channel_ = builder.channel_; -// useEveryStagePass_ = builder.useEveryStagePass_; -// useBeforeAcquisition_ = builder.useBeforeAcquisition_; -// maxOffset_ = builder.maxOffset_; -// autoUpdateOffset_ = builder.autoUpdateOffset_; -// autoUpdateMaxOffset_ = builder.autoUpdateMaxOffset_; - } - public Builder copyBuilder() { - return new Builder(this); - } - - @Override - public boolean enabled() { - return enabled_; } - /** - * Returns the number of images used for autofocus routine. - * - * @return the number of images - */ - @Override - public int numImages() { - return numImages_; - } - - /** - * Returns the step size between images in microns. - * - * @return the step size in microns - */ - @Override - public double stepSizeUm() { - return stepSizeUm_; - } - - /** - * Returns the autofocus mode being used. - * - * @return the autofocus mode - */ - @Override - public AutofocusMode mode() { - return mode_; - } - -// /** -// * Returns the tolerance in microns used in the autofocus routine. -// * -// * @return the coefficient of determination -// */ -// @Override -// public double toleranceUm() { -// return toleranceUm_; -// } - - /** - * Returns {@code true} if showing images in the live view window. - * - * @return {@code true} if displaying images - */ - public boolean showImages() { - return showImages_; - } - - /** - * Returns {@code true} if the graph will be displayed after the autofocus routine. - * - * @return {@code true} if displaying the graph - */ - public boolean showGraph() { - return showGraph_; - } - - /** - * Returns the type of scoring algorithm used for autofocus. - * - * @return the type of scoring algorithm - */ - @Override - public AutofocusType scoringMethod() { - return scoringMethod_; - } - - - /** - * Returns the channel autofocus is being run on. - * - * @return the autofocus channel - */ - @Override - public String channel() { - return channel_; - } - -// /** -// * Returns true if autofocus is run every stage pass. -// * -// * @return true if autofocus is run every stage pass -// */ -// @Override -// public boolean useEveryStagePass() { -// return useEveryStagePass_; -// } -// -// /** -// * Returns true if we run an autofocus routine before starting an acquisition. -// * -// * @return true if enabled -// */ -// @Override -// public boolean useBeforeAcquisition() { -// return useBeforeAcquisition_; -// } - -// /** -// * What is this? -// * -// * @return -// */ -// @Override -// public double maxOffset() { -// return maxOffset_; -// } -// -// @Override -// public boolean autoUpdateOffset() { -// return autoUpdateOffset_; -// } -// -// @Override -// public double autoUpdateMaxOffset() { -// return autoUpdateMaxOffset_; -// } - } diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultChannelSettings.java b/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultChannelSettings.java index 6f69155..4495f47 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultChannelSettings.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultChannelSettings.java @@ -13,8 +13,8 @@ public class DefaultChannelSettings implements ChannelSettings { private final boolean enabled_; - private final String group_; private final ChannelMode mode_; + private final String group_; private final HashMap groups_; // default value for when the channel group key is not found @@ -22,8 +22,8 @@ public class DefaultChannelSettings implements ChannelSettings { private DefaultChannelSettings(Builder builder) { enabled_ = builder.enabled_; - group_ = builder.group_; mode_ = builder.mode_; + group_ = builder.group_; groups_ = builder.groups_; } @@ -167,8 +167,8 @@ public int hashCode() { public static class Builder implements ChannelSettings.Builder { private boolean enabled_ = false; - private String group_ = ""; private ChannelMode mode_ = ChannelMode.VOLUME; + private String group_ = ""; private HashMap groups_ = new HashMap<>(); private Builder() { @@ -176,8 +176,8 @@ private Builder() { public Builder(final ChannelSettings settings) { enabled_ = settings.enabled(); - group_ = settings.group(); mode_ = settings.mode(); + group_ = settings.group(); groups_ = new HashMap<>(); // deep copy settings.groups().forEach((name, channels) -> { diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultSheetCalibration.java b/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultSheetCalibration.java index 0a0760c..0bb4da8 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultSheetCalibration.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultSheetCalibration.java @@ -9,7 +9,7 @@ public class DefaultSheetCalibration implements SheetCalibration { private final double imagingCenter_; private final double sheetWidth_; private final double sheetOffset_; - private final boolean useAutoSheetWidth_; + private final boolean autoSheetWidthEnabled_; private final double autoSheetWidthPerPixel_; private final double scanSpeed_; private final double scanOffset_; @@ -18,7 +18,7 @@ private DefaultSheetCalibration(Builder builder) { imagingCenter_ = builder.imagingCenter_; sheetWidth_ = builder.sheetWidth_; sheetOffset_ = builder.sheetOffset_; - useAutoSheetWidth_ = builder.useAutoSheetWidth_; + autoSheetWidthEnabled_ = builder.autoSheetWidthEnabled_; autoSheetWidthPerPixel_ = builder.autoSheetWidthPerPixel_; scanSpeed_ = builder.scanSpeed_; scanOffset_ = builder.scanOffset_; @@ -56,8 +56,8 @@ public double sheetOffset() { } @Override - public boolean isUsingAutoSheetWidth() { - return useAutoSheetWidth_; + public boolean autoSheetWidthEnabled() { + return autoSheetWidthEnabled_; } @Override @@ -89,7 +89,7 @@ public boolean equals(Object obj) { return Double.compare(imagingCenter_, other.imagingCenter_) == 0 && Double.compare(sheetWidth_, other.sheetWidth_) == 0 && Double.compare(sheetOffset_, other.sheetOffset_) == 0 && - useAutoSheetWidth_ == other.useAutoSheetWidth_ && + autoSheetWidthEnabled_ == other.autoSheetWidthEnabled_ && Double.compare(autoSheetWidthPerPixel_, other.autoSheetWidthPerPixel_) == 0 && Double.compare(scanSpeed_, other.scanSpeed_) == 0 && Double.compare(scanOffset_, other.scanOffset_) == 0; @@ -98,16 +98,16 @@ public boolean equals(Object obj) { @Override public int hashCode() { return Objects.hash(imagingCenter_, sheetWidth_, sheetOffset_, - useAutoSheetWidth_, autoSheetWidthPerPixel_, scanSpeed_, scanOffset_); + autoSheetWidthEnabled_, autoSheetWidthPerPixel_, scanSpeed_, scanOffset_); } @Override public String toString() { return String.format("%s[imagingCenter=%s, sheetWidth=%s, sheetOffset=%s, " + - "useAutoSheetWidth=%s, autoSheetWidthPerPixel=%s, scanSpeed=%s, scanOffset=%s]", + "autoSheetWidthEnabled=%s, autoSheetWidthPerPixel=%s, scanSpeed=%s, scanOffset=%s]", getClass().getSimpleName(), imagingCenter_, sheetWidth_, sheetOffset_, - useAutoSheetWidth_, autoSheetWidthPerPixel_, scanSpeed_, scanOffset_); + autoSheetWidthEnabled_, autoSheetWidthPerPixel_, scanSpeed_, scanOffset_); } public static class Builder implements SheetCalibration.Builder { @@ -115,7 +115,7 @@ public static class Builder implements SheetCalibration.Builder { private double imagingCenter_ = 0.0; private double sheetWidth_ = 0.0; private double sheetOffset_ = 0.0; - private boolean useAutoSheetWidth_ = false; + private boolean autoSheetWidthEnabled_ = false; private double autoSheetWidthPerPixel_ = 0.0; private double scanSpeed_ = 0.0; private double scanOffset_ = 0.0; @@ -127,7 +127,7 @@ private Builder(final SheetCalibration settings) { imagingCenter_ = settings.imagingCenter(); sheetWidth_ = settings.sheetWidth(); sheetOffset_ = settings.sheetOffset(); - useAutoSheetWidth_ = settings.isUsingAutoSheetWidth(); + autoSheetWidthEnabled_ = settings.autoSheetWidthEnabled(); autoSheetWidthPerPixel_ = settings.autoSheetWidthPerPixel(); scanSpeed_ = settings.scanSpeed(); scanOffset_ = settings.scanOffset(); @@ -154,8 +154,8 @@ public Builder sheetOffset(double offset) { } @Override - public Builder useAutoSheetWidth(boolean state) { - useAutoSheetWidth_ = state; + public Builder autoSheetWidthEnabled(boolean state) { + autoSheetWidthEnabled_ = state; return this; } diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultSliceCalibration.java b/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultSliceCalibration.java index c2a75d6..a61f8fc 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultSliceCalibration.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultSliceCalibration.java @@ -6,12 +6,12 @@ public class DefaultSliceCalibration implements SliceCalibration { - private final double sliceSlope_; - private final double sliceOffset_; + private final double slope_; + private final double offset_; private DefaultSliceCalibration(Builder builder) { - sliceSlope_ = builder.sliceSlope_; - sliceOffset_ = builder.sliceOffset_; + slope_ = builder.slope_; + offset_ = builder.offset_; } public static Builder builder() { @@ -29,13 +29,13 @@ public Builder copyBuilder() { } @Override - public double sliceSlope() { - return sliceSlope_; + public double slope() { + return slope_; } @Override - public double sliceOffset() { - return sliceOffset_; + public double offset() { + return offset_; } @Override @@ -47,43 +47,42 @@ public boolean equals(Object obj) { return false; } DefaultSliceCalibration other = (DefaultSliceCalibration) obj; - return Double.compare(sliceSlope_, other.sliceSlope_) == 0 && - Double.compare(sliceOffset_, other.sliceOffset_) == 0; + return Double.compare(slope_, other.slope_) == 0 && + Double.compare(offset_, other.offset_) == 0; } @Override public int hashCode() { - return Objects.hash(sliceSlope_, sliceOffset_); + return Objects.hash(slope_, offset_); } @Override public String toString() { - return String.format("%s[sliceSlope=%s, sliceOffset=%s]", - getClass().getSimpleName(), sliceSlope_, sliceOffset_); + return String.format("%s[slope=%s, offset=%s]", + getClass().getSimpleName(), slope_, offset_); } public static class Builder implements SliceCalibration.Builder { - - private double sliceSlope_ = 0.0; - private double sliceOffset_ = 0.0; + private double slope_ = 0.0; + private double offset_ = 0.0; private Builder() { } private Builder(final SliceCalibration settings) { - sliceSlope_ = settings.sliceSlope(); - sliceOffset_ = settings.sliceOffset(); + slope_ = settings.slope(); + offset_ = settings.offset(); } @Override - public Builder sliceSlope(final double slope) { - sliceSlope_ = slope; + public Builder slope(final double slope) { + slope_ = slope; return this; } @Override - public Builder sliceOffset(final double offset) { - sliceOffset_ = offset; + public Builder offset(final double offset) { + offset_ = offset; return this; } diff --git a/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultSliceSettings.java b/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultSliceSettings.java index 0a9cb6d..e3cf6ed 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultSliceSettings.java +++ b/src/main/java/org/micromanager/lightsheetmanager/api/internal/DefaultSliceSettings.java @@ -101,7 +101,7 @@ public Builder sampleExposure(double exposureMs) { } @Override - public Builder minimizePeriod(boolean state) { + public Builder periodMinimized(boolean state) { periodMinimized_ = state; return this; } diff --git a/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/acquisition/SlicePanel.java b/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/acquisition/SlicePanel.java index a1b2e61..c453ac4 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/acquisition/SlicePanel.java +++ b/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/acquisition/SlicePanel.java @@ -97,7 +97,7 @@ private void createEventHandlers() { lblSlicePeriod_.setEnabled(!selected); spnSlicePeriod_.setEnabled(!selected); model_.acquisitions().settingsBuilder() - .sliceBuilder().minimizePeriod(selected); + .sliceBuilder().periodMinimized(selected); // update slice timing model_.acquisitions().updateAcquisitionSettings(); model_.acquisitions().recalculateSliceTiming(); diff --git a/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/setup/PiezoCalibrationPanel.java b/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/setup/PiezoCalibrationPanel.java index e37aaa7..df961c8 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/setup/PiezoCalibrationPanel.java +++ b/src/main/java/org/micromanager/lightsheetmanager/gui/tabs/setup/PiezoCalibrationPanel.java @@ -86,8 +86,8 @@ private void createUserInterface() { txtOffset_ = new TextField(7); txtStepSize_ = new TextField(); - final double sliceSlope = acqSettings.sliceCalibration().sliceSlope(); - final double sliceOffset = acqSettings.sliceCalibration().sliceOffset(); + final double sliceSlope = acqSettings.sliceCalibration().slope(); + final double sliceOffset = acqSettings.sliceCalibration().offset(); txtSlope_.setText("0"); txtOffset_.setText("0"); @@ -157,7 +157,7 @@ private void createEventHandlers() { btnUpdate_.registerListener(e -> { if (scanner.isBeamOn()) { final double rate = model_.acquisitions().settings() - .sliceCalibration().sliceSlope(); + .sliceCalibration().slope(); final double piezoPosition = piezo.getPosition(); final double scannerPosition = scanner.getPosition().y; double channelOffset = 0.0; @@ -170,7 +170,7 @@ private void createEventHandlers() { model_.acquisitions().settingsBuilder() .sheetCalibrationBuilder().imagingCenter(newOffset); model_.acquisitions().settingsBuilder() - .sliceCalibrationBuilder().sliceOffset(newOffset); + .sliceCalibrationBuilder().offset(newOffset); model_.studio().logs().logMessage("updated offset for view " + pathNum_ + "; new value is " + newOffset + " (with channel offset of " + channelOffset + ")"); } @@ -187,14 +187,14 @@ private void createEventHandlers() { txtSlope_.registerListener(e -> { final double slope = Double.parseDouble(txtSlope_.getText()); model_.acquisitions().settingsBuilder() - .sliceCalibrationBuilder().sliceSlope(slope); + .sliceCalibrationBuilder().slope(slope); lblSlopeValue_.setText(String.format("%.3f μm/°", slope)); }); txtOffset_.registerListener(e -> { final double offset = Double.parseDouble(txtOffset_.getText()); model_.acquisitions().settingsBuilder() - .sliceCalibrationBuilder().sliceOffset(offset); + .sliceCalibrationBuilder().offset(offset); lblOffsetValue_.setText(String.format("%.3f μm", offset)); // also update the imaging center on the position panel panel_.setImagingCenterValue(offset); diff --git a/src/main/java/org/micromanager/lightsheetmanager/model/PLogicDispim.java b/src/main/java/org/micromanager/lightsheetmanager/model/PLogicDispim.java index b893b51..c49e280 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/model/PLogicDispim.java +++ b/src/main/java/org/micromanager/lightsheetmanager/model/PLogicDispim.java @@ -589,15 +589,15 @@ public boolean prepareControllerForAcquisitionSide( } // FIXME: more light sheet setup - final double slope1 = settings.sliceCalibration(1).sliceSlope(); - final double slope2 = settings.sliceCalibration(2).sliceSlope(); + final double slope1 = settings.sliceCalibration(1).slope(); + final double slope2 = settings.sliceCalibration(2).slope(); double sliceRate = (view == 1) ? slope1 : slope2; if (NumberUtils.doublesEqual(sliceRate, 0.0)) { studio_.logs().showError("Calibration slope for view " + view + " cannot be zero. Re-do calibration on Setup tab."); return false; } - final double offset1 = settings.sliceCalibration(1).sliceOffset() + channelOffset; - final double offset2 = settings.sliceCalibration(2).sliceOffset() + channelOffset; + final double offset1 = settings.sliceCalibration(1).offset() + channelOffset; + final double offset2 = settings.sliceCalibration(2).offset() + channelOffset; double sliceOffset = (view == 1) ? offset1 : offset2; double sliceAmplitude = piezoAmplitude / sliceRate; double sliceCenter = (piezoCenter - sliceOffset) / sliceRate; @@ -1039,7 +1039,7 @@ public double getSheetWidth(CameraMode cameraMode, int view) { // final float slopePolarity = (side == Devices.Sides.B) ? -1 : 1; // sheetWidth = roi.height * sheetSlope * slopePolarity / 1e6; // in microdegrees per pixel, convert to degrees } else { - final boolean autoSheet = model_.getAcquisitionEngine().settings().sheetCalibration().isUsingAutoSheetWidth(); + final boolean autoSheet = model_.getAcquisitionEngine().settings().sheetCalibration().autoSheetWidthEnabled(); if (autoSheet) { Rectangle roi = camera.getROI(); if (roi == null || roi.height == 0) { diff --git a/src/main/java/org/micromanager/lightsheetmanager/model/PLogicScape.java b/src/main/java/org/micromanager/lightsheetmanager/model/PLogicScape.java index 2f9716d..9cbf1bb 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/model/PLogicScape.java +++ b/src/main/java/org/micromanager/lightsheetmanager/model/PLogicScape.java @@ -485,14 +485,14 @@ public boolean prepareControllerForAcquisitionSide( // FIXME: more light sheet setup //final double slope1 = settings.sliceCalibration(1).sliceSlope(); //final double slope2 = settings.sliceCalibration(2).sliceSlope(); - double sliceRate = settings.sliceCalibration().sliceSlope();//(view == 1) ? slope1 : slope2; + double sliceRate = settings.sliceCalibration().slope();//(view == 1) ? slope1 : slope2; if (NumberUtils.doublesEqual(sliceRate, 0.0)) { studio_.logs().showError("Calibration slope for view " + view + " cannot be zero. Re-do calibration on Setup tab."); return false; } //final double offset1 = settings.sliceCalibration(1).sliceOffset() + channelOffset; //final double offset2 = settings.sliceCalibration(2).sliceOffset() + channelOffset; - double sliceOffset = settings.sliceCalibration().sliceOffset() + channelOffset; //(view == 1) ? offset1 : offset2; + double sliceOffset = settings.sliceCalibration().offset() + channelOffset; //(view == 1) ? offset1 : offset2; double sliceAmplitude = piezoAmplitude / sliceRate; double sliceCenter = (piezoCenter - sliceOffset) / sliceRate; @@ -937,7 +937,7 @@ public double getSheetWidth(CameraMode cameraMode, int view) { // final float slopePolarity = (side == Devices.Sides.B) ? -1 : 1; // sheetWidth = roi.height * sheetSlope * slopePolarity / 1e6; // in microdegrees per pixel, convert to degrees } else { - final boolean autoSheet = model_.getAcquisitionEngine().settings().sheetCalibration().isUsingAutoSheetWidth(); + final boolean autoSheet = model_.getAcquisitionEngine().settings().sheetCalibration().autoSheetWidthEnabled(); if (autoSheet) { Rectangle roi = camera.getROI(); if (roi == null || roi.height == 0) { 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 5f4e182..e9dab8a 100644 --- a/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineScape.java +++ b/src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineScape.java @@ -72,7 +72,7 @@ boolean setup() { studio_.logs().logMessage("stopped position polling"); } - asb_.sheetCalibrationBuilder().useAutoSheetWidth(true); + asb_.sheetCalibrationBuilder().autoSheetWidthEnabled(true); asb_.sheetCalibrationBuilder().autoSheetWidthPerPixel(0.0); // make settings current