using 2 different cameras simultaneously in burst mode

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

using 2 different cameras simultaneously in burst mode

MarshallC
Hello All,

I've added a "beam monitor" to my microscope that essentially images the excitation beam's reflection.  I use a Point Grey Chameleon 3 for the actual detector, and a Zyla4.2 for imaging.  I'm a bit stuck on how to operate the PGR in triggered mode via a script that will dump each camera's images into separate stacks.  I've copied my current version below.  Right now it will acquire and save the data coming from the Zyla, but nothing gets added to the other acquisition.  If anyone could help out I'd really appreciate it.

As far as I know I can't use the multicamera adapter as the two devices have different sizes, bit depths, etc.  Also, this is my complete debugging version.  

[code]
/*
 * Sequence acquisition script with beam detector
 */

import org.json.JSONArray;
import org.json.JSONObject;

// file locations
//Change the file name for each acquisition
acqName = gui.getUniqueAcquisitionName("seq");
//Alternatively, leave the default name and create a new directory
rootDirName = "C:/Nikon_Data/170302_MJC_scriptingtest";

//Number of stacks
seqNbr = 0;
maxSeq = 5;

//Time between acquisitions in millis (must be longer than cycle time)
timeInt = 5000;

//Exposure time
frameTime = 50.0;
       
// Number of frames per stack (excluding activation frame) for the sCMOS
nrFrames = 32;
//Number of frames for the MD
nrMDFrames = 32;

nrChannels = nrSlices = nrPositions = 1;

try{
mmc.setCameraDevice("Zyla4.2");
currCam = mmc.getCameraDevice();
print(currCam);

zylaWidth = (int) mmc.getImageWidth();
zylaHeight = (int) mmc.getImageHeight();
zylaBytesPerPixel = (int) mmc.getBytesPerPixel();
zylaBitDepth = (int) mmc.getImageBitDepth();
print(zylaWidth + "\n" + zylaHeight + "\n" + zylaBytesPerPixel + "\n" + zylaBitDepth);

mmc.setCameraDevice("beam_monitor");
currCam = mmc.getCameraDevice();
print(currCam);

mdWidth = (int)mmc.getImageWidth();
mdHeight = (int) mmc.getImageHeight();
mdBytesPerPixel = (int) mmc.getBytesPerPixel();
mdBitDepth = (int) mmc.getImageBitDepth();

print(mdWidth + "\n" + mdHeight + "\n" + mdBytesPerPixel + "\n" + mdBitDepth);

//turn on triggering for the beam monitor camera
mmc.setProperty("beam_monitor", "Trigger Mode-OnOff", "On");

for(int seqnbr = 0; seqNbr < maxSeq; seqNbr++)
{
        mmc.setCameraDevice("Zyla4.2");
        String zylaSeq = acqName + "_" + seqNbr;
        String mdSeq = acqName + "_" + seqNbr + "_MD";
        timeNow = System.currentTimeMillis();
       
        //Save as .tiff stack
        gui.setImageSavingFormat(org.micromanager.acquisition.TaggedImageStorageMultipageTiff.class);

        gui.closeAllAcquisitions();
        gui.openAcquisition(zylaSeq, rootDirName, nrFrames, 1, 1, 1,
        true, true);
   //Open the MD acquisition
   gui.openAcquisition(mdSeq, rootDirName, nrMDFrames, 1, 1, 1,
   true, true);
   //initialize the acquisitions
        gui.initializeAcquisition(zylaSeq, zylaWidth, zylaHeight, zylaBytesPerPixel, zylaBitDepth);
        gui.initializeAcquisition(mdSeq, mdWidth, mdHeight, mdBytesPerPixel, mdBitDepth);

        //Clear the circular buffers
        mmc.initializeCircularBuffer();
       
        mmc.startSequenceAcquisition("Zyla4.2", nrFrames, 0, true);
        mmc.startSequenceAcquisition("beam_monitor", nrMDFrames, 0, true);
       
        frame = 0;
        mdFrame = 0;
        exposureMs = mmc.getExposure();
        while (mmc.getRemainingImageCount() > 0 || mmc.isSequenceRunning(mmc.getCameraDevice())) {
           if (mmc.getRemainingImageCount() > 0) {
              img = mmc.popNextTaggedImage();
              JSONObject tags = img.tags;
              cName = tags.get("Camera");
              if(cName.equals("Zyla4.2"))
              {
              gui.addImageToAcquisition(zylaSeq, frame, 0, 0, 0, img);
              }
              else
              {
              gui.addImageToAcquisition(mdSeq, frame, 0, 0, 0, img);
              }
              frame++;
           }
        }
       
        mmc.stopSequenceAcquisition("Zyla4.2");
        mmc.stopSequenceAcquisition("beam_monitor");
       
        gui.setContrastBasedOnFrame(zylaSeq, 1, 0);
       
        timeTaken = System.currentTimeMillis() - timeNow;
       
        if(timeTaken < 50)
        {
                downTime = 0;
        }
        else
        {
                downTime = timeTaken;
        }
        mmc.sleep(downTime);
        //gui.closeAcquisition(acqName + "_" + seqNbr);
        gui.closeAcquisitionWindow(zylaSeq);
        gui.closeAcquisitionWindow(mdSeq);
}


//turn off triggering for the beam monitor camera
//mmc.setProperty("beam_monitor", "Trigger Mode-OnOff", "Off");
}

