Quantcast

Adjusting device properties during Multi-Dimensional acquisition

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

Adjusting device properties during Multi-Dimensional acquisition

pfre017
Is it possible to change device properties during the 'loop' of Multi-Dimensional acquisition?

I have a monochromator which receives a voltage input (±10 V) which in turn corresponds to a wavelength output of the monochromator. I only want to expose the preparation to light (e.g. ~3 V = 590nm) for the duration of the image acquisition.  Basically, I want to change the voltage output of the NI100X adaptor to -10V immediately after acquiring an image - this will work as a shutter.

Start Multi-D acquisition (e.g. 1 image every 500 ms)
Time 0ms: NI100X output: -10 V
Time 495ms: NI100X output: 3V
Time 500ms: Acquire Image (exposure 100 ms)
Time 605ms: NI100X output: -10V
repeat....

This is another possible solution to a problem I am having with using the NI100X adaptor to control a monochromator as a shutter (-10V gives nearly no light output [ie shutter closed]).

Many thanks for any help offered.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adjusting device properties during Multi-Dimensional acquisition

Nico Stuurman-2

On 4/25/17 2:43 PM, pfre017 wrote:
> Is it possible to change device properties during the 'loop' of
> Multi-Dimensional acquisition?

Although it is almost always better to do this at the level of the
device itself, you could use a "Runnable" and attach it to the
acquisition engine:
https://valelab4.ucsf.edu/~MM/doc/mmstudio/org/micromanager/api/ScriptInterface.html#attachRunnable(int,%20int,%20int,%20int,%20java.lang.Runnable)
.

An example script can be found here:
https://valelab4.ucsf.edu/svn/micromanager2/trunk/scripts/runnableDemo.bsh.

I am not quite certain if these runnables are executed before or after
taking the image.

Best,

Nico


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adjusting device properties during Multi-Dimensional acquisition

pfre017
Thank you Nico - that was an excellent starting point. I have attached below my script of the working solution to my problem.

//for MM 2.0beta
print("starting script");

mm.acquisitions().clearRunnables();

runnable = new Runnable() {
   int count = 0;
   interval = mm.acquisitions().getAcquisitionSettings().intervalMs;
   exposure = mmc.getExposure();
   int delayBeforeShutterCloseMs = exposure + 10;
   
   public void run() {

      print("opening shutter @ frame #"+count+"  for "+delayBeforeShutterCloseMs+" ms");
                shutterTimer = new Timer();

      // One has to create a TimerTask each time it is run, since a
      // TimerTask cannot be re-used after it is executed.
            closeTask = new TimerTask() {
         public void run() {
            print("closing shutter");
      mmc.setProperty("AnalogIO", "Volts", 0);
         }
      };
     
                mmc.setProperty("AnalogIO", "Volts", 3.5);
               
                shutterTimer.schedule(closeTask, delayBeforeShutterCloseMs);
     
      ++count;
   }
};


// Run the runnable on all frames and positions,
// but only channel 0 and slice 0.
// -1 --> attach to all planes along given dimension
mm.acquisitions().attachRunnable(-1,-1,0,0,runnable); // f, p, c, s

print("Runnable created and attached OK");

// After running this script, you can test the results by
// running a multi-dimensional acquisition from the Acquisition Dialog.



The only thing that still needs to be done is to somehow delay the camera exposure for a few milliseconds while the 'shutter' opens (monochromator prism physically rotates) - I think a 'pause' function should do the trick.

Thanks again.
pete
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Adjusting device properties during Multi-Dimensional acquisition

Nico Stuurman-2
On 5/1/2017 6:34 PM, pfre017 wrote:
> Thank you Nico - that was an excellent starting point. I have attached below
> my script of the working solution to my problem.
>
> ---cut---
> The only thing that still needs to be done is to somehow delay the camera
> exposure for a few milliseconds while the 'shutter' opens (monochromator
> prism physically rotates) - I think a 'pause' function should do the trick.

Use:
Thread.sleep(10);
Where 10 is the number of milliseconds the system will pause for (not
guaranteed, it may be longer).

Best,

Nico


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Loading...