ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/osprai/osprai/trunk/ba_class.py
(Generate patch)
# Line 19 | Line 19
19    >>> ba1.roi[799].value[1499] = 0.50    ## Set SPR reflectance signal.
20    >>> ba1.roi[799].name = "anti-IgG"     ## Set name of microarray feature.
21   """
22 < __version__ = "110204"
22 > __version__ = "110208"
23  
24  
25   ## Import libraries.
26   import numpy as np
27 #import matplotlib.pyplot as plt
27   from datetime import date
28  
29  
# Line 59 | Line 58
58      def xy2uid(self, gx, gy, x, y):
59          """Given roi coordinates, find corresponding uid (index)."""
60          coor1 = (gx, gy, x, y)
61 <        for ob in self.roi:
62 <            coor2 = (ob.gridx, ob.gridy, ob.spotx, ob.spoty)
63 <            if (coor1==coor2): return ob.uid  ## Success.
61 >        for roi in self.roi:
62 >            coor2 = (roi.gridx, roi.gridy, roi.spotx, roi.spoty)
63 >            if (coor1==coor2): return roi.uid  ## Success.
64          return -1  ## Failure.
65          
66      def set_plot_all(self):
67          """Choose to plot every sensorgram."""
68 <        for ob in self.roi: ob.plottable = True
68 >        for roi in self.roi: roi.plottable = True
69          return
70          
71      def set_plot_list(self, ilist):
72          """Choose a list of sensorgrams to plot"""
73 <        for ob in self.roi: ob.plottable = False
73 >        for roi in self.roi: roi.plottable = False
74          for i in ilist: self.roi[i].plottable = True
75          return
76          
78    ## A pyplot feature for testing purposes.
79    def plot(self):
80        """Show plot of the selected sensorgrams."""
81        plt.clf()
82        plt.title('SPR Data plotted %s' % date.today().isoformat())
83        plt.xlabel('Time (s)')
84        plt.ylabel('SPR Response')
85        plt.grid(True)
86        ## Plot traces.
87        for ob in self.roi:
88            if (ob.plottable==True):
89                mylabel = "%i:%s" % (ob.index,ob.name)
90                plt.plot(ob.time, ob.value, label=mylabel)
91        plt.legend(loc='best')
92        plt.show()
93        return
94        
77      """End of BiosensorArray class definition."""
78  
79  
# Line 183 | Line 165
165      
166      """End of RegOfInterest definition."""
167  
168 < '''
187 < ## Here are a few lines to test this class.
188 < if __name__ == '__main__':
189 <    print "Starting demo..."
190 <    print "Test plotting..."
191 <    x = BiosensorArray(10,10)
192 <    x.roi[0].time = np.arange(10)
193 <    x.roi[0].value = np.arange(10)**2
194 <    x.roi[1].time = np.arange(10)
195 <    x.roi[1].value = np.arange(10)**1.5
196 <    x.roi[9].time = np.arange(10)
197 <    x.roi[9].value = np.arange(10)**1
198 <    #x.set_plot_all()
199 <    x.set_plot_list([0,1,9])
200 <    x.plot()
201 <    print "Test xy2uid... 9 =",
202 <    x.roi[9].gridx = 2
203 <    print x.xy2uid(2,0,0,0)
204 <    print "Test time2dp... 5.6 =>",
205 <    print x.roi[9].time2dp(5.6)
206 <    print "Demo finished."
207 < '''
208 <    
209 <    
168 >
169   ################################# End of module #################################

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines