News:

:) If you can't see some "in-line" images in a post, try "refreshing" your browser!

Main Menu

NeXL

Started by Ben Buse, April 29, 2026, 04:25:34 AM

Previous topic - Next topic

Ben Buse

That's great, I'hadn't checked it was there, I'd just assumed it wasn't, I will give it a go.

Ben Buse

#46
Hi Nicholas, I think it's great NeXL screens out unsuitable standards which contain overlaps.

I'm concerned as to whether it should be screening out due to the presence of a minor element

In the emsa file for Sanidine I have 0.76 Ba

B4 Sanidine,(Na:1.27),(Al:9.8),(Si:30.27),(K:11.8),(O:46.03),(Ba:0.76)
This results in Sanidine being rejected

Info: A material containing Al, Ba, Na, Si, O and K is not a suitable reference for "K K-L3 + 3 others" due to a peak interference.
┌ Warning: A material containing Al, Ba, Na, Si, O and K provides no references for K.
└ @ NeXLSpectrum

Whereas if I delete the Ba concentration from the emsa it is no longer rejected.

Is sanidine with 0.76 Ba a suitable EDS standard.

Thanks

Ben Buse

Similarly with Durango Apatite

emsa
##D2STDCMP   : B4 Durango Apatite,(P:17.79694),(Ca:38.60773),(Si:0.1589262),(Na:0.170626),(S:0.1481775),(F:3.53),(Cl:0.41),(Ce:0.4268828),(La:0.3410718),(Nd:0.128602),(O:37.432)

Rejected on basis of small amount of Si and S

