(autopeak.py) automatically discards spurious peaks with nonsense persistence lengths
authordevicerandom <devnull@localhost>
Mon, 27 Oct 2008 16:48:24 +0000 (16:48 +0000)
committerdevicerandom <devnull@localhost>
Mon, 27 Oct 2008 16:48:24 +0000 (16:48 +0000)
autopeak.py
generalvclamp.py
hooke.conf

index 44c8a6003845d8aebcddbe7d14bd25f71a61c6f8..795189d3aa9d59f8854b2dba9b0b04fbacae4064 100644 (file)
@@ -173,12 +173,6 @@ class autopeakCommands:
             #Automatically find contact point
             cindex=self.find_contact_point()
             contact_point=self._clickize(displayed_plot.vectors[1][0], displayed_plot.vectors[1][1], cindex)
-            '''
-            contact_point=ClickedPoint()
-            contact_point.absolute_coords=displayed_plot.vectors[1][0][cindex], displayed_plot.vectors[1][1][cindex]
-            contact_point.find_graph_coords(displayed_plot.vectors[1][0], displayed_plot.vectors[1][1])
-            contact_point.is_marker=True
-            '''
         #--END COMMAND LINE PARSING--
         
         
@@ -228,37 +222,55 @@ class autopeakCommands:
             
             params, yfit, xfit = self.wlc_fit(points, displayed_plot.vectors[1][0], displayed_plot.vectors[1][1], pl_value, T)
             
-            #save wlc values (nm)
-            c_lengths.append(params[0]*(1.0e+9))
-            if len(params)==2: #if we did choose 2-value fit
-                p_lengths.append(params[1]*(1.0e+9))
-            else:
-                p_lengths.append(pl_value)
-            #Add WLC fit lines to plot
-            fitplot.add_set(xfit,yfit)
-            
-            if len(fitplot.styles)==0:
-                fitplot.styles=[]
-            else:
-                fitplot.styles.append(None)
                 
             #Measure forces
             delta_to_measure=displayed_plot.vectors[1][1][peak-delta_force:peak+delta_force]
             y=min(delta_to_measure)
-            #save force values (pN)
-            forces.append(abs(y-avg)*(1.0e+12))
-                
+            #save force values (pN)   
             #Measure slopes
             slope=self.linefit_between(peak-slope_span,peak)[0]
-            slopes.append(slope)
+            
+            
+            #check fitted data and, if right, add peak to the measurement
+            #FIXME: code duplication
+            if len(params)==1: #if we did choose 1-value fit
+                p_lengths.append(params[1]*(1.0e+9))
+                c_lengths.append(params[0]*(1.0e+9))
+                forces.append(abs(y-avg)*(1.0e+12))
+                slopes.append(slope)     
+                #Add WLC fit lines to plot
+                fitplot.add_set(xfit,yfit)
+                if len(fitplot.styles)==0:
+                    fitplot.styles=[]
+                else:
+                    fitplot.styles.append(None)
+            else:
+                p_leng=params[1]*(1.0e+9)
+                #check if persistent length makes sense. otherwise, discard peak.
+                if p_leng>self.config['auto_min_p'] and p_leng<self.config['auto_max_p']:
+                    p_lengths.append(p_leng)       
+                    c_lengths.append(params[0]*(1.0e+9))
+                    forces.append(abs(y-avg)*(1.0e+12))
+                    slopes.append(slope)     
+                    
+                    #Add WLC fit lines to plot
+                    fitplot.add_set(xfit,yfit)
+                    if len(fitplot.styles)==0:
+                        fitplot.styles=[]
+                    else:
+                        fitplot.styles.append(None)
+                else:
+                    pass
             
         #add basepoints to fitplot
         fitplot.add_set([self.basepoints[0].graph_coords[0],self.basepoints[1].graph_coords[0]],[self.basepoints[0].graph_coords[1],self.basepoints[1].graph_coords[1]]) 
         fitplot.styles.append('scatter')
         
+        
         #Show wlc fits and peak locations
         self._send_plot([fitplot])
-        self.do_peaks('')
+        #self.do_peaks('')
         
         
         #Ask the user what peaks to ignore from analysis.
index aadbd634a9630ad63be7a142ba3da25bba7a62c2..be90d0d39a7160ebbf76ed3b084ba9a95cce3b1d 100644 (file)
@@ -290,14 +290,16 @@ class generalvclampCommands:
         #FIXME: also, *generalize fits* to allow FJC and any other model in the future!
         
         def fit_interval_nm(start_index,plot,nm,backwards):
-            '''
-            '''
+    '''
+            
+    '''
             Calculates the number of points to fit, given a fit interval in nm
             start_index: index of point
             plot: plot to use
             backwards: if true, finds a point backwards.
-            '''
-            '''
+    '''
+            
+    '''
             x_vect=plot.vectors[1][0]
             
             c=0
index d49d3606eed1d7c738514efc15a641fa4e94333c..d929b61f75626dab506593c8fc59fdbc83c08845 100755 (executable)
@@ -2,7 +2,7 @@
 <!-- To comment something, put dashes and ! like here -->
 <config>
 <!-- Internal variabls. -->
-    <display ext="1" colour_ext="None" ret="1" colour_ret="None" correct="1" colour_correct="None" contact_point="0" medfilt="0" xaxes="0" yaxes="0" flatten="1" temperature="301" auto_fit_points="50" auto_slope_span="20" auto_delta_force="10" auto_fit_nm="5" baseline_clicks="0" auto_left_baseline="20" auto_right_baseline="20" fc_showphase="0" fc_showimposed="0" fc_interesting="0"/>
+    <display ext="1" colour_ext="None" ret="1" colour_ret="None" correct="1" colour_correct="None" contact_point="0" medfilt="0" xaxes="0" yaxes="0" flatten="1" temperature="301" auto_fit_points="50" auto_slope_span="20" auto_delta_force="10" auto_fit_nm="5" auto_min_p="0.005" auto_max_p="10" baseline_clicks="0" auto_left_baseline="20" auto_right_baseline="20" fc_showphase="0" fc_showimposed="0" fc_interesting="0"/>
 
 <!-- 
 The following section defines your own work directory. Substitute your work directory.