Skip to content

Instantly share code, notes, and snippets.

@omsai
Created December 9, 2014 23:17
Show Gist options
  • Save omsai/c77f8e4302b51b16ffd6 to your computer and use it in GitHub Desktop.
Save omsai/c77f8e4302b51b16ffd6 to your computer and use it in GitHub Desktop.
Micro-Manager script to uploading image sequence to Andor Mosaic3 using core API.
// Upload image from stack to SLM before each frame in MDA.
//
// We have to use the core API to upload each frame individually,
// since there is no public sequencing API for SLM devices.
//
// Pariksheet Nanda <pariksheet.nanda@uconn.edu> July 2014
//
// License: Public Domain
import ij.io.Opener; // To load TIFF stack file from disk.
import ij.ImagePlus; // To hold the opened image.
import ij.ImageStack; // To access stack pixels.
// Load file from disk.
Opener opener = new Opener();
ImagePlus imp = opener.openImage("C:/Users/Andor/Downloads/speckle.tif");
// Get stack info.
ImageStack stack = imp.getImageStack();
slices = stack.getSize();
// Set MDA to acquire the number of slices.
seqSettings = gui.getAcquisitionSettings();
seqSettings.numFrames = slices;
gui.setAcquisitionSettings(seqSettings);
// Get the installed name of the SLM.
mosaic = mmc.getSLMDevice();
// Boilerplate when using runnables.
gui.clearRunnables();
// Runnable to upload each image to the SLM.
runnable = new Runnable() {
int slice = 1;
public void run() {
// Get the pixels of the stack slice.
pixels = stack.getPixels(slice);
// Upload the image to the SLM.
mmc.setSLMImage(mosaic, pixels);
// Activate the uploaded image on the SLM.
mmc.displaySLMImage(mosaic);
print("Activated slice " + slice);
slice++;
}
};
// Dimension order is frame, position, channel, slice.
gui.attachRunnable(-1, -1, -1, -1, runnable);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment