MCA spectral data
The MCA data is an XRF spectrum for every pixel of your image data. It is collected separately from the data you worked with at the beam line.
This data can be very powerful and allows you to extract more from your analysis. For example, you can extract the spectrum from a specific pixel or region. A very useful feature is that you can bin any part of the spectrum and plot the distribution of that bin. So you can get the distribution of an element that you didn’t window during your analysis. Also, with appropriate standardization, you can use the MCA data to extract quantitative information by doing peak fitting (which can be done within SMAK which utilizes the PyMCA engine developed by ESRF, but with a much more user friendly GUI).
All this is outlined below.
Your MCA data is saved as a zipped files on your T drive as filename.tar.gz. This is what we mean when we say we need to log in on the last morning of your run to “zip the data”.
There is some prepping to do before you can load this data into SMAK and work with it.
Unzip the zip file
First we have to unzip the file. This single zip file itself contains zip files for each map you collected. Data for each map contains an hdf5 file for each line (filename_1, filename_2, etc.).
On a Mac:
Once you copy the file to a Mac, it usually produces a “tmp” or “data” folder automatically with a bunch of zip files in it.
Unzip the specific zip file for the map you want look at simply by double clicking it. This will create another “tmp” or “data” folder which will have all the hdf5 files in it, one for every line of the map.
On a PC:
You may have to download an unzipping program such as 7‐zip (there are others out there).
Typically you right click the zipped file and select “extract files”, “extract here”, “unzip”, or whatever, depending on your program.
This produces a “tmp” or “data” folder with a bunch of zip files in it.
Unzip the specific zip file for the map you want look at by repeating step 2. This will create another “tmp” or “data” folder which will have all the hdf5 files in it, one for every line of the map.
Note that the following command also works if you do not want to download an unzipping program:
Type "cmd" into the search bar to bring up a command window. Select "Run as administrator"
Type the following command (this is all on one line): tar -xvzf C:\PATH\TO\FILE\FILE-NAME.tar.gz -C C:\PATH\TO\FOLDER\EXTRACTION
Constructing a single “MCA file”
Now you need to combine these individual .hdf5 files into one usable “MCA” file (filename_MCA.hdf5). You only need to do this process once for each map file so you can archive the unpacked zip data and work with just this new file.
In SMAK open the normal image file (like you would at the beam line).
Click on the “MCA Spectra” menu and then “HDF5 write compression”.
Select “GZIP 9”.
4. Next, click the “MCA Spectra” menu again and select “Construct Xspress3 HDFs”.
5. You will be prompted to select a file. Navigate to the location where you unpacked the zipped MCA files (the one with a .hdf5 for every line) and select any one of the individual .hdf5 files, it doesn’t matter which.
6. SMAK will produce a pop up window with check boxes for 1 through 4 channels. If you were at a beam line with a 1 element detector (like 2–3) then select Channel 1. If your data came from a 4 element detector, select all 4 channels.
7. You will be asked whether this was a bidirectional scan. Typically this is no. If you did bidirectional you would know.
8. You will see a “Reading HDF files” in the bottom left of the mail SMAK window.
9. When this message returns to ready, you should now have a file “filename_MCA.hdf5” in the “tmp” or “data” folder. This file is now completely self contained, you can put it anywhere on your system.
Using the MCA data
Under the MCA Spectra menu, select Define MCA and choose the _MCA.hdf5 we created in the previous steps. You are telling SMAK to look in this file for the MCA data.
Under MCA Spectra menu, select ‘View MCA’ (a check mark will appear next to this item). This tells SMAK that you want to be able to see the MCA data.
To look at your MCA spectra at:
(A) any point on your map, just double click the point on the map to see the spectrum from that pixel. You should now get a new window “MCA Spectrum View” displaying the spectrum with counts vs energy. For one pixel this will look quite noisy because the spectrum represent the counts from whatever your dwell time was, which is usually only in the 10’s of millisecond time frame.
(B) a region of your map, use shift-click to draw a bounding polygon and double-click to close the area while still holding down shift key.
1. A window will pop up. Select “MCA”.
2. You should now get an MCA Spectrum View with a much smoother spectrum. This is because it is an average/sum of the MCAs of each pixel in the area you selected. This also makes it much easier to fit.
Tip: You can toggle between linear and Log under View Trace Scale, in the new window that has popped up.
Using the MCA data for Multi energy Maps
The MCA files for multi energy maps are not initially split up according to energy, so you must tell the program to do this for you before you use the MCA files for peak fitting. After performing the steps for "Using the MCA data" described above:
(1) Under the MCA Spectra menu, select "Set MCA multi-file lines".
(2) In the pop-up box that says "Enter total number of energy sweeps in MCA file" enter the number of energies you collected for your multi energy map.
(3) Another pop-up box will show up that says, "Enter desired sweep number in MCA file" enter "1".
(4) Go to the MCA Spectra menu again. Select "Split MCA multi-files". This will split the MCA files according to energy and generate new data files in the same folder where your other MCA files are located, which are labeled "_split_0", "_split_1", "split_2", etc. You will have the same number of "split" files as the number of energies you collected. "_split_0" corresponds to the first energy in your multi energy maps, "_split_1" to the second energy, etc.
(5) Go to the MCA Spectra menu again. Select "Define MCA file". Select the "_split_" file that corresponds to the energy you want to fit.
(6) Go to the MCA Spectra menu one more time. Select "Set MCA mulei-file lines." Enter "1" and "1" into the pop up boxes.
You can now proceed to fit each individual energy in your multi energy map following the normal peak fitting protocol, described below.
Click on View Config in the MCA Spectrum View, a new window with the periodic table will pop up, the Peaks tab should be automatically selected, if not you can click on it. Here you can select what elements you want to include in a fit. There is an automatic list that will populate. If you want to delete any of those select it from the Peak list on the right then use the yellow Clear Selected button. Clear all will clear all of the elements chosen. To add more select the element you want from the periodic table then select the appropriate edge by clicking the K, L, M button.
Next go to the Parameters Tab while still in the ‘PyMCA Parameter Configuration’ window. There are four panels here with parameters you can change. Typically, one will focus on the top left and bottom right. The fitting region is in bin numbers, for most of our beamlines it relates to energy by multiply those values by 10. You can use this to just fit a small region, or exclude the scatter peak, etc. This panel also includes a Gaussian smoothing parameter that you can adjust if desired. Under detector one would typically uncheck the first 3 (Spectrometer Zero, Spectrometer Gain, and Detector Width) on the first small fit.
Next return to the MCA Spectrum View window. Here you can start your fitting. To make this easier you should first select Fit Current. This will only fit the spectrum that is in the window. It will do better if you have selected a larger area (more than one pixel) so that the spectrum looks smoother. Your data will be in yellow and the fit in green. Parameters of the fit will be in the command line window.
Once you are satisfied with the fit (you may make different starting points, x-axis range, or elements fix the first three parameters under detector back in the ‘PyMCA Parameter Configuration’ window.
Now back on the image map you can either zoom in on the area you wish to fit, then click Fit Zoom MCA, or you can Fit All MCA. These will do a fit for each pixel in the image or zoomed area. So this may take a while, depending on the size and speed of your computer.
Doing these fits will make a new set of channels in the main SMAK window that correspond to the elements you selected in the fit. Fit info can be found in the terminal window on a PC.