Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
software:micro-manager [2024/04/15 23:19]
Jon Daniels [Micro-manager diSPIM Plugin]
software:micro-manager [2024/05/21 23:52] (current)
Jon Daniels [Runnables in the plugin]
Line 431: Line 431:
 diSPIM.attachRunnable(taskStartTimepoint, RunnableType.TIMEPOINT_START); diSPIM.attachRunnable(taskStartTimepoint, RunnableType.TIMEPOINT_START);
 diSPIM.attachRunnable(taskEndTimepoint, RunnableType.TIMEPOINT_END); diSPIM.attachRunnable(taskEndTimepoint, RunnableType.TIMEPOINT_END);
 +
 +</code>
 +
 +
 +Here is another example that runs autofocus periodically, in this case every 13 positions.
 +
 +<code>
 +
 +// runs autofocus once on the first position and periodically afterwards based on period set in script (currently every 13th position)
 +// script assumes that CRISP is already set up and is the default focus device
 +// run this script after launching the plugin and before beginning the acquisition
 +
 +// required imports
 +import org.micromanager.asidispim.api.*;
 + 
 +// get a reference to the plugin; use this to call the plugins API methods
 +ASIdiSPIMInterface diSPIM = new ASIdiSPIMImplementation();
 +
 +// local variables
 +int runnablePositionCounter;
 +int counterPeriod = 13;
 + 
 +// initialize the counter when the acquisition begins
 +taskStartAcquisition = new Runnable() {
 + public void run() {
 + runnablePositionCounter = 0;
 + }
 +};
 +
 +// at each position see if it's time to run autofocus, plus also increment the counter
 +taskStartPosition = new Runnable() {
 + public void run() {
 + //gui.showError("started position " + runnablePositionCounter);
 + if ((runnablePositionCounter % counterPeriod)<1) {
 + mmc.fullFocus();   // this is supposed to be a blocking call in the device adapter (should wait until focus is achieved)
 + }
 + runnablePositionCounter++;
 + }
 +};
 +
 + 
 +// add the runnables to the diSPIM plugin's acquisition engine
 +diSPIM.clearAllRunnables();
 +diSPIM.attachRunnable(taskStartAcquisition, RunnableType.ACQUISITION_START);
 +diSPIM.attachRunnable(taskStartPosition, RunnableType.POSITION_START);
 +
  
 </code> </code>