Beispiel #1
0
def plot_standard_curve(result, encoding='jpg'):
	
	if not result.isCalibrated:
		raise Exception('Can not plot standard curve if experiment is not calibrated.')
	
	fig = Figure()
	ax1 = fig.add_subplot(111) 
	
	fig.set_size_inches(_plot_size[0],_plot_size[1], forward=True)
	fig.set_facecolor(plot_bgcolor)
	
	ax1.set_title('fitted curve')
	ax1.grid(True)

	background_mean, background_std = result.background_intensity

	# avoid division by zero with perfect testing images
	if background_mean == 0:
		print('warning: background is zero')
		background_mean = np.float64(1e-8)

	calibX, calibY = result.calibration_data
	calibY_snr = calibY / background_mean
	calibY_snr_err = result.intensity_stddev[result.calibration_data_indices] / background_mean
	curve = fittedCurve(calibX, calibY_snr)
	
	# plot fitted curve
	x = np.linspace(0,np.max(calibX),10)
	y = map(curve,x)
	ax1.plot(x, y, color='black', linewidth=1, label='fitted curve')
	
	# plot calibration points
	#ax1.plot(calibX, calibY_snr, marker='x', color='black', linewidth=0) #, yerr=calibY_snr_err)
	ax1.errorbar(calibX, calibY_snr, yerr=calibY_snr_err, marker='x', color='black', linewidth=0)
	
	ax1.set_xlabel('concentration [%s]'%_concentration_units)
	ax1.set_ylabel('signal / background')
	

	
	if background_std > 0:
		# don't plot lod, and loq if std_dev of background is not known.
		
		# limit of detection
		lod = result.limit_of_detection / background_mean
		ax1.axhline(y=lod, linewidth=1, color='g', label='LoD', linestyle='--')
		
		# limit of quantification
		loq = result.limit_of_quantification / background_mean
		ax1.axhline(y=loq, linewidth=1, color='b', label='LoQ', linestyle='-.')
	
	ax1.legend(loc=0)
           
	#plt.margins(0.2)
	#fig.subplots_adjust(hspace=0.2, wspace=0.2, bottom=0.15)
	
	#fig.tight_layout()

	return fig
Beispiel #2
0
 def _intensity_to_concentration(self):
     c, i = self.calibration_data
     curve = curvefit.fittedCurve(i, c)
     return curve
Beispiel #3
0
 def _concentration_to_intensity(self):
     c, i = self.calibration_data
     curve = curvefit.fittedCurve(c, i)
     return curve
Beispiel #4
0
	def _intensity_to_concentration(self):
		c,i = self.calibration_data
		curve = curvefit.fittedCurve(i,c)
		return curve
Beispiel #5
0
	def _concentration_to_intensity(self):
		c,i = self.calibration_data
		curve = curvefit.fittedCurve(c,i)
		return curve