X-Git-Url: http://git.tremily.us/?p=hooke.git;a=blobdiff_plain;f=hooke%2Fplugin%2Fflatfilts.py;h=e19964c71a2dfd01c8f710916402a16e35a024a2;hp=47eab591e46db9b4ef819637a26b85ac108c4386;hb=41ef0130e16c0cf8d2c0f1acc9e06986d62f7607;hpb=cd7b8ff4687547d3661c23180d7145d4ccc898ae diff --git a/hooke/plugin/flatfilts.py b/hooke/plugin/flatfilts.py index 47eab59..e19964c 100644 --- a/hooke/plugin/flatfilts.py +++ b/hooke/plugin/flatfilts.py @@ -1,3 +1,6 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + ''' FLATFILTS @@ -136,8 +139,8 @@ class flatfiltsCommands(object): #-----CONVFILT------------------------------------------------- #-----Convolution-based peak recognition and filtering. #Requires the libpeakspot.py library - - def has_peaks(self, plot, abs_devs=None): + + def has_peaks(self, plot, abs_devs=None, maxpeak=True, window=10): ''' Finds peak position in a force curve. FIXME: should be moved in libpeakspot.py @@ -165,14 +168,26 @@ class flatfiltsCommands(object): noise_level=lps.noise_absdev(convoluted[cut_index:], self.convfilt_config['positive'], self.convfilt_config['maxcut'], self.convfilt_config['stable']) above=lps.abovenoise(convoluted,noise_level,cut_index,abs_devs) peak_location,peak_size=lps.find_peaks(above,seedouble=self.convfilt_config['seedouble']) - - #take the maximum + + #take the minimum or the maximum of a peak for i in range(len(peak_location)): peak=peak_location[i] - maxpk=min(yret[peak-10:peak+10]) - index_maxpk=yret[peak-10:peak+10].index(maxpk)+(peak-10) - peak_location[i]=index_maxpk - + valpk=min(yret[peak-window:peak+window]) #maximum in force (near the unfolding point) + index_pk=yret[peak-window:peak+window].index(valpk)+(peak-window) + + if maxpeak==False: + valpk=max(yret[peak:peak+window]) #minimum in force, near the baseline + index_pk=yret[peak:peak+window].index(valpk)+(peak) + +# Let's explain that for the minimum. Immaging that we know that there is a peak at position/region 100 and you have found its y-value, +# Now you look in the array, from 100-10 to 100+10 (if the window is 10). +# This "100-10 to 100+10" is substancially a new array with its index. In this array you have 20 +# elements, so the index of your y-value will be 10. +# Now to find the index in the TOTAL array you have to add the "position" of the "region" (that in this case +# correspond to 100) and also substract the window size ---> (+100-10) + + peak_location[i]=index_pk + return peak_location,peak_size @@ -310,6 +325,9 @@ class flatfiltsCommands(object): item.curve=None #empty the item object, to further avoid memory leak notflat_list.append(item) + for i in range(1000): + k=0 + #Warn that no flattening had been done. if not ('flatten' in self.config['plotmanips']): print 'Flatten manipulator was not found. Processing was done without flattening.'