StartSequenceAcquisition not allowing IntervalMs > 0

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

StartSequenceAcquisition not allowing IntervalMs > 0

will_h

Hi,


I'm trying to control a piezo stage and acquire a set of images while it is moving at constant speed. To do this, I've gotten the stage control working using Micromanager's scripting interface. I edited a script for burst acquisition that I found online, but when I set the intervalMs to be anything above 0, I get an error


>run-time error : Error in device "HamamatsuHam_DCAM"


If I set intervalMs = 0, it works fine. Below is the script I'm using.


Thanks,

Will

PhD Student, University of Nottingham

_________________________________________________


/*
 * Script copied to use Sequence acquisition
 */
 
// file details
acqName = gui.getUniqueAcquisitionName("test-burst");
rootDirName = "C:/AcquisitionData";

// Speed in X and Y (mm/s):
double  S_X = 01;
double  S_Y = 01;

// Moving time (s):
double  T_drag = 2;

// Acquisition parameters
nrFrames = 10;
nrChannels = nrSlices = nrPositions = 1;


// Sends commands down USB bridge to serial
String  sendASICommand(String command)
{
String  port = "COM5";
mmc.setSerialPortCommand(port, command, "\r");
String  asiReturn = mmc.getSerialPortAnswer(port, "\n");
asiReturn       = asiReturn.replaceAll("\r", "\r\n"); //reformat multiline responses for display
return asiReturn;
}

// Prepare the stage
double  D_X = S_X * T_drag;
double  D_Y = S_Y * T_drag;
sendASICommand("S X=" + S_X + " Y=" + S_Y);

gui.openAcquisition(acqName, rootDirName,
   nrFrames, nrChannels, nrSlices, nrPositions,
   /* show */ true,
   /* save */ false);

width = (int) mmc.getImageWidth();
height = (int) mmc.getImageHeight();
bytesPerPixel = (int) mmc.getBytesPerPixel();
bitDepth = (int) mmc.getImageBitDepth();
gui.initializeAcquisition(acqName, width, height, bytesPerPixel, bitDepth);
mmc.startSequenceAcquisition(nrFrames, 0, true);
frame = 0;                                                                                                               
exposureMs = mmc.getExposure();
mmc.setRelativeXYPosition(1000 * D_X, 1000 * D_Y);

while (mmc.getRemainingImageCount() > 0 || mmc.isSequenceRunning(mmc.getCameraDevice()))
{
   if (mmc.getRemainingImageCount() > 0)
{
      img =  mmc.popNextTaggedImage(); 
      gui.addImageToAcquisition(acqName, frame, 0, 0, 0, img);
      frame++;
}
    else
{
      mmc.sleep(Math.min(0.5 * exposureMs, 20));
   }
}

mmc.stopSequenceAcquisition();



This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please contact the sender and delete the email and
attachment. 

Any views or opinions expressed by the author of this email do not
necessarily reflect the views of the University of Nottingham. Email
communications with the University of Nottingham may be monitored 
where permitted by law.





_______________________________________________
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: StartSequenceAcquisition not allowing IntervalMs > 0

Stuurman, Nico
Hi William,

> I'm trying to control a piezo stage and acquire a set of images while
> it is moving at constant speed. To do this, I've gotten the stage
> control working using Micromanager's scripting interface. I edited a
> script for burst acquisition that I found online, but when I set the
> intervalMs to be anything above 0, I get an error
>
>
> >run-time error : Error in device "HamamatsuHam_DCAM"
>
>
> If I set intervalMs = 0, it works fine. Below is the script I'm using.
>


The intervalMs parameter was a nice idea when the Micro-Manager API was
developed, but it turned out that very few camera APIs actually support
that parameter (i.e., when they run a sequence, they act like a video
camera and stream continuously).  I think that there is only one vendor
that actually supports it (forgot which one).  Most camera device
adapters will simply ignore the parameter, in a way, the Hamamatsu
behavior is nicer, because now you know that it does not work that way.

If you want intervals between frames, you will either need to do
individual snaps (which is quite a bit slower), or use external triggering.

Good luck!

Best,

Nico





_______________________________________________
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: StartSequenceAcquisition not allowing IntervalMs > 0

nanthony
Hi William,

As Nico already mentioned the intervalMs  doesn't work for many cameras. I'm not sure which Hamamatsu you are using, but for my setup using a Hamamatsu Flash v3 I am able to set the camera's `Master Pulse` Interval to get images at a specific interval.

Here is some example code where I make sure that there is a delay of `delayMs`  between when the `readout` TTL signal is fired and the next exposure begins.

String cam = studio_.core().getCameraDevice();
if (studio_.core().getDeviceName(cam).equals("HamamatsuHam_DCAM")) { //This device adapter doesn't seem to support delays in the sequence acquisition. We instead set the master pulse interval.
                            studio_.core().setProperty(cam, "TRIGGER SOURCE", "MASTER PULSE"); //Make sure that Master Pulse is triggering the camera.
                            double exposurems = studio_.core().getExposure();
                            double readoutms = 10; //This is based on the frame rate calculation portion of the 13440-20CU camera. 9.7 us per line, reading two lines at once, 2048 lines -> 0.097*2048/2 ~= 10 ms
                            studio_.core().setProperty(cam, "MASTER PULSE INTERVAL", (exposurems+readoutms+delayMs)/1000.0); // Divide by 100 to convert to seconds.
                            studio_.core().startSequenceAcquisition(numOfImages, 0, false); //The hamamatsu adapter throws an error if the interval is not 0.

> I'm trying to control a piezo stage and acquire a set of images while
> it is moving at constant speed. To do this, I've gotten the stage
> control working using Micromanager's scripting interface. I edited a
> script for burst acquisition that I found online, but when I set the
> intervalMs to be anything above 0, I get an error
>
>
> >run-time error : Error in device "HamamatsuHam_DCAM"
>
>
> If I set intervalMs = 0, it works fine. Below is the script I'm using.
>



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