Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
software:micro-manager [2023/08/16 21:03]
Jon Daniels [Micro-manager diSPIM Plugin]
software:micro-manager [2025/03/12 00:22] (current)
Jon Daniels [Scripting the plugin]
Line 7: Line 7:
 Currently the diSPIM plugin is supported in 1.4.x only.  In 2023 there have been efforts to create a new plugin in Micro-Manager 2.0 called [[https://github.com/micro-manager/LightSheetManager|LightSheetManager]] that will operate the diSPIM as well as other types of light sheet microscopes.  Contributions to the effort of making this new plugin are appreciated.  As of August 2023 this is in alpha testing by the first few bleeding edge adopters, and we expect that by end of 2023 it will be ready for more adopters and a full replacement in 2024. Currently the diSPIM plugin is supported in 1.4.x only.  In 2023 there have been efforts to create a new plugin in Micro-Manager 2.0 called [[https://github.com/micro-manager/LightSheetManager|LightSheetManager]] that will operate the diSPIM as well as other types of light sheet microscopes.  Contributions to the effort of making this new plugin are appreciated.  As of August 2023 this is in alpha testing by the first few bleeding edge adopters, and we expect that by end of 2023 it will be ready for more adopters and a full replacement in 2024.
  
-You can download the nightly builds of Micro-manager 1.4 for Windows [[http://valelab4.ucsf.edu/~MM/nightlyBuilds/1.4/Windows/|here]]; the date is encoded in the file name and the latest date is at the top of the page.  Make sure to get the appropriate 32bit or 64bit depending on your computer.+You can download the nightly builds of Micro-manager 1.4 for Windows [[https://download.micro-manager.org/nightly/1.4/Windows/|here]]; the date is encoded in the file name and the latest date is at the top of the page.  Make sure to get the appropriate 32bit or 64bit depending on your computer.
  
  
Line 89: Line 89:
 ==== Scripting the plugin ==== ==== Scripting the plugin ====
  
-The Micro-Manager plugin has an API that allows most of its functionality to be accessed via Beanshell scripts run from within Micro-Manager.  This allows users to orchestrate complex acquisitions and even use the plugin for adaptive microscopy where automated image analysis guides acquisition.  The best way to see what functionality is exposed via the API is to look at the [[https://github.com/micro-manager/micro-manager/blob/mm1/plugins/ASIdiSPIM/src/org/micromanager/asidispim/api/ASIdiSPIMInterface.java|source code of the Java interface]] which defines the API.  The API includes are methods to get and set the most commonly changed settings within the plugin, launch acquisitions, move the microscope, and more.  The API can be augmented if needed but every effort is made not to change the documented functionality.  Furthermore there is support for Java RMI which allows the plugin API to be access from a completely separate Java VM.+The Micro-Manager plugin has an API that allows most of its functionality to be accessed via Beanshell scripts run from within Micro-Manager.  This allows users to orchestrate complex acquisitions and even use the plugin for adaptive microscopy where automated image analysis guides acquisition.  The best way to see what functionality is exposed via the API is to look at the [[https://github.com/jondaniels/micro-manager/blob/mm1.4/plugins/ASIdiSPIM/src/org/micromanager/asidispim/api/ASIdiSPIMInterface.java|source code of the Java interface]] which defines the API.  The API includes are methods to get and set the most commonly changed settings within the plugin, launch acquisitions, move the microscope, and more.  The API can be augmented if needed but every effort is made not to change the documented functionality.  Furthermore there is support for Java RMI which allows the plugin API to be access from a completely separate Java VM.
  
 Here is a bare-bones example script: Here is a bare-bones example script:
Line 127: Line 127:
 // gets a reference to the plugin; use this to call the plugin's API methods // gets a reference to the plugin; use this to call the plugin's API methods
 // API documented in ASIdiSPIMInterface.java in source code  // API documented in ASIdiSPIMInterface.java in source code 
-//   (https://valelab4.ucsf.edu/trac/micromanager/browser/plugins/ASIdiSPIM/src/org/micromanager/asidispim/api/ASIdiSPIMInterface.java)+//   (https://github.com/jondaniels/micro-manager/blob/mm1.4/plugins/ASIdiSPIM/src/org/micromanager/asidispim/api/ASIdiSPIMInterface.java)
 // note that the plugin must be launched // note that the plugin must be launched
 ASIdiSPIMInterface diSPIM = new ASIdiSPIMImplementation(); ASIdiSPIMInterface diSPIM = new ASIdiSPIMImplementation();
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>