ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/osprai/osprai/trunk/test.py
(Generate patch)
# Line 65 | Line 65
65  
66   def test_mdl_module_fit_module():
67      print "Test the model module..."
68 <    ba0 = BiosensorArray(1,300)  ## Create ba with one ROI and 300 datapoints.
69 <    roi0 = ba0.roi[0]
70 <    roi0.time = arange(300, dtype=float)  ## Samples every 1 second.
71 <    roi0.value = zeros(300, dtype=float) + 20  ## Baseline signal is 20 units.
72 <    roi0.params = {'t1': {'value':30.0, 'min':30.0, 'max':30.0, 'fixed':True} }
73 <    roi0.params['rmax'] =  {'value': 100.0}
74 <    roi0.params['conc'] =  {'value': 1e-6}
75 <    roi0.params['kon'] =   {'value': 2e4}
76 <    roi0.params['t2'] =    {'value': 150.0}
77 <    roi0.params['koff'] =  {'value': 1e-3}
78 <    roi0.params['t3'] =    {'value': 270.0}
79 <    roi0.model = simple1to1
80 <    roi0.value =roi0.model(roi0.time, roi0.value, roi0.params)
68 >    ## Create ba with two ROIs and 300 datapoints.
69 >    ba0 = BiosensorArray(2,300)  
70 >    ## First ROI.
71 >    roi = ba0.roi[0]
72 >    roi.time = arange(300, dtype=float)  ## Samples every 1 second.
73 >    roi.value = zeros(300, dtype=float) + 20  ## Baseline signal is 20 units.
74 >    roi.params = {'t1': {'value':30.0, 'min':30.0, 'max':30.0, 'fixed':'fixed'} }
75 >    roi.params['rmax'] =  {'value': 100.0}
76 >    roi.params['conc'] =  {'value': 1e-6}
77 >    roi.params['kon'] =   {'value': 2e4}
78 >    roi.params['t2'] =    {'value': 150.0}
79 >    roi.params['koff'] =  {'value': 1e-3}
80 >    roi.params['t3'] =    {'value': 270.0}
81 >    roi.model = simple1to1
82 >    roi.value =roi.model(roi.time, roi.value, roi.params)
83 >    ## Second ROI
84 >    roi = ba0.roi[1]
85 >    roi.time = arange(300, dtype=float)  
86 >    roi.value = zeros(300, dtype=float) + 20
87 >    roi.params = deepcopy(ba0.roi[0].params)
88 >    roi.params['rmax'] = {'value': 50}
89 >    roi.model = simple1to1
90 >    roi.value = roi.model(roi.time, roi.value, roi.params)
91      linegraph(ba0, "Simulation")
92      
93 <    ## Constrain rmax<80 when it really is 100 to show what happens.
93 >    ## Constrain rmax away from 100 to show what happens.
94      print "Testing the fitting..."
95      ba1 = deepcopy(ba0)
96 <    roi0 = ba1.roi[0]
97 <    roi0.params['koff'] = {'value':1.0e-2, 'min':1e-8, 'max':1e-1, 'fixed':False}
98 <    roi0.params['kon'] =  {'value':1.0e2, 'min':1e1, 'max':1e8, 'fixed':False}
99 <    roi0.params['rmax'] =  {'value':150, 'min':120, 'max':190, 'fixed':False}
100 <    mclma([roi0])
101 <    roi0.value =roi0.model(roi0.time, roi0.value, roi0.params)
96 >    ## Make rmax too high.
97 >    ba1.roi[0].params['koff'] = {'value':1.0e-2, 'min':1e-8, 'max':1e-1, 'fixed':'float'}
98 >    ba1.roi[0].params['kon'] =  {'value':1.0e2, 'min':1e1, 'max':1e8, 'fixed':'float'}
99 >    ba1.roi[0].params['rmax'] =  {'value':150, 'min':110, 'max':190, 'fixed':'float'}
100 >    ## Make rmax too low.  Tie koff and kon to other ROI.
101 >    ba1.roi[1].params['koff'] = {'value':1.0e-2, 'min':1e-8, 'max':1e-1, 'fixed':0}
102 >    ba1.roi[1].params['kon'] =  {'value':1.0e2, 'min':1e1, 'max':1e8, 'fixed':0}
103 >    ba1.roi[1].params['rmax'] =  {'value':20, 'min':10, 'max':40, 'fixed':'float'}
104 >    ## Fit and then plot.
105 >    mclma([ba1.roi[0], ba1.roi[1]])
106 >    for roi in ba1.roi:
107 >        roi.value =roi.model(roi.time, roi.value, roi.params)
108      dualgraph(ba0, ba1, "Fitted Data with an incorrect Rmax parameter")
109      print "Done with test test_mdl_module_fit_module."
110      

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines