News:

:) Before making a new topic, please check that a relevant topic does not already exist by using the Search feature

Main Menu

Negative values in JEOL software PC-EPMA

Started by Ben Buse, December 10, 2025, 02:38:59 AM

Previous topic - Next topic

Ben Buse

Hi is it possible to have negative values in JEOL software PC-EPMA when using XPP. I have a note that to enable for ZAF do following
"use_negKrat"  (empty textfile)  in "C:\JEOL\exe_spview\System\conf\soft\"The note I made is dated 2013, and suggested it only enabled it for ZAF
Is this still the case?

Nicholas Ritchie

Sounds like a really bad idea.   John handles this the right way.  Negative k-ratios should be truncated to zero !except! when taking the average of multiple measurements. Then the average of the measured k-ratios should be truncated to zero before being fed into a matrix correction algorithm.
"Do what you can, with what you have, where you are"
  - Teddy Roosevelt

John Donovan

#2
This topic is actually a bit complicated.  There is another discussion on this topic here:

https://smf.probesoftware.com/index.php?topic=30.0

In fact, some analytical matrix corrections can handle negative k-ratios, and some can't.

Yes, there is a ForceNegativeKratiosToZero flag in PFE, but it is turned off by default, though it can be turned on automatically from the Probewin.ini file. Though in fact it actually does not force the k-ratio to zero, instead it is forced to a very small concentration, that is 10^-8

However, I do not recommend that this flag be utilized, as this can cause negative values to be truncated, which can be problematic when making replicate measurements at nominally zero concentrations.  That is, there SHOULD be a variance around zero that includes both positive and negative k-ratios.

Also, the use of this flag can make it difficult to troubleshoot various issues such as poorly fitted backgrounds, vs. over correction of interferences vs. improper blank corrections.

Here are some code snippets from Probe for EPMA/CalcZAF/CalcImage that deal with negative k-ratios. Though I am not sure that this implementation is perfect for every matrix correction method "out there", it can handle lots of problematic situations such as pixel by pixel quantification of x-ray maps where cracks and voids are present and negative k-ratios are not uncommon:

Const MAXNEGATIVE_KRATIO! = -0.2
Const MAXNEGATIVE_SUMKRATIO! = -0.01

' Check for force to zero flag
If ForceNegativeKratiosToZeroFlag = True Then
If zaf.krat!(i%) <= 0# Then zaf.krat!(i%) = NOT_ANALYZED_VALUE_SINGLE! / 100#   ' use a non-zero value
End If

' Check for extremely negative k-ratios on each measured element
If zaf.krat!(i%) <= MAXNEGATIVE_KRATIO! Then GoTo ZAFSmpVeryNegativeKratio
End If

' Check for negative sum of k-ratios
If zaf.ksum! < MAXNEGATIVE_SUMKRATIO! Then GoTo ZAFSmpNegativeSumOfKratios


ZAFSmpVeryNegativeKratio:
msg$ = "Very negative unknown k-ratio for " & sample(1).Elsyms$(i%) & " " & sample(1).Xrsyms$(i%) & " on channel " & Format$(i%) & " on line " & Format$(sample(1).Linenumber&(row%)) & "."
msg$ = msg$ & vbCrLf & vbCrLf & "Please check for large off-peak interferences and if necessary re-acquire the data with proper background offsets."
msg$ = msg$ & vbCrLf & vbCrLf & "One can also set the Force Negative Kratios To Zero flag in the Analytical | Analysis Options dialog or disable quant for this element in the Elements/Cations dialog."
If Not CalcImageQuantFlag Then
MiscMsgBoxTim FormMSGBOXTIME, "ZAFSmp", msg$, 20#
Call IOWriteLog(msg$)
Else
Call IOWriteLog(msg$)
End If
zerror = True
Exit Sub

ZAFSmpNegativeSumOfKratios:
msg$ = "Negative sum (" & Format$(zaf.ksum!) & ") of unknown k-ratios on line " & Format$(sample(1).Linenumber&(row%)) & "."
msg$ = msg$ & vbCrLf & vbCrLf & "If analyzing only for trace elements be sure that matrix elements are specified using the Specified Concentrations dialog from the Analyze! window."
msg$ = msg$ & vbCrLf & vbCrLf & "Please also check for large off-peak interferences and if necessary re-acquire the data with proper background offsets."
msg$ = msg$ & vbCrLf & vbCrLf & "One can also set the Force Negative Kratios To Zero flag in the Analytical | Analysis Options dialog or disable quant for this element in the Elements/Cations dialog."
If Not CalcImageQuantFlag Then
MiscMsgBoxTim FormMSGBOXTIME, "ZAFSmp", msg$, 20#
Call IOWriteLog(msg$)
Else
Call IOWriteLog(msg$)
End If
zerror = True
Exit Sub