//Catch any exception and reset important properties before exiting
catch(e)
{
        print("caught exception: " + e);
        mmc.stopSequenceAcquisition("Zyla4.2");
        mmc.stopSequenceAcquisition("beam_monitor");
        gui.closeAllAcquisitions();
        mmc.setProperty("beam_monitor", "Trigger Mode-OnOff", "Off");
        mmc.setCameraDevice("Zyla4.2");
}
[/code]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using 2 different cameras simultaneously in burst mode

Nico Stuurman-2
Hi Marshall,


> I've added a "beam monitor" to my microscope that essentially images the
> excitation beam's reflection.  I use a Point Grey Chameleon 3 for the actual
> detector, and a Zyla4.2 for imaging.  I'm a bit stuck on how to operate the
> PGR in triggered mode via a script that will dump each camera's images into
> separate stacks.  I've copied my current version below.  Right now it will
> acquire and save the data coming from the Zyla, but nothing gets added to
> the other acquisition.  If anyone could help out I'd really appreciate it.

Regretfully, this approach is unlikely to work.  There is only one
circular buffer in the Micro-manager core, and all images that will be
inserted have to be the same size (you must have lots of error stating
"Incompatible image dimensions in the circular buffer". This is the
consequence of a very old software design decision.  It would be
possible to change this, but a lot of work (Mark, Open Imaging,
certainly knows how to do this, but I doubt he has the time right now).

Can you run your "beam monitor" from another instance of Micro-Manager?  
Otherwise, is there any way that you could make the images the same size
and bitdepth?

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: using 2 different cameras simultaneously in burst mode

MarshallC
Nico Stuurman-2 wrote
Regretfully, this approach is unlikely to work.  There is only one
circular buffer in the Micro-manager core, and all images that will be
inserted have to be the same size (you must have lots of error stating
"Incompatible image dimensions in the circular buffer".
I was starting to worry that this would be the case.  I was hoping maybe
there was a trick to creating a unique circular buffer for each camera stream.

Nico Stuurman-2 wrote
This is the consequence of a very old software design decision.  It would be
possible to change this, but a lot of work (Mark, Open Imaging,
certainly knows how to do this, but I doubt he has the time right now).

Can you run your "beam monitor" from another instance of Micro-Manager?  
Otherwise, is there any way that you could make the images the same size
and bitdepth?
I may be able to crop the PGR camera to match the Andor, I'll give that a try
this afternoon and see if that will work.  I've been using FlyCapture2 during testing
in parallel with Micro-Manager for the main acquisition, but I find FlyCapture pretty
annoying to work with.

Also, thank you and great job to the whole Micro-Manager and Open Imaging team.
You guys have put together some great stuff and incredible support.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: using 2 different cameras simultaneously in burst mode

MarshallC
I tried to crop the PGR camera to match the Zyla.  I can do this in FlyCapture, however when I start up Micro-Manager it resets to the full sensor, unlike the other settings.  There doesn't seem to be a crop option in the PGR device adapter, but I haven't been through the code yet.  For now I've got it running with 2 instances of Micro-Manager as Nico suggested, and that's good enough.  If I have some extra time I'll look into the feasibility of adding a crop function to the device adapter.
Loading...