Applying SLM Calibration in Beanshell

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Applying SLM Calibration in Beanshell

Ross, Tyler D.

Hello,


I am using a projector to display patterns on my sample with micromanager. I have calibrated the projector using the projector plugin. However, when I upload images to the projector using the beanshell script, the calibration is not being applied. Is there a beanshell function that I can use to apply the calibration transformations on my images before they are sent to the projector?



For reference I am using Pariksheet's script:


// 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 <[hidden email]> 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("/path/to/stack.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);


Tyler



_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Applying SLM Calibration in Beanshell

Stuurman, Nico
Hi Tyler,


I am using a projector to display patterns on my sample with micromanager. I have calibrated the projector using the projector plugin. However, when I upload images to the projector using the beanshell script, the calibration is not being applied. Is there a beanshell function that I can use to apply the calibration transformations on my images before they are sent to the projector?


The calibration is stored in the Projector plugin itself.  You will need to go through its code to see how you can get in there.  I rewrote substantial parts of that plugin in 2.0-gamma in part to make approaches like yours easier.  It looks like you are using 1.4, and I really do not remember how that version was wired up.  If you are not bound to 1.4, it maybe easier to switch to 2.0-gamma (but note that the scripting interface has changed, especially with respect to the gui object, which is now called and mm and has a completely different interface).

Best,


Nico



For reference I am using Pariksheet's script:


// 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 <[hidden email]> 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("/path/to/stack.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);


Tyler



_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general



_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Applying SLM Calibration in Beanshell

StevenF
Hi,

So I am reviving this thread because i am also interested in accessing the
Calibration/Affine Transforms generated by the Calibration of the Projector
plugin!

How would you go about doing this using version 2.0 gamma?

Thanks in advance,

Best,

Steven



--
Sent from: http://micro-manager.3463995.n2.nabble.com/


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Applying SLM Calibration in Beanshell

Stuurman, Nico
Hi Steven,
> So I am reviving this thread because i am also interested in accessing the
> Calibration/Affine Transforms generated by the Calibration of the Projector
> plugin!
>
> How would you go about doing this using version 2.0 gamma?

For 2.0-gamma, look at my mnfinder repository on Github:
https://github.com/nicost/mnfinder/tree/mm2-gamma

The relevant code is in the
https://github.com/nicost/mnfinder/blob/mm2-gamma/MicroNuclei/src/org/micromanager/micronuclei/MicroNucleiForm.java 
class (hmm, not so nice to have this in the UI class, but oh well),
specifically, the "zap" function that takes ImageJ rois and projects
them on the SLM (line 1115 onwards).

Best,

Nico


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general