Skip to content

Commit

Permalink
ASIdiSPIM plugin: Added AcquisitionSettings class and started using i…
Browse files Browse the repository at this point in the history
…t to help make the acquisitioncode more readable

git-svn-id: https://valelab.ucsf.edu/svn/micromanager2/trunk@15599 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd
  • Loading branch information
nico committed Jul 8, 2015
1 parent c15118e commit ff7c640
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
import java.awt.geom.Point2D;

import javax.swing.BorderFactory;
import org.micromanager.asidispim.Data.AcquisitionSettings;

import org.micromanager.asidispim.Data.ChannelSpec;
import org.micromanager.asidispim.Data.Devices.Sides;
Expand Down Expand Up @@ -841,7 +842,7 @@ private boolean isTwoSided() {
return (numSides_.getSelectedIndex() == 1);
}

private int getNumTimepoints() {
private int getNumTimePoints() {
if (!useTimepointsCB_.isSelected()) {
return 1;
}
Expand All @@ -852,7 +853,7 @@ private double getTimePointInterval() {
return (double) PanelUtils.getSpinnerFloatValue(acquisitionInterval_);
}

private boolean isMultichannel() {
private boolean isMultiChannel() {
return multiChannelPanel_.isPanelEnabled() && multiChannelPanel_.getUsedChannels().length > 1;
}

Expand All @@ -874,7 +875,7 @@ private boolean isStageScanning() {
* selection otherwise
*/
private MultichannelModes.Keys getChannelMode() {
if (isMultichannel()) {
if (isMultiChannel()) {
return MultichannelModes.getKeyFromPrefCode(
props_.getPropValueInteger(Devices.Keys.PLUGIN,
Properties.Keys.PLUGIN_MULTICHANNEL_MODE));
Expand Down Expand Up @@ -1149,7 +1150,7 @@ private void updateActualVolumeDurationLabel() {
* @return duration in s
*/
private double computeActualTimeLapseDuration() {
double duration = (getNumTimepoints() - 1) * getTimePointInterval()
double duration = (getNumTimePoints() - 1) * getTimePointInterval()
+ computeActualVolumeDuration()/1000;
return duration;
}
Expand Down Expand Up @@ -1273,13 +1274,13 @@ private void updateAcquisitionStatus(AcquisitionStatus phase, int secsToNextAcqu
text = "Acquiring time point "
+ NumberUtils.intToDisplayString(numTimePointsDone_)
+ " of "
+ NumberUtils.intToDisplayString(getNumTimepoints());
+ NumberUtils.intToDisplayString(getNumTimePoints());
break;
case WAITING:
text = "Next timepoint ("
+ NumberUtils.intToDisplayString(numTimePointsDone_+1)
+ " of "
+ NumberUtils.intToDisplayString(getNumTimepoints())
+ NumberUtils.intToDisplayString(getNumTimePoints())
+ ") in "
+ NumberUtils.intToDisplayString(secsToNextAcquisition)
+ " s.";
Expand Down Expand Up @@ -1317,6 +1318,26 @@ private static void componentsSetEnabled(Container container, boolean enabled) {
}
}

private AcquisitionSettings generateAcquisitionSettings(boolean hardwareTimePoints) {
AcquisitionSettings acqSettings = new AcquisitionSettings();
acqSettings.hardwareTimepoints_ = hardwareTimePoints;
acqSettings.channelMode_ = getChannelMode();
acqSettings.useChannels_ = isMultiChannel();
acqSettings.numSlices_ = getNumSlices();
acqSettings.numTimepoints_ = getNumTimePoints();
acqSettings.timePointInterval_ = getTimePointInterval();
acqSettings.numSides_ = getNumSides();
acqSettings.firstSide_ = getFirstSide();
acqSettings.useTimepoints_ = useTimepointsCB_.isSelected();
acqSettings.spimMode_ = getAcquisitionMode();
acqSettings.centerAtCurrentZ_ = false;
acqSettings.delayBeforeSide_ = getDelayBeforeSide();
acqSettings.stepSizeUm_ = getStepSizeUm();
acqSettings.sliceTiming_ = sliceTiming_;

return acqSettings;
}

/**
* Sets all the controller's properties according to volume settings
* and otherwise gets controller all ready for acquisition
Expand All @@ -1327,13 +1348,12 @@ private static void componentsSetEnabled(Container container, boolean enabled) {
*/
private boolean prepareControllerForAquisition(boolean hardwareTimepoints) {

return controller_.prepareControllerForAquisition(
hardwareTimepoints,
return controller_.prepareControllerForAquisition(hardwareTimepoints,
getChannelMode(),
isMultichannel(),
isMultiChannel(),
getNumChannels(),
getNumSlices(),
getNumTimepoints(),
getNumTimePoints(),
getTimePointInterval(),
getNumSides(),
getFirstSide(),
Expand Down Expand Up @@ -1445,7 +1465,7 @@ private boolean runAcquisitionPrivate() {
int nrSlicesSoftware = nrSlices;
String originalChannelConfig = "";
boolean changeChannelPerVolumeSoftware = false;
boolean useChannels = isMultichannel();
boolean useChannels = isMultiChannel();
MultichannelModes.Keys channelMode = getChannelMode();
if (useChannels) {
if (nrChannels < 1) {
Expand Down Expand Up @@ -1520,9 +1540,9 @@ private boolean runAcquisitionPrivate() {
int nrFrames; // how many Micro-manager "frames" = time points to take
if (singleTimePointViewers) {
nrFrames = 1;
nrRepeats = getNumTimepoints();
nrRepeats = getNumTimePoints();
} else {
nrFrames = getNumTimepoints();
nrFrames = getNumTimePoints();
nrRepeats = 1;
}
long timepointsIntervalMs = Math.round(
Expand Down Expand Up @@ -1560,7 +1580,7 @@ private boolean runAcquisitionPrivate() {
// experimentally need ~0.5 sec to set up acquisition, this gives a bit of cushion
boolean hardwareTimepoints = false;
if (timepointsIntervalMs < (volumeDuration + 750)
&& getNumTimepoints() > 1) {
&& getNumTimePoints() > 1) {
hardwareTimepoints = true;
}

Expand All @@ -1580,7 +1600,7 @@ && getNumTimepoints() > 1) {
}
}

if (getNumTimepoints() > 1) {
if (getNumTimePoints() > 1) {
if (timepointsIntervalMs < volumeDuration) {
MyDialogUtils.showError("Time point interval shorter than" +
" the time to collect a single volume.\n");
Expand Down Expand Up @@ -1670,7 +1690,8 @@ && getNumTimepoints() > 1) {

// Set up controller SPIM parameters (including from Setup panel settings)
// want to do this, even with demo cameras, so we can test everything else
if (! prepareControllerForAquisition(hardwareTimepoints)) {
AcquisitionSettings acqSettings = generateAcquisitionSettings(hardwareTimepoints);
if (!controller_.prepareControllerForAquisition(acqSettings)) {
return false;
}

Expand Down Expand Up @@ -1837,7 +1858,7 @@ && getNumTimepoints() > 1) {
sliceTiming_, false);
}
// Restore settings of the controller
prepareControllerForAquisition(hardwareTimepoints);
controller_.prepareControllerForAquisition(acqSettings);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
///////////////////////////////////////////////////////////////////////////////
//FILE: AcquisitionSettings.java
//PROJECT: Micro-Manager
//SUBSYSTEM: ASIdiSPIM plugin
//-----------------------------------------------------------------------------
//
// AUTHOR: Nico Stuurman, Jon Daniels
//
// COPYRIGHT: University of California, San Francisco, & ASI, 2015
//
// LICENSE: This file is distributed under the BSD license.
// License text is included with the source distribution.
//
// This file is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.

package org.micromanager.asidispim.Data;

import org.micromanager.asidispim.Utils.SliceTiming;

/**
* Associative container for slice timing information.
* Public elements so they can be get/set directly, like C++ struct
* @author nico
*/

public class AcquisitionSettings {
// if true, the tiger controller will run multiple timepoints
public boolean hardwareTimepoints_;
// MultiChannel mode
public MultichannelModes.Keys channelMode_;
// if true, use channels
public boolean useChannels_;
// number of channels for this acquisition
public int numChannels_;
// number of slices for this acquisition
public int numSlices_;
// number of timepoints for this acquisition
public int numTimepoints_;
// time between starts of timepoints
public double timePointInterval_;
// number of Sides from which we take data (diSPIM: 1 or 2)
public int numSides_;
// firstSide to take data from (A or B)
public String firstSide_;
// whether or not we use time points
public boolean useTimepoints_;
// piezo scanning, vibration, stage scanning, i.e. what is
// moved between slices
public AcquisitionModes.Keys spimMode_;
// true to use current Z position (e.g. autofocus),
// false to use specified acquisition center
public boolean centerAtCurrentZ_;
// wait in ms before starting each side (piezo only)
public float delayBeforeSide_;
// spacing between slices in microns
public float stepSizeUm_;
// low level controller timing parameters
public SliceTiming sliceTiming_;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import mmcorej.Configuration;
import org.micromanager.api.ScriptInterface;
import org.micromanager.asidispim.Data.AcquisitionModes;
import org.micromanager.asidispim.Data.AcquisitionSettings;
import org.micromanager.asidispim.Data.CameraModes;
import org.micromanager.asidispim.Data.ChannelSpec;
import org.micromanager.asidispim.Data.Devices;
Expand Down Expand Up @@ -100,7 +101,8 @@ public boolean prepareControllerForAquisition(
final float delayBeforeSide,
final float stepSizeUm,
final SliceTiming sliceTiming
) {
)
{

// turn off beam and scan on both sides (they are turned off by SPIM state machine anyway)
// also ensures that properties match reality at end of acquisition
Expand Down Expand Up @@ -250,6 +252,28 @@ public boolean prepareControllerForAquisition(
return true;
}


public boolean prepareControllerForAquisition(AcquisitionSettings settings)
{
return prepareControllerForAquisition(
settings.hardwareTimepoints_,
settings.channelMode_,
settings.useChannels_,
settings.numChannels_,
settings.numSlices_,
settings.numTimepoints_,
settings.timePointInterval_,
settings.numSides_,
settings.firstSide_,
settings.useTimepoints_,
settings.spimMode_,
settings.centerAtCurrentZ_,
settings.delayBeforeSide_,
settings.stepSizeUm_,
settings.sliceTiming_
);
}

/**
* Sets all the controller's properties according to volume settings
* and otherwise gets controller all ready for acquisition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ public boolean equals(Object obj) {


}

}

0 comments on commit ff7c640

Please sign in to comment.