News:

:) You cannot see "members only" boards if you are not a member, so please join the forum!

Main Menu

New Remote Server functions for imaging

Started by John Donovan, June 11, 2016, 08:39:30 AM

Previous topic - Next topic

John Donovan

The Remote Server app allows one to write their own scripts or macros for custom EPMA application development. Scripts can be written for any OLE (Active-X) container such as Excel, MatLab, LabView, etc.  See here for more information:

http://smf.probesoftware.com/index.php?topic=88.msg315#msg315

I have recently added several new functions to enable custom imaging app development as listed here:

Public Property Get RemoteInterfaceType() As Integer
Public Property Get RemoteImageInterfaceType() As Integer
Public Property Get RemoteJEOLEOSInterfaceType() As Long
Public Property Get RemoteImageInterfaceImageIxIy() As Single

Public Sub RemoteImageGetBeamMode(beammode As Integer)
Public Sub RemoteImageSetBeamMode(beammode As Integer)
Public Sub RemoteImageBeamDeflection2(xoffset As Single, yoffset As Single)
Public Sub RemoteImageGetImageShift(ix As Single, iy As Single)
Public Sub RemoteImageSetImageShift(ix As Single, iy As Single)
Public Sub RemoteSetReflectedLight(lightonoff As Integer, lightintensity As Integer)
Public Sub RemoteSetTransmittedLight(lightonoff As Integer, lightintensity As Integer)

See the Remote Server documentation for more details.
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

John Donovan

#1
As an aid to developing your own custom imaging applications using the Probe for EPMA Remote Server interface, I have attached below a zip file with a very simple but powerful example of a Remote Server imaging application (remember to login to see attachments). This application and the Remote interface are of course free to all PFE customers. Please let us know if you have any questions on using this for your own custom applications.

To demonstrate how simple it is to develop a custom imaging application for your EPMA instrument, see the "get image" routine code inserted below which was written in VB6.  The complete VB6 project is in the attached zip file.


Sub TestRemoteImageGet()
' Get analog signal image

ierror = False
On Error GoTo TestRemoteImageGetError

' Send the image channel
Remote.RemoteImageSetImageMode ImageChannel%

Dim done%                               ' returned, true (-1) if image complete
Dim ntype As Integer                    ' passed (1 = analog signal, 2 = x-ray)

Dim sxmin As Single, symin As Single    ' returned (stage coordinates of corners)
Dim sxmax As Single, symax As Single  ' returned (stage ccordinates of corners)
Dim zmin As Long, zmax As Long          ' returned (intensity min/max)

ReDim iarray(1 To ImageIx%, 1 To ImageIy%) As Byte  ' returned (0-255 normalized intensity data)
ReDim darray(1 To ImageIx%, 1 To ImageIy%) As Long  ' returned (raw intensity data)

' Set beam mode to analog or digital spot (comment out other line)
'Remote.RemoteImageSetBeamMode 1                           ' set to analog scan mode for SX100 mapping or SX100 video or Bruker or Thermo imaging
Remote.RemoteImageSetBeamMode 2                           ' set to digital spot mode for JEOL 8200/8900/8500

' Remove faraday cup
Remote.RemoteFaraday 2

' Start the acquisition
Remote.RemoteImageStart

' Call image get in a loop until complete
Do Until done
Remote.RemoteImageGet done%, ntype%, ImageChannel%, AnalogAverages%, ImageIx%, ImageIy%, sxmin!, symin!, sxmax!, symax!, iarray(), darray&(), zmin&, zmax&

Sleep 100
DoEvents
If ierror Then Exit Do
Loop

' Convert long values to byte array
ReDim barray(1 To ImageIx%, 1 To ImageIy%) As Byte
Screen.MousePointer = vbHourglass
Call BMPConvertLongArrayToByteArray(ImageIx%, ImageIy%, darray&(), barray())
Screen.MousePointer = vbDefault
If ierror Then Exit Sub

' Display intensity data
Call TestRemoteImagingConvertImage(ImageIx%, ImageIy%, barray(), FormMAIN)
If ierror Then Exit Sub

msg$ = "Sxmin=" & Format$(sxmin!) & ", Sxmax=" & Format$(sxmax!) & vbCrLf
msg$ = msg$ & "Symin=" & Format$(symin!) & ", Symax=" & Format$(symax!)
FormMAIN.TextLog.Text = msg$

' Insert faraday cup
Remote.RemoteFaraday 1

