% \documentclass[portrait,25pt]{sciposter}
\documentclass[]{beamer}
\usepackage[orientation=portrait,size=a0extended,scale=1,debug]{beamerposter}
\usepackage[utf8x]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{wasysym}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{fancyhdr}
\usepackage{tikz}
\usepackage[version=3]{mhchem}
\usepackage[lf]{venturis}

\setbeamertemplate{caption}[numbered] 

\title{A software tool for evaluating and enhancing the quality of EELS spectra for EMCD}
\author{A. Hasenkopf and J. Zweck}
\institute{Fakultät für Physik, Universität Regensburg}
\date{Aug. 28th, 2011}

%%%%%%%%%%%%%%%%%%%%
% Document started %
%%%%%%%%%%%%%%%%%%%%

\mode<presentation>{
\usetheme{Regensburg}
\usecolortheme{PhysikPoster}
}

\begin{document}
\begin{frame}{\vspace{1ex}\hfill Keywords: \bfseries EMCD, EELS, spectrum processing \& filtering}
	\begin{columns}[t]
	\column{.45\columnwidth}

		\begin{block}{Motivation / Problem}
			\begin{multicols}{2}
				\setlength{\parindent}{1.2em}
				\setlength{\parskip}{1ex}

				Quality of EELS spectra acquired in diffraction mode (detector shift method for EMCD) can suffer from a series of phenomena (compare fig. \ref{fig_eels-coni}) which strongly reduce the quality of spectra:

				\begin{itemize}
					\item Increased signal-to-noise ratio (SNR)
					\item Shifted and strained features
					\item Different shape of background
				\end{itemize}

				\begin{figure}[h]
					\centering
					\includegraphics[width=.9\columnwidth]{eels-coni.png}
					\caption{\small EELS spectra of \ce{Co} and \ce{Ni}. Switching from imaging (exposure time 1 s) to diffraction (exposure time > 1 min) mode can cause shifts of several electron volts of features, e.g. the \ce{L23} edges. Due to the low intensity between diffraction spots the SNR is strongly increased. Especially the \ce{Co} spectra show different behaviors in the tailing area after the \ce{L23} edges.}
					\label{fig_eels-coni}
				\end{figure}

				\begin{figure}[h]
					\centering
					\includegraphics[width=.9\columnwidth]{emcd-no-fe.png}
					\caption{\small EELS spectrum of monocrystalline \ce{Fe} in diffraction mode. Poor alignments of the TEM can increase the effects shown in fig. \ref{fig_eels-coni} drastically: The \ce{L23} edges are strongly distorted and shifted approx. 400 eV.}
				\end{figure}

				These distortions can have different sources and require different solutions. A useful concept is switching to a telefocus mode \cite{lidbaum2}, but not all problems are solved by adjusting the alignment.

				Until now there was no convenient way to calculate EMCD signals from EELS spectra which are shifted in energy. Established tools, e.g. Digital Micrograph, offer a means for recalibrating the energy scale of an EELS spectrum, but the process of subtracting two recalibrated spectra does not preserve these calibrations (see fig. \ref{fig_dm}).

				\begin{figure}[h]
					\centering
					\includegraphics[width=.9\columnwidth]{digitalmicrograph.png}
					\caption{\small EELS spectra and EMCD signal (difference between spectra). Output of Digital Micrograph. An incorrect energy scaling of the two spectra results in twisted and enlarged features of the EMCD signal. }
					\label{fig_dm}
				\end{figure}

				The result is the difference of the uncalibrated spectra showing 
				strong distortions (see fig. \ref{fig_dm}) due to 
				different energy scales. 

				In addition to the need of correct treatment of shifted spectra a minimum of required user interaction would be comfortable.
			\end{multicols}
		\end{block}

		\begin{block}{The software solution}
			\setlength{\parindent}{1.2em}
			\setlength{\parskip}{1ex}

			Using the Python programming language we have written a program (licensed under GPL, available for download at \cite{emcd_tool}) for the comfortable treatment of EELS spectra for determination of EMCD signals.

			\begin{figure}[h]
				\centering
				\begin{columns}[t]
				\column{.33\columnwidth}
					\includegraphics[width=\columnwidth]{main-window.png}
					\caption{\small Screenshot of main window}
					\label{fig_main-window}
				\column{.32\columnwidth}
					\includegraphics[width=\columnwidth]{background-removal.png}
					\caption{\small Screenshot of interactive background removal}
					\label{fig_background-removal}
				\column{.32\columnwidth}
					\includegraphics[width=\columnwidth]{energy-scale-alignment.png}
					\caption{\small Screenshot of interactive energy scale alignment}
					\label{fig_energy-calibration}
				\end{columns}
			\end{figure}

			The screenshots (fig. \ref{fig_main-window} - 
			\ref{fig_energy-calibration}) show the different steps which require user interaction. A crucial issue was to process the spectra simultaneously with as less "clicks" as neccessary.

			\begin{columns}[t]
				\column{.45\columnwidth}
				\begin{block}{Features}
					
					\begin{itemize}
						\item Reads \textbf{*.dm3} and compressed 
						\textbf{*dm3.gz} files
						\item Different background removal models (compare \cite{verbeeck_3})
						\item Different filter models
						\item Reduced user interaction. User input is required for (see fig. \ref{fig_background-removal} and \ref{fig_energy-calibration}):
						\begin{itemize}
							\item Selecting a range for fitting the background model.
							\item Selecting a range in which the positions of \ce{L23} edges are determined.
						\end{itemize}
						\item Option to pan/resize and save spectra in open file 
						format:
						\begin{itemize}
							\item Saved \textbf{xml} files can be 
							reopened and contain meta data from the 
							DM3 files.
							\item The resulting graphs (see figs 
							\ref{emcd_twinview} - \ref{emcd_35_2}) can 
							be saved in different open image file 
							formats.
						\end{itemize}
					\end{itemize}
				\end{block}

				\column{.45\columnwidth}
				\begin{block}{Order of operation}
				\setlength{\parindent}{1.2em}
				\setlength{\parskip}{1ex}

					The program performs its tasks in a given order as defined in an internal list:

					\begin{enumerate}
						\item Filter application.
						\item Background removal.
						\item Energy scale alignment.
						\begin{enumerate}
							\item Resample spectra on a common energy 
							scale using interpolation algorithm.
							\item Shift spectra
							\item[$\Rightarrow$] \ce{L2} and \ce{L3} edges are 
							equally spaced in each spectrum and appear 
							at corresponding energy values in 
							different spectra.
						\end{enumerate}
						\item Normalization of spectra.
						\item Calculation of dichroic (EMCD) signal.
					\end{enumerate}

					%~ \begin{flushright}
						%~ \includegraphics[height=10ex]{python_logo}
						%~ \includegraphics[height=10ex]{scipy_logo}
					%~ \end{flushright}

				\end{block}
			\end{columns}
		\end{block}

		\begin{block}{References}
			
			\small
			\begin{multicols}{2}
				\setbeamertemplate{bibliography item}[text]
				\bibliographystyle{unsrt}
				\bibliography{literature}
			\end{multicols}
		\end{block}
	
	\column{.5\textwidth}
		\begin{block}{Test sample}
			\begin{columns}[t]
				\column{.3\columnwidth}
					\begin{table}[h]
						\centering
						\begin{tabular}{|l|c|}
							\hline
							Material & \ce{Co} single crystal\\
							Orientation & $[0001]$\\
							\textbf{g} & $(11\bar{2}0)$ \\
							EMCD Mode & 3 beam case\\ \hline
						\end{tabular}

						\caption{Sample Properties}
					\end{table}
				\column{.65\columnwidth}
					\setlength{\parindent}{1.2em}
					\setlength{\parskip}{1ex}
					In order to demonstrate the benefits of this program we compare one set of EELS spectra of a monocrystalline \ce{Co} sample.

					Spectra were acquired using Digital Micrograph (4x binning). Further treatment was performed by our software tool.

					The distances between the \ce{L2} and \ce{L3} edge are 9 channels and 10 channels, respectively, in the spectra.
			\end{columns}
		\end{block}
		
		\begin{block}{Processed EELS spectra and EMCD signal}
			\begin{columns}[t]
				\column{.45\columnwidth}
					\begin{figure}[h]
						\includegraphics[width=.8\columnwidth]{emcd-co-power-gauss-30.png}
						\caption{\small Output of program. Upper subplot: Unfiltered (dotted lines) and filtered (continuous line, Gaussian Filter with a kernel size of 3.0) EELS spectra. Lower subplot: Corresponding differences of the filtered and unfiltered spectra (EMCD signals).}
						\label{emcd_twinview}
					\end{figure}
				\column{.45\columnwidth}
					\begin{figure}[h]
						\includegraphics[width=\columnwidth]{emcd-co-power-gauss-50.png}
						\caption{\small Output of program. A Gaussian filter with a 
						kernel size of 5.0 has been applied prior to power law background removal.}
						\label{emcd_70}
					\end{figure}
			\end{columns}
			\begin{multicols}{2}
					\begin{itemize}
						\item In all examples (figs. \ref{emcd_twinview} - 
						\ref{emcd_35_2}) a Gaussian filter and a power law background have been applied.
						\item In all examples the shift of features on the energy axis has been corrected.
						\item In figs. \ref{emcd_twinview} and \ref{emcd_35_2} the difference in dispersion values of the filtered spectra has been corrected using a cubic interpolating algorithm.
						\item Resampling can be treated as an alternative \textbf{or} a supplement (for small kernel sizes, $\sigma\lesssim 2\Delta x$) to filtering.
						\item Application of a filter reduces noise considerably, \textbf{but} gives rise to "background oscillations" (see fig. \ref{emcd_70}).
						\item Increasing the kernel size of the filter results in stronger reduction of noise, \textbf{but} broadens features and decreases the height of the \ce{L23} edges.
					\end{itemize}
			\end{multicols}
			
			\begin{columns}[t]
				\column{.48\columnwidth}
					\begin{figure}[h]
						\includegraphics[width=\columnwidth]{emcd-co-power-gauss-13.png}
						\caption{\small Output of program. Kernel size of filter: 1.3. No resampling of spectra has been performed.}
						\label{emcd_35}
					\end{figure}
				\column{.48\columnwidth}
					\begin{figure}[h]
						\includegraphics[width=\columnwidth]{emcd-co-power-gauss-13-resampled.png}
						\caption{\small Output of program. Kernel size of filter: 1.3. The spectra have been resampled on a common energy axis.}
						\label{emcd_35_2}
					\end{figure}
			\end{columns}
		\end{block}

		\begin{block}{Results}
			\begin{multicols}{2}
				%\column{.48\columnwidth}
					\setlength{\parindent}{1.2em}	
					\setlength{\parskip}{1ex}
				
					Background models are equally applicable to spectra as long as they match the actual background \cite{verbeeck_3}. Due to the actual implementation the \textbf{Power law} model is strongly recommended.
					
					The tool offers different filter models, but only the \textbf{Gaussian Blur} shows reasonable results.
					
					Having found proper parameters (background model, filter model and kernel size; see table \ref{good_settings}) one can display the dichroic signal of poor (high SNR) raw data. 
					
					In addition, resampling of the spectra on a common energy scale only shows its advantages for small kernel sizes (compare figs. \ref{emcd_35}, \ref{emcd_35_2} and \ref{emcd_70}).		
									
					\begin{table}[h]
						\begin{tabular}{|l|r|}
							\hline
							\multicolumn{2}{|c|}{\bfseries Suitable 
							parameters}\\
							\hline
							Background & Power Law\\
							\hline
							Filter & Gaussian Blur\\
							\hline 
							Kernel size & 1 -- 5\\
							\hline
						\end{tabular}
						\caption{This parameters have returned in 
						various scenarios to be suitable.}
						\label{good_settings}
					\end{table}
					
					Comparing figs \ref{emcd_twinview} - \ref{emcd_35_2} with fig. \ref{fig_dm} one can see major (dis-)advantages relative to established software.
				%\column{.48\columnwidth}
					%~ \begin{figure}[h]
						%~ \includegraphics[width=\columnwidth]{emcd-ni-power-gauss-50.png}
						%~ \caption{\small Output of program. \ce{L23} edges of a \ce{Ni} sample. \textbf{g}=(110), 2 beam case. Gaussian filter with kernel size of 5.0.}
						%~ \label{emcd_ni}
					%~ \end{figure}
			\end{multicols}

			\noindent
			\begin{minipage}{.98\columnwidth}
				\begin{block}{Advantages}
					\begin{itemize}
						\item Reduction of human interaction in the process of determining dichroic signals.
						\item "Complete" alignment on a common energy scale strongly reduces artifacts in EMCD signals.
						\item Application of a filter (e.g. Gaussian) emphasizes features of the spectra, e.g. the \ce{L23} edges of \ce{Co}, and reduces noise in the background.
					\end{itemize}
				\end{block}
			\end{minipage}

			\noindent
			\begin{minipage}{.98\columnwidth}
				\begin{block}{Disadvantages \& Known bugs}
					\begin{multicols}{2}
						\setlength{\parindent}{1.2em}	
						\setlength{\parskip}{1ex}
						\begin{itemize}
							\item Application of an unsuitable filter or kernel size can lead to useless results.
							\item Some filters and background models show poor results as they have been neglected in the development process of this tool.
							\item The script has to be restarted for each set of spectra.
						\end{itemize}
					\end{multicols}
				\end{block}
			\end{minipage}
		\end{block}

	\end{columns}

\end{frame}
\end{document}
