UniDec
Universal Deconvolution of Mass and Ion Mobility Spectra
Functions | Variables
UniDec.unidec_modules.unidectools Namespace Reference

Functions

def isempty (thing)
 
def string_to_value (s)
 
def simp_string_to_value (s)
 
def string_to_int
 
def safedivide (a, b)
 
def weighted_std (values, weights)
 
def interp_pos (array, target)
 
def interp_val (data, target)
 
def nearestunsorted (array, target)
 
def nearest (array, target)
 
def get_z_offset (mass, charge)
 
def predict_charge (mass)
 
def simchargefit (x2)
 
def get_tvalue
 
def get_zvalue
 
def integrate (data, start, end)
 
def center_of_mass
 
def stepmax (array, index)
 
def localmax (array, start, end)
 
def localmaxpos (data, start, end)
 
def localmax2 (array, index, window)
 
def simple_extract
 
def data_extract (data, x, extract_method, window=None, kwargs)
 
def data_extract_grid
 
def kendrick_analysis
 
def solve_for_mass
 
def header_test (path)
 
def load_mz_file (path, config)
 
def zipdir (path, zip_handle)
 
def zip_folder (save_path)
 
def dataexport (datatop, fname)
 
def mergedata (data1, data2)
 
def mergedata2d (x1, y1, x2, y2, z2)
 
def auto_peak_width (datatop)
 
def auto_noise_level
 
def average_bin_size (datatop)
 
def cal_data
 
def datachop (datatop, newmin, newmax)
 
def datasimpsub (datatop, buff)
 
def datacompsub (datatop, buff)
 
def calc_local_mins (data, w)
 
def polynomial_background_subtract
 
def savgol
 
def savgol_background_subtract
 
def intensitythresh (datatop, thresh)
 
def gsmooth (datatop, sig)
 
def nonlinear_axis (start, end, res)
 
def linear_interpolation (x1, x2, x)
 
def lintegrate (datatop, intx)
 
def linterpolate (datatop, intx)
 
def linearize (datatop, binsize, linflag)
 
def nonlinearize (datatop, num_compressed)
 
def removeduplicates (datatop)
 
def normalize (datatop)
 
def detectoreff (datatop, va)
 
def dataprep (datatop, config)
 
def unidec_call (exepath, configfile, silent=False, kwargs)
 
def peakdetect
 
def mergepeaks (peaks1, peaks2, window)
 
def make_peaks_mztab (mzgrid, pks, adductmass)
 
def makespecfun (i, k, peaks_masses, adductmass, charges, xvals, ftab, xmax, xmin)
 
def make_peaks_mztab_spectrum (mzgrid, pks, data2, mztab)
 
def makeconvspecies (processed_data, pks, config)
 
def nonlinstickconv (xvals, mztab, fwhm, psfun)
 
def stickconv (mztab, kernel)
 
def make_alpha_cmap (rgb_tuple, alpha)
 
def color_map_array (array, cmap, alpha)
 
def lengths (array)
 
def combine (array2)
 
def combine_all (array2)
 
def make_isolated_match (oligos)
 
def make_all_matches (oligos)
 
def match
 
def ndis_std
 
def ndis (x, mid, fwhm, kwargs)
 
def ndis_fit (x, s, m, a, b)
 
def ldis
 
def ldis_fit (x, s, m, a, b)
 
def splitdis
 
def splitdis_fit (x, s, m, a, b)
 
def voigt
 
def cconv (a, b)
 
def single_cwt
 
def continuous_wavelet_transform
 
def autocorr
 
def cconvolve (xvals, mztab, fwhm, psfun)
 
def conv_peak_shape_kernel (xaxis, psfun, fwhm)
 
def make_peak_shape
 
def gaussfit
 
def psfit (x, s, m, a, b, psfun)
 
def voigt_fit
 
def fit_peak (xvals, yvals, psfun, midguess, fwhmguess, aguess, bguess)
 
