Quantcast

getLastTaggedImage() and obtaining the circular buffer's newest image

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

getLastTaggedImage() and obtaining the circular buffer's newest image

Kyle Douglass
Hello everyone,

I'm having a difficult time understanding what getLastTaggedImage() does
(and its related variants like getLastImage()). Would anyone be able to
tell me whether getLastTaggedImage() et al. returns the *oldest* image
from the circular buffer or the *newest* image? I am working under the
assumption that it does not remove any images from the buffer and simply
provides a pointer to or copy of the data, unlike popNextImage() which
removes the image from the buffer.

The reason I ask is because I would like to extract the newest image in
the circular buffer. AFAIK, popNextImage() returns and removes the
oldest. Unfortunately, I've found conflicting explanations of
getLastImage() et al. on the web, some that state it returns the most
recently acquired image in the buffer and others that state it returns
the oldest image in the buffer.

For example, Chris's corrected post here states that "getLastImage (et
al) return the *oldest* image that has not yet been popped
from the buffer, not the most recent image"
(https://sourceforge.net/p/micro-manager/mailman/message/33735446/).
(I'm sorry to pick on you, Chris.)

However, the docs for getLastImageMD state that it "Returns a pointer to
the pixels of the image that was last inserted into the circular buffer"
(http://javadoc.imagej.net/Micro-Manager-Core/mmcorej/CMMCore.html#getLastImageMD%28mmcorej.Metadata%29).
To me, this sounds like it points to the newest image.

Finally, I wrote a script to test its behavior by modifying the example
MM 2.0 burstAcquisition.bsh script
(https://github.com/micro-manager/micro-manager/blob/mm2/scripts/burstAcquisition.bsh).
Assuming getLastTaggedImage() returns the oldest image in the circular
buffer and does not remove images from the buffer, then I would expect
that the script at the bottom of this post would produce a sequence of
identical images because it would always get the oldest (and therefore
first) image without removing it from the buffer. However, it doesn't do
this. Instead, it produces a jerky movie of a sine wave that pauses
randomly for a few frames. The frames at which it pauses vary each time
the script is run, so it seems to me like getLastTaggedImage() is
getting the NEWEST image in the circular buffer and the jerkiness
corresponds to iterations of the while loop where a new image had not
arrived in the buffer. I'm using the demo camera from MMConfig_demo.cfg.

I'd really appreciate it if someone could explain what exactly
getLastTaggedImage() is doing.

Thanks a lot, and have a great day everyone,

Kyle


store  = mm.data().createRAMDatastore();
mm.displays().createDisplay(store);

nFrames = 50;
expTime = mmc.getExposure();
mmc.clearCircularBuffer();
/* Arguments:
  *  1. Number of frames
  *  2. Interval between frames
  *  3. Halt acquisition if buffer overflows (yes/no)? */
mmc.startSequenceAcquisition(nFrames, 0, true);

builder = mm.data().getCoordsBuilder().z(0).channel(0).stagePosition(0);
int currFrame = 0;

while (mmc.getRemainingImageCount() > 0 ||
mmc.isSequenceRunning(mmc.getCameraDevice())) {
     if (mmc.getRemainingImageCount() > 0) {

         tagged = mmc.getLastTaggedImage();
         image = mm.data().convertTaggedImage(tagged,
builder.time(currFrame).build(), null);
         store.putImage(image);
         currFrame++;
         mmc.sleep(Math.min(.5 * expTime, 20));
     }

     if (currFrame > nFrames) {
         break;
     }
}

mmc.stopSequenceAcquisition();
mm.displays().manage(store);


--
Kyle M. Douglass, PhD
Post-doctoral researcher
The Laboratory of Experimental Biophysics
EPFL, Lausanne, Switzerland
http://kmdouglass.github.io
http://leb.epfl.ch


------------------------------------------------------------------------------
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: getLastTaggedImage() and obtaining the circular buffer's newest image

Nico Stuurman-2
Hi Kyle,


> I'm having a difficult time understanding what getLastTaggedImage() does
> (and its related variants like getLastImage()). Would anyone be able to
> tell me whether getLastTaggedImage() et al. returns the *oldest* image
> from the circular buffer or the *newest* image? I am working under the
> assumption that it does not remove any images from the buffer and simply
> provides a pointer to or copy of the data, unlike popNextImage() which
> removes the image from the buffer.

Authoritative explanation is in the source code
(https://valelab4.ucsf.edu/svn/micromanager2/trunk/MMCore/MMCore.cpp),
or the derived documentation:
https://valelab4.ucsf.edu/~MM/doc/MMCore/html/class_c_m_m_core.html#abffeccc28f7e71a95149ac77cc196839.
That documentation is quite sparse, but I interpret it the same way you
do, i.e. the "last" image is the last image that was added to the
circular buffer.  I think that your experiment confirms that it is doing
the right thing.

> Unfortunately, I've found conflicting explanations of
> getLastImage() et al. on the web, some that state it returns the most
> recently acquired image in the buffer and others that state it returns
> the oldest image in the buffer.
>
> For example, Chris's corrected post here states that "getLastImage (et
> al) return the *oldest* image that has not yet been popped
> from the buffer, not the most recent image"
> (https://sourceforge.net/p/micro-manager/mailman/message/33735446/).
> (I'm sorry to pick on you, Chris.)

Looks like that was indeed mistaken.


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: getLastTaggedImage() and obtaining the circular buffer's newest image

Kyle Douglass
Hi Nico,

Thanks for your response and for verifying what I had originally thought.

> Authoritative explanation is in the source code
> (https://valelab4.ucsf.edu/svn/micromanager2/trunk/MMCore/MMCore.cpp),

The source code is probably something I should always check when a question like this arises. :)

Cheers,
Kyle


Dr. Kyle M. Douglass
Post-doctoral Researcher
EPFL - The Laboratory of Experimental Biophysics
http://leb.epfl.ch/
http://kmdouglass.github.io
------------------------------------------------------------------------------
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...