Ejemplo n.º 1
0
def find_all_thres(data,thres,msep,find_segs=False):
    """
    Peak pick a spectrum using a threshhold-minimum distance algorithm.
    
    Find peaks (local maxima) in a arbitrary dimensional NMR spectra above a 
    set threshold with a minimal distance between peaks.  When the spectrum is 
    small and multiple copies can fit into RAM use the _fast version of this 
    function. Segments are found by finding the first point in each direction
    along each dimension which is below the threshold.

    Parameters:

    * data      N-dimensional array.
    * thres     Threshold value for minimum peak height
    * msep      N-tuple of minimum peak seperations along each axis
    * find_segs True or False to return a list of slices for the segments.


    Returns: locations,seg_slices
    
    * locations     List of indicies of peak locations
    * seg_slices    List of slices which extract a region around each peak. 

    """
    locations = []  # create an empty list of peak locations
    wsize = tuple([2*i+1 for i in msep])    #window size is 2*seperation+1

    # loop over the windows
    for idx,s in ndwindow_index(data.shape,wsize):
        max = data[s].max()
        if max == data[idx] and max > thres:
            locations.append(idx)

    if find_segs:
        seg_slices = find_pseg_slices(data,locations,thres)
        return locations,seg_slices
    else:
        return locations
Ejemplo n.º 2
0
def find_all_nthres(data,thres,msep,find_segs=False):
    """
    Peak pick a spectrum using a threshhold-minimum distance algorithm.
    
    Identical to find_all_thres except local minima are found below the
    given threshold.  See find_all_thres for a description of the algorithm and
    parameters.

    """
    locations = []  # create an empty list of peak locations
    wsize = tuple([2*i+1 for i in msep])    #window size is 2*seperation+1

    # loop over the windows
    for idx,s in ndwindow_index(data.shape,wsize):
        min = data[s].min()
        if min == data[idx] and min < thres:
            locations.append(idx)

    if find_segs:
        seg_slices = find_pseg_slices(data,locations,thres)
        return locations,seg_slices
    else:
        return locations