[ Info: A material containing S, Ca, Ce, Nd, O, Cl, Na, F, Si, La and P is not a suitable reference for "P K-L3 + 3 others" due to 2 peak interferences.
┌ Warning: A material containing S, Ca, Ce, Nd, O, Cl, Na, F, Si, La and P provides no references for P.

If remove Si and S it is no longer rejected.

Nicholas Ritchie

As you observe, there is a limit below which a trace element no longer matters - at least in practical terms.  However, as implemented, NeXL doesn't even consider the mass fraction when determining whether a material is suitable.  Even 1 part in 10^6 of an element will trigger a rejection.  Clearly, this doesn't always make sense.  But nor is there a clear cut-off between matters/doesn't matter.

As an alternative, I usually suggest to use pure elements or simple stoichiometric compounds as simple references.  If you really want to use a similar standard, fit the unknown with the simple reference, fit the similar standard with the simple reference (and the other elements as necessary) and compute the ratio of the two to get the k-ratio of the unknown relative to the similar standard.  This ratio of k-ratios idea is the key notion behind the k-ratio database.

"Do what you can, with what you have, where you are"
  - Teddy Roosevelt

Ben Buse

#49
Yes I agree it's complicated to define an almost limit depending on distance away, x-ray yield and concentration.

I do suspect though it's exacerbated in EPMA as we want to list the trace elements in the standards, which may be at EDS detection limit or negligible contribution compared to the major element being used for the standard.

For EDS I've been trying to use simple oxides Mgo, Al2O3, NaCl, TiO2, but also finding I running out of simple compound standards, and quartz is unstable under the electron beam, at high beam currents, which I can use with small aperture selected on collimator. I'd be interested in simple synthetic standards if anyone is sharing any material

I guess one way would be to read the emsa files exported from PFE remove trace elements and write the files. Recognizing this could cause an error where the interference is a problem

Do you find matrix matching important, or do you find pure metals working for silicates. In terms of your suggestion do I fit the unk and the complex standard as unk, using fitted_spectrum, to give the kratios. Then I take the kratios and divide them by each other.

Nicholas Ritchie

Personally, I find pure elements and simple stoichiometric compounds sufficient for almost everything. As JD points out, matrix correction has improved to the point where similar standards are rarely necessary.  He suggests to use secondary standards to validate the measurement rather than similar standards to make the measurement. 

My typical probe currents are on the order of 1 nA so material instability under the beam is not an issue.  However, I understand that for the probe currents necessary for WDS there can be a problem.

Reading and rewriting the composition makes sense to me.  It is a little tedious but it keeps you in control when deciding whether a trace element can be ignored.  I'd be much less concerned about omitting an element for hyperspectral maps where the data spectra are low count. I would be much more careful when ignoring elements on references to be used for point spectra.

I've implemented a mechanism to standardize using similar standards in NeXLSpectrum/standardize.jl  THere is an example here: https://github.com/usnistgov/NeXLSpectrum.jl/blob/master/test/standardize.jl
"Do what you can, with what you have, where you are"
  - Teddy Roosevelt

Ben Buse

Quote from: Ben Buse on May 12, 2026, 10:21:32 AMInfo: A material containing Al, Ba, Na, Si, O and K is not a suitable reference for "K K-L3 + 3 others" due to a peak interference.
┌ Warning: A material containing Al, Ba, Na, Si, O and K provides no references for K.
└ @ NeXLSpectrum


This feels a really basic question, but is there any way of writing these warning to file.

Nicholas Ritchie

Yes.  One popular way is to use Jupyter notebooks which record all the inputs and outputs.  I really like Weave.jl (https://weavejl.mpastell.com/stable/).  Weave is more script-like and generates HTML, PDF, Markdown, ... documents from a simple text format file.
"Do what you can, with what you have, where you are"
  - Teddy Roosevelt

Ben Buse

Quote from: Nicholas Ritchie on May 28, 2026, 09:30:40 AMYes.  One popular way is to use Jupyter notebooks which record all the inputs and outputs.  I really like Weave.jl (https://weavejl.mpastell.com/stable/).  Weave is more script-like and generates HTML, PDF, Markdown, ... documents from a simple text format file.
Weave looks nice, look forward to giving it a go next week

Ben Buse

Ok I gave weave a go, and it's nice, and whilst shows if error in weave report, it doesn't show the info and warning in weave report to say which standards where not suitable. Any ideas how to get the info and warnings


Ben Buse

Ok I can log the warnings to the file using the julia logger

jl.seval('using Logging')
jl.seval('io = open("log.txt", "w+")')
jl.seval('logger = SimpleLogger(io)')
jl.seval('global_logger(logger)')
jl.seval(''+referencestring+referencemiddle+referenceend)
jl.seval('weave(filename; doctype = "md2html", out_path = :pwd)')
jl.seval('close(io)')

Ben Buse

#56
Ok I've attached a python script that quantifies all the spectrum collected by PFE using NeXL, using the PFE assigned standards. Spectrum exported to emsa first using option within PFE. Standard interference problems written to log file and result quant and kratios written to csv files

Nicholas Ritchie

I'll have to try using the logger in Weave. Seems like a good solution.
"Do what you can, with what you have, where you are"
  - Teddy Roosevelt

Ben Buse

#58
Also I couldn't get gadfly plots to show in the weave html report, but found gadfly can also write interactive svg plots

eg for fitted spectra

res9= [fit_spectrum(u,refs5) for u in unks]
for x in 1:length(res9)
    myplot = plot(res9[x])
    filetest = string(res9[x].label) * string(x) * ".svg"
    Gadfly.draw(SVGJS(filetest),myplot)
end

And for standards

myplot = plot(spectra(refs5)..., klms=collect(elms(refs5)), xmax=8.0e3)
Gadfly.draw(SVGJS("refs5.svg"),myplot)

Weave doc attached

So if combine with above python script for processing PFE spectra get additionally the svg plots and the weave report - in python script attached.

Nicholas Ritchie

#59
 ??? I have had good success in the past getting Gadfly plots to work in Weave.

Maybe this will help: https://discourse.julialang.org/t/im-not-able-to-use-gadfly-weave/47810/5
It claims that Weave embeds PNG files which require Cairo and Fontconfig to generate.
using Cairo, Fontconfig
"Do what you can, with what you have, where you are"
  - Teddy Roosevelt