' Set beam mode to analog scan mode
'Remote.RemoteImageSetBeamMode 1                           ' set to analog scan mode for SX100 mapping or SX100 video or Bruker or Thermo imaging

Exit Sub

' Errors
TestRemoteImageGetError:
MsgBox Error$, vbOKOnly + vbCritical, "TestRemoteImageGet"
ierror = True
Exit Sub

End Sub


Note that your custom code can be developed in any application development environment which supports the active-X interface. This also includes Excel, Matlab, LabView and many other environments that support OLE containers.
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Dan R

#2
Hi John-
So these commands would work regardless of the ImageInterfaceType-- e.g., no EDS, JEOL EDS, Thermo EDS, Bruker EDS?

e.g.,
[Image]
ImageInterfacePresent=1
ImageInterfaceType=7         ;JEOL video

or
ImageInterfacePresent=1
ImageInterfaceType=4   

in the probewin.ini file

John Donovan

#3
Quote from: Dan R on August 26, 2024, 12:35:58 PM
Hi John-
So these commands would work regardless of the ImageInterfaceType-- e.g., no EDS, JEOL EDS, Thermo EDS, Bruker EDS?

e.g.,
[Image]
ImageInterfacePresent=1
ImageInterfaceType=7         ;JEOL video

or
ImageInterfacePresent=1
ImageInterfaceType=4   

in the probewin.ini file

Almost.

ImageInterfaceType=4 will work on any JEOL instrument with (or without) any EDS interface because it calls the JEOL WDS mapping interface directly. The minimum pixel dwell time for the WDS scan generator is 100 microsec, so a large images takes a minute or so.

ImageInterfaceType=7 only works with the JEOL 8230/8530 EDS but it can acquire down to a 1 microsec pixel dwell time so it's a little faster.
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Ben Buse

#4
This looks very interesting, if anyone creates a macro version, I'd be very interested

I added the imaging code to one of the preexisting xls and
Remote.RemoteImageSetImageMode
gives the compile error: method or data member not found, which I guess means I don't know what I'm doing  ;D

John Donovan

Here is a test app for using these Remote Imaging functions that was developed for Dan Rusuitto at GE.  I just tested it now, and it does work in simulation mode.



See attached ZIP below.
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Ben Buse

I've found a compiler, and this is very helpful to work with. Thanks for providing

Dan R

Hi John and team,
I'm using the remote image interface on a JEOL 8530 with the JEOL ImageInterfaceType=7 (we are now able to collect faster JEOL images using the EDS interface) for two things:
1. automate image collection after driving from one location to another.
2. performing automated spot analyses after acquiring an image.

Automated image collection works fine, and I can collect series of images and save them.

However, during the automated spot analyses, image acquisition works fine on the first image (followed by point analyses) -- but then it seems to fail on subsequent images (see attached examples on two points on a metal standard: test and test2). The second (and subsequent) image appears to just be a copy of the first image with a bunch of lost pixels that must relate to where the beam has been scanning.

I can recover the system if I go into the JEOL PC-SEM software and click out of "EDS Analysis" mode and go back to "Observation" -- it asks if I want to leave spot mode -- but this defeats the purpose of automation. I see the same issue in your software *sometimes*, including the RemoteTestImage executable. Any thoughts on how I can reset the beam to get back to the right condition in between image collection + spot analyses -- you must have to do this during simultaneous WDS + EDS measurement?


After collecting the image and performing spot analyses, we do use RemoteImageSetBeamMode to set the beam mode back to 1, but this doesn't appear to fix the issue (see code snippets below).


Thanks,
Dan

Code snippets (in tcl) below for starting a point and stopping a point analysis:

proc jeol::startSpectrumAcq {xoffset yoffset counttime maxcounts} {

    variable handle
    variable nFixedSpecs
    variable nTunableSpecs
    variable countDone


    # Digital spot mode
    set mode 2
    puts "RemoteImageSetBeamMode mode=$mode"
    $handle RemoteImageSetBeamMode mode
    puts "mode set"
...

proc jeol::finishSpectrumAcq {} {
    variable handle
    try {
   try {
       # Stop the counters
       puts "RemoteStopAllCounters"
       $handle RemoteStopAllCounters
   } finally {

       # Return the beam to zero deflection
       set xoff 0.0
       set yoff 0.0
       puts "RemoteImageBeamDeflection2 xoff=$xoff yoff=$yoff"
       $handle RemoteImageBeamDeflection2 xoff yoff
   }
    } finally {

   # Reset the beam to 'scan' mode
   set mode 1
   puts "RemoteImageSetBeamMode mode=$mode"
   $handle RemoteImageSetBeamMode mode
    }



John Donovan

#8
Quote from: Dan R on March 04, 2025, 02:33:52 PMHi John and team,
I'm using the remote image interface on a JEOL 8530 with the JEOL ImageInterfaceType=7 (we are now able to collect faster JEOL images using the EDS interface) for two things:
1. automate image collection after driving from one location to another.
2. performing automated spot analyses after acquiring an image.

Automated image collection works fine, and I can collect series of images and save them.

However, during the automated spot analyses, image acquisition works fine on the first image (followed by point analyses) -- but then it seems to fail on subsequent images (see attached examples on two points on a metal standard: test and test2). The second (and subsequent) image appears to just be a copy of the first image with a bunch of lost pixels that must relate to where the beam has been scanning.

This is a known issue with the JEOL 8230/8530 EDS video imaging interface.

What happens and how to fix it, is explained here:

https://smf.probesoftware.com/index.php?topic=40.msg10743#msg10743

So basically you need to unfreeze the imaging system, then and wait long enough so that the partial video image is finished and then start the video frame acquisition. That way you obtain a full video image at your specified frame rate.
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Dan R

#9
Thanks John, so I should set the JEOL scan to slower and then use a delay -- any tips for how long your default scan delay is? Is it configured in the probewin.ini?

Is there a sample snippet of code you could share for that delay button? is it just a timer?

John Donovan

#10
Quote from: Dan R on March 04, 2025, 04:50:55 PMThanks John, so I should set the JEOL scan to slower and then use a delay -- any tips for how long your default scan delay is? Is it configured in the probewin.ini?

It's going to depend on the image size and frame rate so I would do some testing in Probe for EPMA and see what sort of delay is necessary for your imaging requirements.

Yes, you can set the default value in the probewin.ini file

[image]
JEOLUnfreezeDelay=2

in seconds. We tried to get JEOL to fix this partial video frame issue for the 8230/8530, but they said they were already working on the new MEC EDS interface for the iSP100/iHP200F instruments and didn't want to spend time on an old interface...

Please note that I edited the instructions above.  The unfreeze delay is applied after the unfreeze command, but *before* the image acquisition is started.

But the problem now is, that the unfreeze command in Probe for EPMA is applied outside of the image acquisition procedures. This is because the unfreeze command is utilized in several other places in PFE, for example when starting integrated EDS acquisitions using the JEOL MEC interface.

Because it turns out that JEOL needs to have the stage positions updated when adding points to the EDS acquisition "reservation list".  And the EDS "reservation list" stage positions can only be updated when the video imaging is "unfrozen".

Yeah, it's crazy, but that's the way it is.  So because because this "unfreeze" command is not implemented in the Remote Automation interface, we will have to add that.  Give us a few days to look into this.
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Dan R

Thanks John, I appreciate the help. The new instrument we are redeveloping our software for will be an iHP200F -- I assume PFE and Remote will still work on this even with the new version of PC-SEM software? Our issue is that we originally bypassed all this trouble by using a Thermo NSS scan generator, however Thermo will no longer sell these for 3rd party equipment (i.e., non-Thermo SEMs).

John Donovan

#12
The new iHP200F instrument uses a completely different (JEOL) EDS and video imaging interface. We've implemented the EDS calls, but not the video imaging yet, but we hope to implement the MEC video imaging at some point.

Right now people who have an iSP100/iHP200F instrument and want to do analog signal imaging in Probe for EPMA (or Remote), must use the JEOL mapping interface, which is as you, know a bit slow as the minimum dwell time is 0.1 millisec (100 microsec) per pixel for the mapping call.

Yes, the Thermo EDS imaging was a great solution and is no longer available for EPMA instruments, but if I were you I'd buy a Bruker EDS with your new instrument. Then you get a great EDS detector and imaging system.

For one thing, we've already interfaced Probe for EPMA to the Bruker imaging system. Second, you will have the ability to specify a frame time independently of the of the image size.  With the JEOL 8230/8530 and iSP100/iHP200F video imaging systems, the frame times are determined by the image size as seen here:

' 64x48    : 100 us
' 128x96  : 100 us
' 256x192  : 80 us
' 512x384  : 60 us
' 1024x768  : 33 us
' 2048x1536 : 33 us
' 4096x3072 : 33 us

So for a 64 x 48 or 128 x 96 video image, the pixel dwell time is the same as the WDS beam scan mapping call, but for larger images the dwell time drops to 1/3 the time of the mapping call which is limited to 100 us per pixel.

So bottom line, we haven't implemented the new MEC video imaging calls yet, but hope to at some point in time. Or you could buy a Bruker EDS and be able to specify the pixel dwell time and image size independently!  And it's already supported.
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

John Donovan

In the Remote automation interface, we added a call to "unfreeze" command for the video imaging on JEOL 8230/8530 instruments.  We also added the call to the TestRemoteImaging test application:



The source code for this project is attached below. This command is to be used when acquiring images using the ImageInterfaceType=7 (JEOL video) in the Probewin.ini file (for 8230/8530). This new command:

Remote.RemoteImageUnfreeze

is used to avoid acquiring a partial image frame from the JEOL video imaging. The idea is to unfreeze the imaging system using this command.  This call will then wait for 2 seconds by default, so the next frame completes, but one can define a longer delay in the Probewin.ini file for larger image sizes.  Alternatively one can simply add an additional timer delay in your macro or script, before acquiring a video image.

We will hopefully be adding the JEOL MEC video imaging for the iSP100/iHP200F instruments using the Microscope External Control (MEC) interface later this year.

We also updated the Remote user documentation and the Help file. Please download the latest Remote automation software from the Probe Software Resources pages to obtain the latest Remote automation interface installer:

https://www.probesoftware.com/resources/

from the Remote COM Download button.
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Dan R

Thanks John, so when we are collecting an image, our system is actually in 'analog scan' mode, so to modify your original VBA code above, we would need to:

Sub TestRemoteImageGet()
' Get analog signal image

ierror = False
On Error GoTo TestRemoteImageGetError

' Send the image channel
Remote.RemoteImageSetImageMode ImageChannel%

Dim done%                              ' returned, true (-1) if image complete
Dim ntype As Integer                    ' passed (1 = analog signal, 2 = x-ray)

Dim sxmin As Single, symin As Single    ' returned (stage coordinates of corners)
Dim sxmax As Single, symax As Single  ' returned (stage ccordinates of corners)
Dim zmin As Long, zmax As Long          ' returned (intensity min/max)

ReDim iarray(1 To ImageIx%, 1 To ImageIy%) As Byte  ' returned (0-255 normalized intensity data)
ReDim darray(1 To ImageIx%, 1 To ImageIy%) As Long  ' returned (raw intensity data)

' Set beam mode to analog or digital spot (comment out other line)
'Remote.RemoteImageSetBeamMode 1                          ' set to analog scan mode for SX100 mapping or SX100 video or Bruker or Thermo imaging

' Remove faraday cup
Remote.RemoteFaraday 2

' CALL UNFREEZE
' SET DELAY AND WAIT


' Start the acquisition
Remote.RemoteImageStart

' Call image get in a loop until complete
Do Until done
Remote.RemoteImageGet done%, ntype%, ImageChannel%, AnalogAverages%, ImageIx%, ImageIy%, sxmin!, symin!, sxmax!, symax!, iarray(), darray&(), zmin&, zmax&

Sleep 100
DoEvents
If ierror Then Exit Do
Loop

' Convert long values to byte array
ReDim barray(1 To ImageIx%, 1 To ImageIy%) As Byte
Screen.MousePointer = vbHourglass
Call BMPConvertLongArrayToByteArray(ImageIx%, ImageIy%, darray&(), barray())
Screen.MousePointer = vbDefault
If ierror Then Exit Sub

' Display intensity data
Call TestRemoteImagingConvertImage(ImageIx%, ImageIy%, barray(), FormMAIN)
If ierror Then Exit Sub

msg$ = "Sxmin=" & Format$(sxmin!) & ", Sxmax=" & Format$(sxmax!) & vbCrLf
msg$ = msg$ & "Symin=" & Format$(symin!) & ", Symax=" & Format$(symax!)
FormMAIN.TextLog.Text = msg$

' Insert faraday cup
Remote.RemoteFaraday 1

' Set beam mode to analog scan mode
'Remote.RemoteImageSetBeamMode 1                          ' set to analog scan mode for SX100 mapping or SX100 video or Bruker or Thermo imaging

Exit Sub

' Errors
TestRemoteImageGetError:
MsgBox Error$, vbOKOnly + vbCritical, "TestRemoteImageGet"
ierror = True
Exit Sub

End Sub

Once the image is acquired, we would set to deflect the beam and perform spot analyses:
Remote.RemoteImageSetBeamMode 2                          ' set to digital spot mode for JEOL 8200/8900/8500

and then we would start again in another location...