DM Adventurer
DM Adventurer

Reputation: 45

Acquire a series of STEM images via the method of event listener

Recently I am trying to attach an event listener to a live display so as to acquire a series of images automatically and the even map used is "data_value_changed". In TEM mode everything is fine and the 3D stack can be properly obtained. Unfortunately, while applying this to a live STEM image from the DigiScan, the script failed completely. Later on I just realized that in such a mode, the image is updated pixel by pixel with the scanning rather than frame by frame. Another event map "data_changed" was further tested but still ended up with failure.

With DM2.0 or later version, it seems to be much easier to acquire a series of customerized STEM images, since the DigiScan controlling can be conveniently accessable via scripting. Unfortunately, our microscope is quite old and only with DM 1.5 installed.

Is there any event map sepcific to this purpose or the approach of event handler is not suitable at all?

Thanks in advance

Upvotes: 0

Views: 170

Answers (1)

BmyGuest
BmyGuest

Reputation: 2949

The data changed event handler is suitable, but there is no event for a particular frame/complete event.

Instead, your event-handling code needs to be creative and deal with the situation that you get more events than you want. You are really only interested in the event which (also) change the last pixel in an image (as the frame is sequentially filled), but you do get events whenever sub-parts of the image change.

So you need to "filter" those events out - as quickly and CPU-conservative as possible.

The easiest way is to gather the last pixel's value at each event and compare it to a stored value. If the value changed, then this pixel was changed, indicating the frame is "complete" and you want to use the event. Otherwise, just return without further action.

There is a very slim chance ( - for scanned images - ) that a "new" frame has the numerically identical value than the frame before, so this in most cases is all yoou need to do.

If this isn't enough for you, you may look at longer - but also more CPU cycles consuming - checks like each time computing a Boolean change map betwee "now" and "buffered" and keeping track of the "last" change. Then, if there is a "jump over" to an earlier index, you know that your "buffered" last image actually wa a full frame. (Note, that you will always see the data update once at the end of frame. Hence this will work.)

There is an example of this type of script in this answer here. If this isn't working for you, please comment or rephrase your question for more details on where you run into issues.

Upvotes: 0

Related Questions