Skip to content

Commit a4e0a28

Browse files
authored
Merge pull request #533 from bls337/main
Show a bad save name when the plugin opens, and remove unused SCAPE sheet width code
2 parents 0cce138 + fb2d87f commit a4e0a28

5 files changed

Lines changed: 6 additions & 172 deletions

File tree

‎src/main/java/org/micromanager/lightsheetmanager/api/AcquisitionSettings.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ interface Builder<T extends Builder<T>> {
2424
* Sets the folder name.
2525
*
2626
* @param name the name of the folder
27+
* @throws IllegalArgumentException if the name cannot be used as a Windows file name
2728
*/
2829
T saveNamePrefix(final String name);
2930

@@ -53,6 +54,8 @@ interface Builder<T extends Builder<T>> {
5354
*
5455
* @param mode the camera mode
5556
* @return {@code this} builder
57+
* @throws IllegalArgumentException if the microscope does not support the mode
58+
* (SCAPE does not support virtual slit)
5659
*/
5760
T cameraMode(final CameraMode mode);
5861

‎src/main/java/org/micromanager/lightsheetmanager/gui/components/TextField.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void registerListener(final Runnable listener) {
3535
}
3636

3737
/**
38-
* Registers a listener that checks the current text whenever the document changes,
38+
* Registers a listener that checks the text now and whenever the document changes,
3939
* and shows the error color while the text has a problem.
4040
*
4141
* @param problemOf returns why the text is invalid, or null when it is valid
@@ -67,6 +67,7 @@ public void changedUpdate(DocumentEvent e) {
6767
};
6868

6969
getDocument().addDocumentListener(docListener);
70+
validate.run(); // check the text the field already holds
7071
}
7172

7273
/**

‎src/main/java/org/micromanager/lightsheetmanager/model/PLogicScape.java‎

Lines changed: 1 addition & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
import org.micromanager.lightsheetmanager.LightSheetManager;
77
import org.micromanager.lightsheetmanager.api.data.AcquisitionMode;
88
import org.micromanager.lightsheetmanager.api.data.CameraMode;
9-
import org.micromanager.lightsheetmanager.api.data.GeometryType;
109
import org.micromanager.lightsheetmanager.api.data.ChannelMode;
1110
import org.micromanager.lightsheetmanager.api.internal.ScapeAcquisitionSettings;
1211
import org.micromanager.lightsheetmanager.model.acquisitions.AcquisitionEngineScape;
1312
import org.micromanager.lightsheetmanager.model.acquisitions.CameraTriggers;
1413
import org.micromanager.lightsheetmanager.model.channels.ChannelSpec;
15-
import org.micromanager.lightsheetmanager.model.devices.cameras.CameraBase;
1614
import org.micromanager.lightsheetmanager.model.devices.vendor.ASIPLogic;
1715
import org.micromanager.lightsheetmanager.model.devices.vendor.ASIPiezo;
1816
import org.micromanager.lightsheetmanager.model.devices.vendor.ASIScanner;
@@ -22,7 +20,6 @@
2220
import org.micromanager.lightsheetmanager.model.utils.GeometryUtils;
2321
import org.micromanager.lightsheetmanager.model.utils.NumberUtils;
2422

25-
import java.awt.Rectangle;
2623
import java.awt.geom.Point2D;
2724
import java.util.Objects;
2825

@@ -627,23 +624,7 @@ public boolean prepareControllerForAcquisitionSide(
627624
// set interleaved sides flag low unless we are doing interleaved stage scan
628625
scanner_.setSPIMInterleaveSides(isInterleaved);
629626

630-
// send sheet width/offset
631-
double sheetWidth = getSheetWidth(acqSettings_.cameraMode(), view);
632-
double sheetOffset = getSheetOffset(acqSettings_.cameraMode(), view);
633-
if (cameraMode == CameraMode.VIRTUAL_SLIT) {
634-
// adjust sheet width and offset to account for settle time where scan is going but we aren't imaging yet
635-
// FIXME: !!!
636-
//final float settleTime = props_.getPropValueFloat(Devices.Keys.PLUGIN, Properties.Keys.PLUGIN_LS_SCAN_SETTLE);
637-
// infer the main scan time (during imaging) from the laser duration
638-
// final float readoutTime = settings.timingSettings().laserTriggerDurationMs() - 0.25; // -0.25 is for scanLaserBufferTime
639-
// // offset should be decreased by half of the distance traveled during settle time (instead of re-extracting slope use existing sheetWidth/readoutTime)
640-
// sheetOffset -= (sheetWidth * settleTime/readoutTime)/2;
641-
// // width should be increased by ratio (1 + settle_fraction)
642-
// sheetWidth += (sheetWidth * settleTime/readoutTime);
643-
}
644-
// SCOPE should not modify the x-axis of the galvo
645-
// scanner_.sa().setAmplitudeX(sheetWidth);
646-
// scanner_.sa().setOffsetX(sheetOffset);
627+
// SCAPE leaves the galvo's x axis alone, so no sheet width or offset is sent
647628
}
648629
return true;
649630
}
@@ -932,98 +913,6 @@ private boolean doesPLogicChannelIncludeLaser(final int laserNum, final ChannelS
932913
}
933914
}
934915

935-
// TODO: need sheet width settings in AcquisitionSettings
936-
/**
937-
* gets the sheet width for the specified settings in units of degrees
938-
* @param cameraMode
939-
* @param view
940-
* @return 0 if camera isn't assigned
941-
*/
942-
public double getSheetWidth(CameraMode cameraMode, int view) {
943-
double sheetWidth;
944-
//final String cameraName = devices_.getMMDevice(cameraDevice);
945-
String deviceName = "ImagingCamera" + view; // diSPIM
946-
if (model_.devices().adapter().geometry() == GeometryType.SCAPE) {
947-
deviceName = "ImagingCamera";
948-
if (model_.devices().adapter().numSimultaneousCameras() > 1 ) {
949-
deviceName += String.valueOf(view);
950-
}
951-
}
952-
CameraBase camera = devices_.device(deviceName); // TODO: find a way of adapting to different cameras
953-
String cameraName = camera.getDeviceName(); // TODO: put this on LSM camera?
954-
955-
// // start by assuming the base value, then modify below if needed
956-
// final Properties.Keys widthProp = (side == Devices.Sides.A) ?
957-
// Properties.Keys.PLUGIN_SHEET_WIDTH_EDGE_A : Properties.Keys.PLUGIN_SHEET_WIDTH_EDGE_B;
958-
// sheetWidth = props_.getPropValueFloat(Devices.Keys.PLUGIN, widthProp);
959-
sheetWidth = model_.acquisitions().settings().sheetCalibration().sheetWidth();
960-
961-
if (cameraName == null || cameraName.isEmpty()) {
962-
studio_.logs().logDebugMessage("Could not get sheet width for invalid device " + cameraName);
963-
return sheetWidth;
964-
}
965-
966-
if (cameraMode == CameraMode.VIRTUAL_SLIT) {
967-
// TODO: this!
968-
// final float sheetSlope = prefs_.getFloat(
969-
// MyStrings.PanelNames.SETUP.toString() + side.toString(),
970-
// Properties.Keys.PLUGIN_LIGHTSHEET_SLOPE, 2000);
971-
// Rectangle roi = cameras_.getCameraROI(cameraDevice); // get binning-adjusted ROI so value can stay the same regardless of binning
972-
// if (roi == null || roi.height == 0) {
973-
// studio_.logs().logDebugMessage("Could not get camera ROI for light sheet mode");
974-
// }
975-
// final float slopePolarity = (side == Devices.Sides.B) ? -1 : 1;
976-
// sheetWidth = roi.height * sheetSlope * slopePolarity / 1e6; // in microdegrees per pixel, convert to degrees
977-
} else {
978-
final boolean autoSheet = model_.acquisitions().settings().sheetCalibration().autoSheetWidthEnabled();
979-
if (autoSheet) {
980-
// unbinned, so the sheet width stays the same regardless of binning
981-
Rectangle roi = camera.getUnbinnedROI();
982-
if (roi == null || roi.height == 0) {
983-
studio_.logs().logDebugMessage("Could not get camera ROI for auto sheet mode");
984-
}
985-
final double sheetSlope = model_.acquisitions().settings().sheetCalibration().autoSheetWidthPerPixel();
986-
sheetWidth = roi.height * sheetSlope / 1000.0; // in millidegrees per pixel, convert to degrees
987-
sheetWidth *= 1.1; // 10% extra width just to be sure
988-
}
989-
// final boolean autoSheet = prefs_.getBoolean(
990-
// MyStrings.PanelNames.SETUP.toString() + side.toString(),
991-
// Properties.Keys.PREFS_AUTO_SHEET_WIDTH, false);
992-
// if (autoSheet) {
993-
// Rectangle roi = cameras_.getCameraROI(cameraDevice); // get binning-adjusted ROI so value can stay the same regardless of binning
994-
// if (roi == null || roi.height == 0) {
995-
// studio_.logs().logDebugMessage("Could not get camera ROI for auto sheet mode");
996-
// }
997-
// final float sheetSlope = prefs_.getFloat(MyStrings.PanelNames.SETUP.toString() + side.toString(),
998-
// Properties.Keys.PLUGIN_SLOPE_SHEET_WIDTH.toString(), 2);
999-
// sheetWidth = roi.height * sheetSlope / 1000; // in millidegrees per pixel, convert to degrees
1000-
// // TODO add extra width to compensate for filter depending on sweep rate and filter freq
1001-
// // TODO calculation should account for sample exposure to make sure 0.25ms edges get appropriately compensated for
1002-
// sheetWidth *= 1.1; // 10% extra width just to be sure
1003-
// }
1004-
}
1005-
return sheetWidth;
1006-
}
1007-
1008-
// TODO: needs properties
1009-
public double getSheetOffset(CameraMode cameraMode, int view) {
1010-
double sheetOffset;
1011-
if (cameraMode == CameraMode.VIRTUAL_SLIT) {
1012-
// in millidegrees, convert to degrees
1013-
// TODO: is this correct?
1014-
sheetOffset = model_.acquisitions().settings().sheetCalibration().sheetOffset() / 1000.0;
1015-
//sheetOffset = prefs_.getFloat(
1016-
//MyStrings.PanelNames.SETUP.toString() + side.toString(),
1017-
//Properties.Keys.PLUGIN_LIGHTSHEET_OFFSET, 0) / 1000; // in millidegrees, convert to degrees
1018-
} else {
1019-
sheetOffset = model_.acquisitions().settings().sheetCalibration().sheetOffset();
1020-
//final Properties.Keys offsetProp = (side == Devices.Sides.A) ?
1021-
// Properties.Keys.PLUGIN_SHEET_OFFSET_EDGE_A : Properties.Keys.PLUGIN_SHEET_OFFSET_EDGE_B;
1022-
// sheetOffset = props_.getPropValueFloat(Devices.Keys.PLUGIN, offsetProp);
1023-
}
1024-
return sheetOffset;
1025-
}
1026-
1027916
/**
1028917
* Gets the actual step size for stage scanning acquisitions.
1029918
* Only valid after call to prepareControllerForAcquisition().

‎src/main/java/org/micromanager/lightsheetmanager/model/acquisitions/AcquisitionEngineScape.java‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ boolean setup() {
114114
studio_.logs().logMessage("stopped position polling");
115115
}
116116

117-
asb_.sheetCalibrationBuilder().autoSheetWidthEnabled(true);
118-
asb_.sheetCalibrationBuilder().autoSheetWidthPerPixel(0.0);
119-
120117
// make settings current
121118
updateSettings();
122119

‎src/main/java/org/micromanager/lightsheetmanager/model/playlist/AcquisitionTableData.java‎

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -282,60 +282,4 @@ public void setMetadataPositionListName(final int row, final String name) {
282282
data.setPositionListName(name);
283283
}
284284

285-
// -----------
286-
// Debug Tools
287-
// -----------
288-
289-
public void printMetadataNames() {
290-
report("Metadata Acq Names =>");
291-
for (final AcquisitionMetadata data : metadata_) {
292-
report(data.getAcquisitionName());
293-
}
294-
}
295-
296-
public void printPositionNames() {
297-
report("PositionList HashMap Keys =>");
298-
for (final String name : positions_.keySet()) {
299-
report(name);
300-
}
301-
}
302-
303-
public void printSettingNames() {
304-
report("AcquisitionSettings HashMap Keys =>");
305-
for (final String name : settings_.keySet()) {
306-
report(name);
307-
}
308-
}
309-
310-
/**
311-
* A useful method for validating that everything is in sync between the metadata and
312-
* settings fields. There should be a key in the settings HashMap that corresponds
313-
* to each acquistionName field in the metadata ArrayList.
314-
*
315-
* @return true if everything is okay
316-
*/
317-
public boolean validateKeysWithMetadata() {
318-
// validate size
319-
final int size = metadata_.size();
320-
if (size != settings_.size()) {
321-
report("Validate Error: Size of metadata does not equal size of settings.");
322-
return false;
323-
}
324-
// validate keys
325-
for (final AcquisitionMetadata data : metadata_) {
326-
final String name = data.getAcquisitionName();
327-
if (settings_.get(name) == null) {
328-
report("Validate Error: Missing key \"" + name + "\" in settings HashMap.");
329-
return false;
330-
}
331-
}
332-
report("Validate Success: Metadata and settings are in sync.");
333-
return true;
334-
}
335-
336-
// you can change this method to report however you like (log file, etc)
337-
private void report(final String message) {
338-
System.out.println(message);
339-
}
340-
341285
}

0 commit comments

Comments
 (0)