def isolated_peak_fit (xvals, yvals, psfun, kwargs)
 
def fft (data)
 
def fft_diff (data, diffrange=[500.)
 
def pad_data
 
def pad_two_power (data)
 
def double_fft_diff
 
def windowed_fft
 
def win_fft_grid (rawdata, binsize, wbin, window_fwhm, diffrange)
 
def win_fft_diff
 
def correlation_integration (dat1, dat2, alpha=0.01, plot_corr=False, kwargs)
 
def wide_sse (dat1, dat2, sig)
 
def broaden (aligned)
 

Variables

int is_64bits = sys.maxsize>2
 
string dllname = "libmypfunc"
 
 testpath = dllname
 
 dllpath = testpath
 
tuple pathtofile = os.path.dirname(os.path.abspath(__file__))
 
tuple libs = cdll.LoadLibrary(dllpath)
 

Function Documentation

def UniDec.unidec_modules.unidectools.auto_noise_level (   datatop,
  buffer = 10 
)
def UniDec.unidec_modules.unidectools.auto_peak_width (   datatop)

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.autocorr (   datatop,
  config = None 
)

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.average_bin_size (   datatop)
def UniDec.unidec_modules.unidectools.broaden (   aligned)
Take a list of aligned peaks and broaden each so that they achieve maximum overlap with the broadest one.
:param aligned: Array (N x M x 2). N is the number of peaks, M is the number of data points, 2 is (x,y)
:return: combined, aligned: The combined total of all the aligned and broaded individual peaks.

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.cal_data (   datatop,
  poly_coeff = None 
)
def UniDec.unidec_modules.unidectools.calc_local_mins (   data,
  w 
)

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.cconv (   a,
  b 
)
Circular convolution of two lists
:param a: N-length array
:param b: N-length array
:return: Convolution

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.cconvolve (   xvals,
  mztab,
  fwhm,
  psfun 
)
Fast nonlinear convolution algorithm using C dll.
:param xvals: x-axis
:param mztab: mztab from make_peaks_mztab()
:param fwhm: Full width half max of peak
:param psfun: Peak shape function code (0=Gauss, 1=Lorentzian, 2=Split G/L)
:return: Convolved output

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.center_of_mass (   data,
  start = None,
  end = None 
)

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.color_map_array (   array,
  cmap,
  alpha 
)
For a specified array of values, map the intensity to a specified RGB color defined by cmap (output as topcm).
For each color, create a color map where the color is constant but the transparency changes (output as cmarr).
:param array: Values
:param cmap: Color map
:param alpha: Max Alpha value (transparency) [0,1]
:return: cmarr, topcm (list of transparent color maps, list of RGB colors for array values)

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.combine (   array2)

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.combine_all (   array2)

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.continuous_wavelet_transform (   a,
  widths,
  wavelet_type = "Ricker" 
)
Perform a continuous wavelet transform at multiple widths.
:param a: 1D numpy array of data (length N)
:param widths: List of widths (length W) of transform defined with respect to the data points in a
:param wavelet_type: Type of wavelet. Either "Ricker" (Mexican Hat) or "Morlet" (Gabor)
:return: cwt_matrix (The continuous wavelet transform at the defined widths in a (W x N) array)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.conv_peak_shape_kernel (   xaxis,
  psfun,
  fwhm 
)
Creation of an efficient peak shape kernel for circular convolutions.

Note: peak width must be in units of index not value of x-axis. To get this take fwhm/binsize.
:param xaxis: Array of x axis values
:param psfun: Integer

0=Gaussian
1=Lorentzian
2=Split Gaussian/Lorentzian

:param fwhm: Full width half max of peak (in units matching data indexes not values)
:return: Peak shape kernel centered at 0.

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.correlation_integration (   dat1,
  dat2,
  alpha = 0.01,
  plot_corr = False,
  kwargs 
)
Perform MacCoss method (http://pubs.acs.org/doi/pdf/10.1021/ac034790h) of getting peak intensities
:param dat1: Denominator peak
:param dat2: Numerator peak
:param alpha: 1-confidence level
:param plot_corr: Boolean flag, if True, will plot the results
:param kwargs: keywords (unused dump)
:return: slope, cierr, rsquared, slope_std_error * np.sqrt(n), pvalue
slope of line (ratio of peak areas)
cierr (confidence interval for error)
rsquared (R squared value for linear fit)
slope_std_error * np.sqrt(n) (standard deviation of slope fit)
pvalue (probability that slope is nonzero)
def UniDec.unidec_modules.unidectools.data_extract (   data,
  x,
  extract_method,
  window = None,
  kwargs 
)
Assumes a sorted array in data[:,0]
:param data:
:param x:
:param extract_method:
:param window:
:return:

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.data_extract_grid (   data,
  xarray,
  extract_method = 1,
  window = 0 
)

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.datachop (   datatop,
  newmin,
  newmax 
)
Chops the range of the data. The [:,0] column of the data is the column that will be indexed.
:param datatop: Data array
:param newmin: Minimum value of chopped data
:param newmax: Maximum value of chopped data
:return: New data limited between the two bounds

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.datacompsub (   datatop,
  buff 
)
Complex background subtraction.

Taken from Massign Paper

First creates an array that matches the data but has the minimum value within a window of +/- buff.
Then, smooths the minimum array with a Gaussian filter of width buff * 2 to form the background array.
Finally, subtracts the background array from the data intensities.

:param datatop: Data array
:param buff: Width parameter
:return: Subtracted data

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.dataexport (   datatop,
  fname 
)
def UniDec.unidec_modules.unidectools.dataprep (   datatop,
  config 
)
Main function to process 1D MS data. The order is:

Crop Data (datacrop)
Correct for detector efficiency (detectoreff)
Smooth (gsmooth)
Remove duplicates (removeduplicates)
Linearize (linearize or nonlinearize)
Baseline subtraction (datasimpsub or datacompsub or simply data[:,1]-np.amin(data[:,1])
Normalization (normalize)
Intensity Threshold with a threshold of 0 (intthresh)

:param datatop: Raw data array (N x 2)
:param config: UniDecConfig object
:return: Processed data

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.datasimpsub (   datatop,
  buff 
)
Simple subtraction of a linear background.

The first n and last n data points are averaged. A line is drawn between the two averages.
This line is then subtracted from the [:,1] column of the data.
:param datatop: Data array (N x 2) (m/z, intensity)
:param buff: Integer, n.
:return: Subtracted data

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.detectoreff (   datatop,
  va 
)
Incorporate a model of TOF detector efficiency used by CHAMP to correct the intensity values.
:param datatop: Data array (N x 2)
:param va: TOF acceleration voltage in kV (I think...)
:return: Detector corrected data (N x 2)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.double_fft_diff (   mzdata,
  diffrange = None,
  binsize = 0.1,
  pad = None,
  preprocessed = False 
)

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.fft (   data)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.fft_diff (   data,
  diffrange = [500. 
)

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.fit_peak (   xvals,
  yvals,
  psfun,
  midguess,
  fwhmguess,
  aguess,
  bguess 
)
Fit peak from xvals and yvals data to defined peak shape function.
:param xvals: x values of data
:param yvals: y values of data
:param psfun: peak shape function integer code
:param midguess: midpoint guess
:param fwhmguess: fwhm guess
:param aguess: amplitude guess
:param bguess: background guess
:return: popt, perr, fitdat (optimized parameters [fwhm, mid, a, b], std error of parameters, fit to data)

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.gaussfit (   xvals,
  yvals,
  mguess = None,
  sguess = 0.1,
  aguess = None,
  cleanup = True 
)
Simple gaussian fitting function.
:param xvals: X values
:param yvals: Y values
:param mguess: Guess for midpoint
:param sguess: Guess for standard deviation
:param aguess: Guess for amplitude
:param cleanup: Boolean Flag, if True, will clean up data to remove background and normalize
:return: Gaussian fit parameters [mid, sig, amp]
def UniDec.unidec_modules.unidectools.get_tvalue (   dof,
  ci = 0.99 
)
Get t-value for a given degrees of freedom and confidence interval
:param dof: Degrees of freedom
:param ci: Confidence interval level (default is 0.99, 99% confidence)
:return: T value
def UniDec.unidec_modules.unidectools.get_z_offset (   mass,
  charge 
)
For a given mass and charge combination, calculate the charge offset parameter.
:param mass: Mass in Da
:param charge: Charge State
:return: Difference between charge and predicted native charge of the mass

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.get_zvalue (   ci = 0.99)
Get z-value for area under a Gaussian for a given confidence level
:param ci: Confidence interval level (default is 0.99, 99% confidence)
:return: Z-value
def UniDec.unidec_modules.unidectools.gsmooth (   datatop,
  sig 
)
Smooths the data with a Gaussian filter of width sig.
:param datatop: Data array
:param sig: Width of Gaussian Array
:return: Smoothed Data

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.header_test (   path)
A quick test of a file to remove any problems from the header.

If scans through each line of an input file specificed by path and count the number of lines that cannot be
completely converted to floats. It breaks the loop on the first hit that is entirely floats, so any header lines
blow that will not be counted.
:param path: Path of file to be scanned
:return: Integer length of the number of header lines

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.integrate (   data,
  start,
  end 
)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.intensitythresh (   datatop,
  thresh 
)
Sets an intensity threshold. Everything below the threshold is set to 0.
:param datatop: Data array
:param thresh: Threshold value
:return: Thresholded array.

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.interp_pos (   array,
  target 
)
On a given array, interpolate the position of the target
:param array: Array
:param target: Value
:return: Interpolated index of value in array.
def UniDec.unidec_modules.unidectools.interp_val (   data,
  target 
)
On a given array, interpolate the value of the target
:param array: data
:param target: Value
:return: Interpolated index of value in array.
def UniDec.unidec_modules.unidectools.isempty (   thing)
Checks wether the thing, a list or array, is empty
:param thing: Object to check
:return: Boolean, True if not empty
def UniDec.unidec_modules.unidectools.isolated_peak_fit (   xvals,
  yvals,
  psfun,
  kwargs 
)
Fit an isolated peak to the peak shape model.
:param xvals: x values of data
:param yvals: y values of data
:param psfun: peak shape function integer code
:param kwargs: keywords (unused)
:return: fit_array, fit_data (4 x 2 array of (fit, error) for [fwhm,mid,amp,background],fit to data)

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.kendrick_analysis (   massdat,
  kendrickmass,
  centermode = 1,
  nbins = 50,
  transformmode = 1,
  xaxistype = 1 
)

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.ldis (   x,
  mid,
  fwhm,
  a = 1,
  norm_area = False 
)
Lorentzian function normalized to a max of 1.
Note: x and mid are interchangable. At least one should be a single float. The other may be an array.
:param x: x values
:param mid: Mean
:param fwhm: Full Width at Half Max
:param a: Amplitude (default is 1)
:param norm_area: Boolean, Whether to normalize so that the area under the distribution is 1.
:return: Lorentzian distribution at x values

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.ldis_fit (   x,
  s,
  m,
  a,
  b 
)
Function for fitting Lorentzian distribution to peak.
Adds a background to ldis.
Prevents negative background, amplitude, and standard deviation.
:param x: x value
:param s: full width half max
:param m: mean
:param a: amplitude
:param b: linear background
:return: peak shape

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.lengths (   array)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.linear_interpolation (   x1,
  x2,
  x 
)
:param x1:
:param x2:
:param x:
:return: float(x - x1) / float(x2 - x1)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.linearize (   datatop,
  binsize,
  linflag 
)
Linearize data by defined x-axis bin size by either interpolation or integration
:param datatop: Data array (N x 2)
:param binsize: Spacing between first two m/z points
:param linflag: Integer flag indicating the type of linearization.

0=Integration with Linear Axis (constant m/z)
1=Integration with Nonlinear Axis (constant resolution: mz / delta mz)

3=Interpolation with Linear Axis
4=Interpolation with Nonlinear Axis

:return: Linearized data

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.lintegrate (   datatop,
  intx 
)
Linearize x-axis by integration.

Each intensity value in the old data gets proportionally added into the new x-axis.

The total sum of the intensity values should be constant.
:param datatop: Data array
:param intx: New x-axis for data
:return: Integration of intensity from original data onto the new x-axis.
    Same shape as the old data but new length.

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.linterpolate (   datatop,
  intx 
)
Linearize x-axis by interpolation.

The new x-axis is interpolated on the old data and the corresponding intensities and picked out.

:param datatop: Data array
:param intx: New x-axis
:return: Interpolation of intensity from original data onto the new x-axis.
    Same shape as the old data but new length.

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.load_mz_file (   path,
  config 
)
Loads a text or mzml file
:param path: File path to load
:param config: UniDecConfig object
:return: Data array

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.localmax (   array,
  start,
  end 
)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.localmax2 (   array,
  index,
  window 
)

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.localmaxpos (   data,
  start,
  end 
)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.make_all_matches (   oligos)

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.make_alpha_cmap (   rgb_tuple,
  alpha 
)
Make color map where RGB specified in tup
:param rgb_tuple: Tuple of RGB vaalues [0,1]
:param alpha: Maximum Alpha (Transparency) [0,1]
:return: Color map dictionary with a constant color but varying transprency

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.make_isolated_match (   oligos)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.make_peak_shape (   xaxis,
  psfun,
  fwhm,
  mid,
  norm_area = False 
)
Make a peak of width fwhm centered at mid for given x axis.

Note: peak width must be in units of index not value of x-axis. To get this take fwhm/binsize.
:param xaxis: Array of x axis values
:param psfun: Integer

0=Gaussian
1=Lorentzian
2=Split Gaussian/Lorentzian

:param fwhm: Full width half max of peak (in units matching data indexes not values)
:param mid: Midpoint of peak
:return: Peak shape centered at midpoint .

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.make_peaks_mztab (   mzgrid,
  pks,
  adductmass 
)
For each peak in pks, get the charge state distribution.

The intensity at each charge state is determined from mzgrid and stored in a list as peak.mztab.
An array of the results is also output for help speeding up make_peaks_mztab_spectrum

:param mzgrid: 2D grid of m/z vs charge (N x Z)
:param pks: Peaks object (length P)
:param adductmass: Mass of electrospray adduct.
:return: P x Z array

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.make_peaks_mztab_spectrum (   mzgrid,
  pks,
  data2,
  mztab 
)
Used for plotting the dots in plot 4.

Perform the same things as make_peaks_mztab, but instead of using the deconvolved intensities,
it takes the intensity directly from the spectrum.
:param mzgrid: m/z grid (N x Z)
:param pks: Peaks object
:param data2: Processed data 1D
:param mztab: Prior mztab from make_peaks_mztab
:return: mztab but with intensities replaced by value at the spectrum.
def UniDec.unidec_modules.unidectools.makeconvspecies (   processed_data,
  pks,
  config 
)
For data and peaks, create a simulated spectrum of each peak.
Assumes p.mztab has been set for each p in pks.peaks by make_peaks_mztab
Also makes pks.composite, which is a sum of all the simulated spectra.
:param processed_data: Processed 2D MS data (data2, N x 2)
:param pks: Peaks object (P Peak objects in pks.peaks)
:param config: UniDecConfig object
:return: Array of simulated spectra (P x N)

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.makespecfun (   i,
  k,
  peaks_masses,
  adductmass,
  charges,
  xvals,
  ftab,
  xmax,
  xmin 
)
Small helper function to speed things up. May be more better way to do this, but I found this to be fastest.
:param i: peak mass index
:param k: charge index
:param peaks_masses: peak masses list
:param adductmass: Adduct mass
:param charges: charge list
:param xvals: x-values from data
:param ftab: List of interpolation functions
:param xmax: Maximum x value
:param xmin: Minimum x value
:return:

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.match (   pks,
  oligomasslist,
  oligonames,
  tolerance = None 
)

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.mergedata (   data1,
  data2 
)
Uses a 1D intepolation to merge the intensity of data2 into the axis of data1
:param data1: Reference data (N x 2 array)
:param data2: Data to merge (M x 2 array)
:return: data2 interpolated into the same axis as data1 (N x 2)
def UniDec.unidec_modules.unidectools.mergedata2d (   x1,
  y1,
  x2,
  y2,
  z2 
)
Uses a 2D interpolation to merge a 2D grid of data from one set of axes to another.

Requires rectangular grids of all inputs such as might be created by numpy.meshgrid.
:param x1: Reference x-value grid (N x M)
:param y1: Reference y-value grid (N x M)
:param x2: Data x-value grid (N2 x M2)
:param y2: Data y-value grid (N2 x M2)
:param z2: Data intensity grdi (N2 x M2)
:return: z2 interpolated onto x1 y1 2D grid (N x M)
def UniDec.unidec_modules.unidectools.mergepeaks (   peaks1,
  peaks2,
  window 
)
Merge a test list of peaks to a reference list.

Each peak in peaks2 is matched to the closest peak in peak1.
If it within some defined threshold, the new peak replaces that closes peak in the matched list.
If no new peaks are matched to a reference peak, that peaks mass is unchanged but intensity is set to 0.

:param peaks1: Reference peaks (P x 2)
:param peaks2: Test peaks (R x 2)
:param window: Tolerance window of the x values
:return: Intensity of peaks2 matched to values of peaks1 (P x 2)
def UniDec.unidec_modules.unidectools.ndis (   x,
  mid,
  fwhm,
  kwargs 
)
Gaussian function normalized to a max of 1.

Note: x and mid are interchangable. At least one should be a single float. The other may be an array.
:param x: x values
:param mid: Mean
:param fwhm: Full Width at Half Max (2.35482 * standard deviation)
:param kwargs: Allows norm_area flag to be passed
:return: Gaussian distribution at x values

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.ndis_fit (   x,
  s,
  m,
  a,
  b 
)
Function for fitting normal distribution to peak.
Adds a background to ndis.
Prevents negative background, amplitude, and standard deviation.
:param x: x value
:param s: full width half max
:param m: mean
:param a: amplitude
:param b: linear background
:return: peak shape

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.ndis_std (   x,
  mid,
  sig,
  a = 1,
  norm_area = False 
)
Normal Gaussian function normalized to the max of 1.
:param x: x values
:param mid: Mean of Gaussian
:param sig: Standard Deviation
:param a: Maximum amplitude (default is 1)
:param norm_area: Boolean, Whether to normalize so that the area under the distribution is 1.
:return: Gaussian distribution at x values

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.nearest (   array,
  target 
)
In an sorted array, quickly find the position of the element closest to the target.
:param array: Array
:param target: Value
:return: np.argmin(np.abs(array - target))

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.nearestunsorted (   array,
  target 
)
In an unsorted array, find the position of the element closest to the target.

For a sorted array, the method nearest will be faster.
:param array: Array
:param target: Value
:return: np.argmin(np.abs(array - target))

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.nonlinear_axis (   start,
  end,
  res 
)
Creates a nonlinear axis with the m/z values spaced with a defined and constant resolution.
:param start: Minimum m/z value
:param end: Maximum m/z value
:param res: Resolution of the axis ( m / delta m)
:return: One dimensional array of the nonlinear axis.

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.nonlinearize (   datatop,
  num_compressed 
)
Compress the data in a simple and nonlinear way.
:param datatop: Data array (N x 2)
:param num_compressed:
:return:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.nonlinstickconv (   xvals,
  mztab,
  fwhm,
  psfun 
)
Python-based Nonlinear convolution. First makes a stick spectrum. Then, convolved with peak shape kernel.
:param xvals: x-axis
:param mztab: mztab from make_peaks_mztab
:param fwhm: Full width half max
:param psfun: Peak shape function integer
:return: Convolved output

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.normalize (   datatop)
Normalize the data so that the maximum intensity is 1.

maxval = np.amax(datatop[:, 1])
datatop[:, 1] = datatop[:, 1] / maxval

:param datatop: Data array (N x 2)
:return: Normalized data array (N x 2)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.pad_data (   linear_mzdata,
  pad_until = 50000 
)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.pad_two_power (   data)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.peakdetect (   data,
  config = None,
  window = 10,
  threshold = 0 
)
Simple peak detection algorithm.

Detects a peak if a given data point is a local maximum within plus or minus config.peakwindow.
Peaks must also be above a threshold of config.peakthresh * max_data_intensity.

The mass and intensity of peaks meeting these criteria are output as a P x 2 array.

:param data: Mass data array (N x 2) (mass intensity)
:param config: UniDecConfig object
:return: Array of peaks positions and intensities (P x 2) (mass intensity)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.polynomial_background_subtract (   datatop,
  polynomial_order = 4,
  width = 20,
  cutoff_percent = 0.25 
)

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.predict_charge (   mass)
Give predicted native charge state of species of defined mass
:param mass: Mass in Da
:return: Float, predicted average native charge state

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.psfit (   x,
  s,
  m,
  a,
  b,
  psfun 
)
Make peak shape from fit
:param x: x values
:param s: fwhm
:param m: max position
:param a: amplitude
:param b: background
:param psfun: peak shape function integer code
:return: peak shape fit data

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.removeduplicates (   datatop)
Cleans up data that may have the same x value multiple times.
Each nonunique x gets merged into a single unique x with the sum of all of the nonunique intensities.
:param datatop: Data array (N x 2)
:return: Data with unique x values

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.safedivide (   a,
  b 
)
Divide numpy arrays b from a. Define a/0=0 to avoid zero division error.
:param a: Numerator
:param b: Denominator
:return: a/b
def UniDec.unidec_modules.unidectools.savgol (   ydata,
  window = None,
  order = 2 
)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.savgol_background_subtract (   datatop,
  width,
  cutoff_percent = 0.25 
)

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.simchargefit (   x2)

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.simp_string_to_value (   s)
Try to convert string to float. Raise False if not possible.
:param s: String
:return: Float if possible. Otherwise, False

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.simple_extract (   data,
  x,
  zero_edge = True 
)

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.single_cwt (   a,
  width,
  wavelet_type = "Ricker" 
)
Perform a continuous wavelet transform at a single defined width.
:param a: 1D numpy array of data (length N)
:param width: Width of transform defined with respect to the data points in a
:param wavelet_type: Type of wavelet. Either "Ricker" (Mexican Hat) or "Morlet" (Gabor)
:return: cwt, wavelet
Continous wavelet transform and wavelet of choice, both as numpy arrays of length N.

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.solve_for_mass (   mz1,
  mz2,
  adductmass = 1.007276467 
)
Simple function to solve for mass from two adjacent charge state peaks in m/z.
:param mz1: Smaller m/z value (charge = z1)
:param mz2: Larger m/z value (charge = z2 = z1 + 1)
:param adductmass: Mass of electrospray adduct (default = Hydrogen)
:return: mass, z1, z2
def UniDec.unidec_modules.unidectools.splitdis (   x,
  mid,
  fwhm,
  a = 1,
  norm_area = False 
)
Split Gaussain/Lorentzian function normalized to a max of 1.

Gaussian < mid. Lorentzian > mid.

:param mid: Mid point (point of peak intensity)
:param x: x value or values
:param fwhm: Full Width at Half Max
:return: Split Gaussian/Lorentzian distribution at x value

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.splitdis_fit (   x,
  s,
  m,
  a,
  b 
)
Function for fitting Split G/L distribution to peak.
Adds a background to splitdis.
Prevents negative background, amplitude, and standard deviation.
:param x: x value
:param s: full width half max
:param m: mean
:param a: amplitude
:param b: linear background
:return: peak shape

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.stepmax (   array,
  index 
)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.stickconv (   mztab,
  kernel 
)
Make stick spectrum and then convolves with kernel.
:param mztab: mztab from make_peaks_mztab
:param kernel: peak shape kernel
:return: Convolved output

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.string_to_int (   s,
  default = False 
)
Try to convert string to integer.
:param s: String
:return: Integer if possible. Otherwise, False
def UniDec.unidec_modules.unidectools.string_to_value (   s)
Try to convert string to float.
:param s: String
:return: Float if possible. Otherwise, empty string.
def UniDec.unidec_modules.unidectools.unidec_call (   exepath,
  configfile,
  silent = False,
  kwargs 
)
Run the UniDec binary specified by exepath with the configuration file specified by configfile.
If silent is False (default), the output from exepath will be printed to the standard out.
If silent is True, the output is suppressed.

The binary is run as a commandline subprocess with a call of (for example):

UniDec.exe conf.dat

:param exepath: Path to UniDec or UniDecIM binary
:param configfile: Path to configuration file
:param silent: Whether to print the output of exepath to the standard out
:param kwargs:
:return: Standard error of exepath execution
def UniDec.unidec_modules.unidectools.voigt (   x,
  mu = 0,
  sigma = 1,
  gamma = 1,
  amp = 1,
  background = 0 
)
\
voigt profile

V(x,sig,gam) = Re(w(z))/(sig*sqrt(2*pi))
z = (x+i*gam)/(sig*sqrt(2))

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.voigt_fit (   xvals,
  yvals,
  mguess = 0,
  sguess = 0.1,
  gguess = 0,
  aguess = 0,
  bguess = 0 
)
 

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.weighted_std (   values,
  weights 
)
Calculate weighted standard deviation.
:param values: Values
:param weights: Weights
:return: Weighted standard deviation.

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.wide_sse (   dat1,
  dat2,
  sig 
)
Tests the sum of squared errors between two sets of data where the second has been convolved with a Gaussian
:param dat1: Reference list of intensities.
:param dat2: Test spectrum list of intensities to broaden.
:param sig: Sigma for Gaussian filter
:return: SSE between dat1 and broadedned dat1 (float)

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.win_fft_diff (   rawdata,
  binsize = 0.05,
  sigma = 1000,
  diffrange = None 
)

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.win_fft_grid (   rawdata,
  binsize,
  wbin,
  window_fwhm,
  diffrange 
)

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.windowed_fft (   data,
  mean,
  sigma,
  diffrange = None 
)

Here is the call graph for this function:

Here is the caller graph for this function:

def UniDec.unidec_modules.unidectools.zip_folder (   save_path)
Zips a directory specified by save_path into a zip file for saving.
:param save_path: Path to save to zip
:return: None

Here is the call graph for this function:

def UniDec.unidec_modules.unidectools.zipdir (   path,
  zip_handle 
)
Zips all the files in the path into the zip_handle
:param path: Directory path
:param zip_handle: Handle of the zip file that is being created
:return: None

Here is the caller graph for this function:

Variable Documentation

string UniDec.unidec_modules.unidectools.dllname = "libmypfunc"
UniDec.unidec_modules.unidectools.dllpath = testpath
int UniDec.unidec_modules.unidectools.is_64bits = sys.maxsize>2
tuple UniDec.unidec_modules.unidectools.libs = cdll.LoadLibrary(dllpath)
tuple UniDec.unidec_modules.unidectools.pathtofile = os.path.dirname(os.path.abspath(__file__))
tuple UniDec.unidec_modules.unidectools.testpath = dllname