#NEWLINE# def find_bright_peaks( self , data , threshold = None , sigma = 5 , radius = 5 ) : #NEWLINE# #INDENT# '\n        Find bright peak candidates in (data).  (threshold) specifies a\n        threshold value below which an object is not considered a candidate.\n        If threshold is blank, a default is calculated using (sigma).\n        (radius) defines a pixel radius for determining local maxima--if the\n        desired objects are larger in size, specify a larger radius.\n\n        The routine returns a list of candidate object coordinate tuples\n        (x, y) in data.\n        ' #NEWLINE# if ( threshold is None ) : #NEWLINE# #INDENT# threshold = self . get_threshold ( data , sigma = sigma ) #NEWLINE# self . logger . debug ( ( 'threshold defaults to %f (sigma=%f)' % ( threshold , sigma ) ) ) #NEWLINE# #UNINDENT# data_max = filters . maximum_filter ( data , radius ) #NEWLINE# maxima = ( data == data_max ) #NEWLINE# diff = ( data_max > threshold ) #NEWLINE# maxima [ ( diff == 0 ) ] = 0 #NEWLINE# ( labeled , num_objects ) = ndimage . label ( maxima ) #NEWLINE# slices = ndimage . find_objects ( labeled ) #NEWLINE# peaks = [ ] #NEWLINE# for ( dy , dx ) in slices : #NEWLINE# #INDENT# xc = ( ( ( dx . start + dx . stop ) - 1 ) / 2.0 ) #NEWLINE# yc = ( ( ( dy . start + dy . stop ) - 1 ) / 2.0 ) #NEWLINE# peaks . append ( ( xc , yc ) ) #NEWLINE# #UNINDENT# return peaks