giovedì 5 giugno 2014

Analyzing and reporting spectra: Python to LaTeX Raman spectra analyzer

Most of the chemists don't know much about programming indeed mathematicians, physicists and of course IT engineers are familiar with Python and LaTeX and so they already know about their great potential. Analytical chemists use Excel (or software design for them like OriginPro) and Word processors, these are indeed great tools for data analysis but sometimes are not so efficient and convenient for repeated tasks. In academia these tools are very common (just look at some academic posters to recognize who uses Excel or OriginPro) and so they teach you to use them thinking that you will analyze only o bunch of spectra for the publication and then you will move to another project and another instrument. In industry many times you begin your career with an instrument and you finish it with him, so reduce time to analyze and report his spectrum is a great advantage. LIS (LIMS) are normally used to organize better data, but indeed sometimes we only need something between these two antipodes, I will show you my workflow using Python and LaTeX for analyzing and reporting Raman spectra in in this post. I begin to deal with spectra when I was a Raman spectroscopist this was a typical spectrum saved as .csv I used to work with:
How my spectra looked like

I needed only the DATA to plot them so I have to avoid other things like parameters and additional informations. I learnt how to create a filter with Origin to skip the first rows but, how can I avoid to import the peaks found by the spectrometer's software? This was a more difficult task for Origin, even the peaks analyzer was a very slow process. Then when I finally insert the image in the Word file I used to found errors and so I had to repeat the whole process! So I begin to develop my own tools to analyze the spectra (found peaks...) and report them directly in TeX. I posted my work in GitHub basically it consists in a general python script to analyze peaks in Raman spectra (positive peaks) and the filter to import spectra form Xantus-1 spectrometer as an example of how everyone can make his own filter to import their own spectra. When you obtain the matplotlib image you can save it but I think that exporting it as LaTeX code is more interesting and lead to many advantages. These are some of the advantages in using the whole methods:
  • Very fast importing methods
  • Print a pice of TeX code that lead to images with publication resolution and all the advantages of LaTeX.
  • If you need you can edit the LaTeX code and so the image directly in a second step.
  • You can add directly into the caption the acquisition parameters for every spectrum, extracting them directly from the spectrum file.
This video shows how it works:

Nessun commento :

Posta un commento