# Data analysis
The following tools are typically used to analyze MAXPEEM measurement data:
- [athina](https://gitlab.maxiv.lu.se/evagko/athina) is an in-house developed analysis toolbox for Igor Pro 9 or newer.
- [ImageJ](https://www.dropbox.com/sh/3hw0ts4tvufd3gp/AABj-EfVO1CbgqesGMQ9FDc-a?dl=0)
- Python-based [MAX IV Jupyterlab notebook](https://jupyterhub.maxiv.lu.se/)
## Igor Pro (athina package)
*athina* provides a comprehensive package for PEEM/LEEM/PES/ARPES/XMC(L)D-PEEM/STM data analysis.
Check [athina's documentation](https://evagko.gitlab-pages.maxiv.lu.se/athina/) hosted at MAXIV's intranet or publicly at [gitlab](https://evangelosgolias.gitlab.io/athina/). There you can find instructions on how to install *athina* and how to use it to process your data.
```{note}
You can use Igor Pro for during you beamtime and still be able to access your analysis at home even if you do not have an Igor Pro license. Save your analysis as HDF5 packed experiment file (.h5xp, which is the default option at MAXPEEM) and you will be able to access your files using any HDF5 program ([Silx](https://www.silx.org/doc/silx/latest/index.html) for example). **We can also provide a python script to extract all images, image stacks, plots, and notes from the Igor Pro file.**
```
```{tip}
Access to the source code outside MAXIV at [gitlab](https://gitlab.com/evangelosgolias/athina).
```
## ImageJ
### Background image substraction with ImageJ
1. Import both images
2. Select Process > Image Calculator
3. Choose the original image as Image1, the background as Image2, and select Subtract.
### Drift correction with ImageJ
1. **Import sequence**: File – Import – Image sequence
2. **Check spectra**: Image – Stack – Plot z-axis profile
3. **Adjust image**: Image – Adjust – Brightness/Contrast
4. **Drift correction**: select a rectangle area – Plugins – Template Matching – Align slices in stack – search area 20 (100) pixels for small (large) drift
**Plugins**: https://sites.imagej.net/Template_Matching/plugins/
### Plotting LEED with ImageJ
1. **Import data**:File – Import – Raw
2. Calculate the `Offset to first image = file size in byte - 2*2048*2048`
* The size of file can be found in the Property of data file.
```{image} ./imgs/LEED_ImageJ.png
:align: center
:width: 300
```
### Calculate XMCD with ImageJ
1. Import sequence from folder(two files): circular left and circular right, e.g. named as CL, CR.
2. Drift correction.
3. File-Open-calculateAS.ijm (file locates at c disk - Fiji - micro) and run on the drift-corrected images. The created image represents CL/CR.
* If user has clicked on other image, remember to click on the XMCD image before running the code.
% i1=CL, i2=CR, Operation: new_i2 =(i1/i2) x k1 + k2, k1=1100, k2=0
## Python with Jupyterhub
Guide's coming soon.