Table Of Contents

Previous topic

nmrglue.process.pipe_proc.ztp

Next topic

nmrglue.helpers

This Page

nmrglue.analysisbase

analysisbase provides general purpose analysis functions and classes used by several nmrglue.analysis modules

This modules is imported as nmrglue.analysisbase and can be called as such.

Low-Level Functions

These functions are typically not used directly by users. They are called by high level functions.

nmrglue.analysis.analysisbase.recnames(dnames, ls_classes, Ms)

Determind the names of a records array provided lineshape classes,

Parameters:

  • dnames List of dimension names.
  • ls_classes List of lineshape classes.
  • Ms List of lineshape lengths.

Returns list of records array names (strings).

nmrglue.analysis.analysisbase.find_limits(pts)

Find the limits which outline the provided list of points

Parameters:

  • pts List of points [(z0,y0,x0),(z1,y1,x1),...]

Returns (min,max):

  • min array of minimum indices array([zmin,ymin,xmin]
  • max array of maximum indices array([zmin,ymin,xmin]
nmrglue.analysis.analysisbase.limits2slice(limits)

Create a set of slice objects given list of min,max limits

Parameters:

  • limits Tuple of minimum and maximum indices

Returns: list of slices which will return points between limits.

nmrglue.analysis.analysisbase.slice2limits(slices)

Create a tuple of min,max limits from a set of slices

Parameters:

  • slices: list of slices

Returns: Tuple of minimum and maximum indices

nmrglue.analysis.analysisbase.squish(r, axis)
Squish array r along axis - sum along all but one axis
nmrglue.analysis.analysisbase.pick2linesh(centers, linewidths, amplitudes)

Convert peakpick.pick output to linesh.fit_NDregion input

Parameters:

  • centers Array of estimated peak locations, shape (n_peaks,ndim).
  • linewidths Array of estimated peak linewidths, shape (n_peaks,ndim).
  • amplitudes Array of estimated peak amplitude, shape (n_peaks).

Return: guesses,amp_guesses

  • guesses P-length list (P is the number of peaks in region) of

    N-length lists of tuples where each each tuple is the optimiztion starting parameters for a given peak and dimension lineshape.

  • amp_guesses P-length list of amplitudes.

nmrglue.analysis.analysisbase.linesh2pick(guesses, amp_guesses)

Convert linesh.fit_NDregion input/output to peakpick.pick output

Parameters:

  • guesses P-length list (P is the number of peaks in region) of

    N-length lists of tuples where each each tuple is the optimiztion starting parameters for a given peak and dimension lineshape.

  • amp_guesses P-length list of amplitudes.

Return: (centers,linewidths,amplitudes)

  • centers Array of estimated peak locations, shape (n_peaks,ndim).
  • linewidths Array of estimated peak linewidths, shape (n_peaks,ndim).
  • amplitudes Array of estimated peak amplitude, shape (n_peaks).
nmrglue.analysis.analysisbase.ls_str2class(l)
Convert lineshape string to lineshape class
nmrglue.analysis.analysisbase.center_fwhm(signal)
Estimate the center and full-width half max of a signal.
nmrglue.analysis.analysisbase.center_fwhm_bymoments(signal)
Estimate the center and full-width half max of a signal using moments

Low-Level Classes

class nmrglue.analysis.analysisbase.gauss1D

Gaussian (normal) lineshape class

Parameters (mu,sigma):

  • mu mean (center of mean)
  • sigma variance (width of distribution)
class nmrglue.analysis.analysisbase.peak1D

Peak lineshape class

This is really a gaussian lineshape which takes a center,fwhm as parameters

class nmrglue.analysis.analysisbase.lorentz1D

Lorentzian lineshape class

Parameters (x0,g):

  • x0 the center of the lorentzian.
  • gamma the scale parameter .
class nmrglue.analysis.analysisbase.scale1D

One dimensional scale class

Simulates a lineshape with functional form:

1.0,a0,a1,a2,....

Where a0, a1, ... are the parameters provided.

class nmrglue.analysis.analysisbase.ndwindow(shape, wsize)

An N-dimentional iterator to slice arrays into windows.

Given the shape of an array and a window size, an ‘ndwindow’ instance iterators over tuples of slices which slice an the array into wsize sub-arrays. At each iteration, the index of the center of the sub-array is incremented by one along the last dimension. Array border are ignored so the resulting sub-array can be smaller than wsize. If wsize contains even values the window is off center containing an additional point with lower index.

Parameters

  • size Size of array to generate tuples of slices from.
  • wsize Size of the area to select from array (sub-array maximum size).

Example:

>>> a = np.arange(12).reshape(3,4)
>>> for s in ndwindow(a.shape,(3,3))
...     print a[s]
[[0 1]
 [4 5]]
[[0 1 2]
 [4 5 6]]
[[1 2 3]
 [5 6 7]]
[[2 3]
 [6 7]]
[[0 1]
 [4 5]
 [8 9]]
[[ 0  1  2]
 [ 4  5  6]
 [ 8  9 10]]
...
class nmrglue.analysis.analysisbase.ndwindow_index(shape, wsize)

An N-dimensional interator object which returns the index of the window center and a ndwindow slice array.

Equivalent to:

for slices,index in zip(np.ndindex(shape),ndwindow(shape,wshape)):
return (index,slice)
class nmrglue.analysis.analysisbase.ndwindow_inside(shape, wsize)

An N-dimentional iterator to slice arrays into uniform size windows.

Given the shape of an array and a window size, an ‘ndwindow_inside’ instance iterators over tuples of slices which slice an the array into uniform size wsize sub-arrays. At each iteration, the index of the top left of the sub-array is incremented by one along the last dimension utill the windows would extend past the array border. All sub-arrays are equal sized (wsize).

Parameters:

  • size Size of array to generate tuples of slices from.
  • wsize Size of the area to select from array (widow size).

Example:

>>> a = np.arange(9).reshape(3,3)
>>> for s in ndwindow_inside(a.shape,(2,2):
...     print a[s]
[[0 1]
 [4 5]]
[[1 2]
 [5 6]]
[[2 3]
 [6 7]]
[[4 5]
 [8 9]]
[[ 5  6]
 [ 9 10]]
[[ 6  7]
 [10 11]]
class nmrglue.analysis.analysisbase.ndwindow_inside_index(shape, wsize)

An N-dimensional interator object which returns the index of the window top-left and a ndwindow_inside slice array.

Similar to ndwindow_index but reports top left index of window.