This code allows for individual (element) negative concentrations as low as -20% as long as the sum total k-ratio is greater than -1%. The complete code can be found in the Open Microanalysis site in the ZAFSmp procedure in the ZAF.BAS file:

https://github.com/openmicroanalysis/calczaf

Note also on the other end of things, that there are important considerations when performing elements or formulas specified by difference from 100%, when the sum total without the element by difference exceeds 100%. This is similar to the force k-ratios to zero issue when measuring around zero, in that we don't want to assume that our total is 100% when performing quant calculations where the replicate total should nominally average to 100%.

For example, calculating water by difference:

https://smf.probesoftware.com/index.php?topic=861.msg6596#msg6596

That is, if the nominal total should be 100%, we want to be sure to calculate a negative element by difference when the total (without the element by difference) is over 100%, in order to obtain a statistical 100% average total for replicate results.

Yeah, it's a bit complicated.    ;D
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

John Donovan

#3
I understand some of this does not seem intuitive.  I had to think about this for a long time to figure this out!

Consider when one is attempting to measure an element where the concentration is exactly zero.  There will, of statistical necessity (from say the background correction), some measurements where some k-ratios are negative and some are positive. Hopefully about half of all replicates are either negative or positive, if the background correction is accurate.  Replicate measurements will show a Gaussian (Poisson) distribution around a zero k-ratio for homogeneous materials. 

Note however that we do not need to assume a homogeneous replicate set of measurements. Each analysis point is treated independently for the purposes of all corrections. This is especially the case for quantification of x-ray maps with multiple phases each requiring a different set of unanalyzed elements for proper matrix corrections:

https://smf.probesoftware.com/index.php?topic=1647.0

In other words, if, when measuring a zero concentration of an element, one forces each negative k-ratio to zero (or a very small positive number), when these results are averaged together, there will have been applied a positive bias to the average:

https://smf.probesoftware.com/index.php?topic=392.msg9015#msg9015

Same thing applies when measuring an element by difference where the concentration is also exactly zero.  In this case sometimes the total of the matrix elements will be below 100% and the element by difference will be a positive number, but sometimes the total of the matrix elements will be above 100% (because photons have a statistical variance), so the element by difference must be negative to obtain an replicate measurement average centered around 100% for the element by difference.

If one did not treat the element by difference in this way, and instead zeroed out the element by difference whenever the matrix total was over 100%, one would create a bias in the element (or formula) by difference concentration, pushing the average towards larger values.
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Les Moore

There are some complicating factors here and it depends on how much of a purist you are. 
1. The Bkg correct in the JEOL mapping software averages the low & hi counts and if negative assigns it to zero. If the average counts in the bkg maps is close to zero this can result in a significant (re the average) increase in average counts.
2. The software uses integer arithmetic and I believe it truncates the decimal points; again, a compromise.
3. If you want a pure effect, run three separate maps and use Excel to average and subtract - it will be obvious and not hidden.

4. Fractional count averages are OK and you can do 95% CI comparisons on the averages ... meh
5. Don't forget the thin film X-Ray yield is an integration between the landing voltage and the energy the electron leaves the film and into the substrate. The higher the kV (above the Overvoltage), the more you lose into the substrate where it can contribute to the Bkg problems.

John Donovan

#5
Quote from: Les Moore on December 17, 2025, 04:34:01 PM1. The Bkg correct in the JEOL mapping software averages the low & hi counts and if negative assigns it to zero. If the average counts in the bkg maps is close to zero this can result in a significant (re the average) increase in average counts.

I don't understand how averaging the hi and lo background counts could produce a negative number. X-ray measurements should always produce a positive number or zero.

The only time a negative number could be produced is when subtracting the background counts (however they are calculated) from the peak counts to obtain the net intensity for subsequent quantification.

Quote from: Les Moore on December 17, 2025, 04:34:01 PM2. The software uses integer arithmetic and I believe it truncates the decimal points; again, a compromise.

The JEOL "software uses integer arithmetic"?  Doesn't every one use x-ray intensities in cps/nA?

Maybe the map intensities are not corrected for dead time, or beam drift, sure.  But why not use floating point math? 

Maybe they're trying to save memory, but then you'd have to use 2 byte integers (compared to 4 byte floats)...
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"