MSData module
- class MSData.ElementalMap(matrix=None, dx=None, dy=None)
Bases:
object- create_xy()
Create values of x and y axis from dx and dy.
- flip(axis=None)
Flip matrix of image.
- Parameters:
axis (str) – Axis along which to flip over. The default, axis=None,
axes (will flip over all of the) –
vertically (axis=0 flip matrix) –
:param : :param axis=1 flip matrixhorizontally.:
- quantify_map(slope, intercept=0)
Quantify elemental map.
- Parameters:
slope (float) – Slope of linear regression for quantification.
intercept (float) – Intercept of linear regression for quantification.
- read_matrix(path, el)
Import created map from excel, where each isotope is on one list.
- Parameters:
path (str) – Path to excel file.
el (str) – Name of isotope to import.
- rotate()
Rotate map by 90 degrees.
- write_matrix(path, el)
Save created map to excel, where each isotope is on one list.
- Parameters:
path (str) – Path to excel file.
el (str) – Name of isotope to export. Will be used as sheet name.
- class MSData.Isotope(isotope_name, ms_data=None, logger=None)
Bases:
objectExtract specific Isotope data from MSData object.
- Parameters:
isotope_name (str) – Isotope to extract from MSData (i.e. Li7)
ms_data (MSData) – MS data to extract from.
- Returns:
data – data interpreted as an array.
- Return type:
array
- average_intensity(despiked=True, bcgcor_method='all', method='intensity')
Calculate average intensity for peaks in selected Isotope.
- Parameters:
bcgcor_method (str) – Method of background calculation. Possible options are [None, ‘all’, ‘beginning’, ‘end’]. Default is ‘all’.
despiked (bool) – State of data to be corrected. If True use despiked data, else use original. Default is True.
method (str) – Method to get average peaks. Possible options are [‘intensity’, ‘integral’]. Default is ‘intensity’.
- bcg_correction(method='all', despiked=True)
Calculate bacground correction for selected Isotope.
- Parameters:
method (str) – Method of background calculation. Possible options are [‘all’, ‘beginning’, ‘end’]. Default is ‘all’.
despiked (bool) – State of data to be corrected. If True use despiked data, else use original. Default is True.
- despike(win=3, treshold=10)
Removes high outliers of the data using rolling mean and standard deviation. Replace values that are greater than n standard deviations above the mean with the mean adjacent values.
- Parameters:
win (int) – Window for rolling mean.
tresholds (int) – Multiplier of std above which values will be replaced.
- detection_limit(method='intensity', scale='all', ablation_time=60)
Calculate limit of detection for isotope.
- Parameters:
method (str) – Possible methods [‘integral’,’intensity’]. LoD must be calculates same way as average of isotopes.
scale (str) – Possible methods [‘beginning’, ‘all’]. LoD must be calculates same way as average of isotopes.
ablation_time (int) – Time in seconds of one ablation. Necessary only for method ‘integral’.
- element()
Returns name of the element.
- elemental_distribution(despiked=False, bcgcor_method='all', dx=1, dy=1)
Creates ElementalMap from Isotope data.
- Parameters:
despiked (bool (Optional)) – State of data to be corrected. If True use despiked data, false use original. Default is False.
bcgcor_method (str (Optional)) – Method of background calculation. Possible options are [None, ‘all’, ‘beginning’, ‘end’]. Default is ‘all’.
dx (float) – X-axis distance between two values, usually in μm. Can be calculated by (scan speed [μm/s]/ integration time [s])
dy (float) – Y-axis distance between two values, usually in μm. Distance between two lines, usually equal to ablation spot size.)
- quantify(srm_name='NIST610', drift_correction=True)
Calculate quantification of average peaks in Isotope.
- Parameters:
srm_name (str) – Name of the standard reference material to be used for quantification. Must be in SRM file.
- class MSData.MSData(datareader=None, logger=None)
Bases:
objectLA-ICP-MS data structure. Primary object for LA-ICP-MS data reduction with imgMS.
- Parameters:
datareader (MSEval.DataReader) – Object for reading and import of LA-ICP-MS data.
logger (logger class (optional)) – If logger is pssed all methods of MSData will log in the activity.
- IS_correction()
Calculates correction for each element given in internal standard correction from PARAM file.
- Returns:
corrected data – dict of internal standards used for correction as keys and DataFrames where index are peak names and columns are isotopes with values in ppm.
- Return type:
dict
- TS_correction(suma=1000000, skip_isotopes=[], return_oxides=False)
Calculates total sum correction [1] using coefficients given in PARAM file. If coefficients in PARAM file are not given, uses default values. Default values assume all elements are in most common oxide form.
[1] Liu, Y., Hu, Z., Gao, S., Günther, D., Xu, J., Gao, C. and Chen, H., 2008. In situ analysis of major and trace elements of anhydrous minerals by LA-ICP-MS without applying an internal standard. Chemical Geology, 257(1-2), pp.34-43.
- Parameters:
suma (float) – Total sum of measured elements in ppm used for correction. Normally is equal to 100% (default).
skip_isotopes (list) – List of isotopes to be skipped, in total sum correction one element can’t be measured on multiple isotopes.
return_oxides (bool) – If True return data in oxide form as was used for total sum correction. Default is False.
- Returns:
corrected data – DataFrame where index are peak names and columns are isotopes with values in ppm.
- Return type:
DataFrame
- average_isotopes(despiked=True, bcgcor_method='all', method='intensity')
Calculate average value for all peaks for all isotopes.
- Parameters:
bcgcor_method (str) – Method of background calculation. Possible options are [None, ‘all’, ‘beginning’, ‘end’]. Default is ‘all’.
despiked (bool) – If True use despiked data, else use original. Default is True.
method (str) – Method to get average peaks. Possible options are [‘intensity’, ‘integral’]. Default is ‘intensity’.
- Returns:
data – DF where index are peak names and columns are isotopes
- Return type:
DataFrame
- create_isotopes()
- create_maps(despiked=False, bcgcor_method='all', dx=1, dy=1)
Create elemental distribution matrix for all isotopes.
- Parameters:
despiked (bool) – If True use despiked data, else use original. Default is False.
bcgcor_method (str) – Method of background calculation. Possible options are [None, ‘all’, ‘beginning’, ‘end’]. Default is ‘all’.
dx (float) – X-axis distance between two values, usually in μm. Can be calculated by (scan speed [μm/s]/ integration time [s])
dy (float) – Y-axis distance between two values, usually in μm. Distance between two lines, usually equal to ablation spot size.)
- detection_limit(method='intensity', scale='all', ablation_time=60)
Calculate detection limit for all isotopes.
- Parameters:
method (str) – Possible methods [‘integral’,’intensity’]. LoD must be calculates same way as average of isotopes.
scale (str) – Possible methods [‘beginning’, ‘all’]. LoD must be calculates same way as average of isotopes.
ablation_time (int) – Time in seconds of one ablation. Necessary only for method ‘integral’.
- export(path)
Export all data to excel file.
- Parameters:
path (str) – Path to excel file where to save data.
- export_matrices(path, quantified=False)
Export all elemental distribution data to excel file. Each isotope will be a matrix on one sheet.
- Parameters:
path (str) – Path to excel file where to save data.
- formated_export(path, table='quantified')
Export all data to excel file in a formated style, containing means, sd, max and min for repeated samples.
- Parameters:
path (str) – Path to excel file where to save data.
- graph(ax=None, logax=False, el=None, *args, **kwargs)
Create matplotlib graph of intensity in time for ablation and highlights peaks and background signal if the peaks are already identifyied.
- Parameters:
ax (matplotlib axes (optional)) – Axes to plot in, if not specified, create new ax.
logax (bool (optional)) – If True use logarythmic x axes. Default False.
el (str (optional)) – Element to plot. If not specified plot all measured elements.
*args – All other plotting arguments to be passed to matplotlib.pyplot.plot.
**kwargs – All other plotting arguments to be passed to matplotlib.pyplot.plot.
- import_matrices(path)
Import all elemental distribution data from excel file. Each isotope will be a matrix on one sheet.
- Parameters:
path (str) – Path to the excel file.
- quantify_isotopes(srm_name='NIST610', drift_correction=True)
Calculate quantified value for all peaks for all isotopes.
- Parameters:
srm_name (str) – Standard reference material used for quantification. The name must be at least one of the peaks and listed in SRM file.
- Returns:
data – Quantified data in DF where index are peak names and columns are isotopes
- Return type:
DataFrame
- quantify_maps(slopes, intercepts)
Calculate quantification for elemental distribution matrix for all isotopes.
- Parameters:
intercepts (dict) – Dict of intercepts for each isotope.
slopes (dict) – Dict of slopes for each isotope.
- read_param(path)
Import excel file with additional parameters (names of peaks, internal standard values, total sum correction coefficients) for data reduction. A sample PARAM file can be found in data folder.
- Parameters:
path (str) – Path to excel param file.
- read_srms(path='./SRM.xlsx')
Import excel file with standard reference values. Default file is part of the imgMS package and contains values for NIST610, NIST612 and NIST 614.
- Parameters:
path (str) – Path to excel SRM file.
- report()
Clean all data in MSData. Replace values lower than limit of detection. If the value is above LoD, round to specific decimal place.
- select(method='treshold', selector=None, s=60, sdmul=10, iolite=None)
Selects starts and ends of peaks using imgMS.Selector.
- Parameters:
method (str (optional)) – Name of the method to be used for identifying peaks. Possible options are ‘treshold’ and ‘iolite’. Default is ‘treshold’.
selector (MSEval.Selector (optional)) – Class for identifying peaks. If Selector is passed none of the other parameters are necessary. If not, Selector is created by selected settings.
s (float (optional)) – Start of the first peak in seconds from the start of analysis. Default is 60. Necessary if Selector is not passed and used for synchronisation of data with iolite.
sdmul (float (optional)) – Coeficient by which a standard deviation of background is multiplied to calculate treshold. Only used if method = treshold.
iolite (MSEval.Iolite (optional)) – Iolite class holding data from .Iolite file. Necessary if method = Iolite and Selector not passed.
- set_names(names)
Sets list of names of peaks. The name of SRM must be equal to the name in SRM file.
- Parameters:
names (list) – List of names.
- time_to_number(time, integration_time=None)
Takes time in seconds returns number of measured values. The result depends on integration time of MS method.
- Parameters:
time (float) – Time in seconds to be converted into number of values in data.
integration_time (float (optional)) – Integration time of LA-ICP-MS measurement. If not specified will be calculated from data.
- class MSData.Peak(isotope, bounds)
Bases:
objectSeparate one peak of isotope data.
- Parameters:
isotope (MSData.Isotope) – Isotope to use for peak extraction.
bounds (set) – Set of 2 values, start and end of peak.