# convert to java array jxa = jarray.array(xa, 'd') jya = jarray.array(ya, 'd') # construct a CurveFitter instance cf = CurveFitter(jxa, jya) # actual fitting # fit models: # see http://rsb.info.nih.gov/ij/developer/api/constant-values.html#ij.measure.CurveFitter.STRAIGHT_LINE cf.doFit(CurveFitter.STRAIGHT_LINE) #print out fitted parameters. print(cf.getParams()[0], cf.getParams()[1]) print(cf.getFormula()) plt = cf.getPlot() plt.draw() left = 0 right = 5 bottom = 0 top = 5 nPoints = 4 rng = right - left # Create filled plot plt = Plot("Line plot", "X", "Y") plt.setLimits(left, right, bottom, top) plt.setFrameSize(600, 300)
# Calculate normalized curve normalized_curve = [] for i in range(n_slices): normalized_curve.append( (If[i] - min_intensity) / (mean_If - min_intensity) * mean_In / In[i] ) x = [i * frame_interval for i in range( n_slices ) ] y = normalized_curve xtofit = [ i * frame_interval for i in range( n_slices - bleach_frame ) ] ytofit = normalized_curve[ bleach_frame : n_slices ] # Fitter fitter = CurveFitter(xtofit, ytofit) fitter.doFit(CurveFitter.EXP_RECOVERY_NOOFFSET) IJ.log("Fit FRAP curve by " + fitter.getFormula() ) param_values = fitter.getParams() IJ.log( fitter.getResultString() ) # Overlay fit curve, with oversampling (for plot) xfit = [ (t / 10.0 + bleach_frame) * frame_interval for t in range(10 * len(xtofit) ) ] yfit = [] for xt in xfit: yfit.append( fitter.f( fitter.getParams(), xt - xfit[0]) ) plot = Plot("Normalized FRAP curve for " + current_imp.getTitle(), "Time ("+time_units+')', "NU", [], []) plot.setLimits(0, max(x), 0, 1.5 ); plot.setLineWidth(2)
cv = CurveFitter([a[0] for a in spshifts], [8 - a[1] for a in spshifts]) # fit the distortion measurements cv.doFit(CurveFitter.EXP_WITH_OFFSET) # cv.doFit(CurveFitter.EXPONENTIAL) # cv.doFit(CurveFitter.POLY2) # cv.doFit(CurveFitter.POLY3) plot = cv.getPlot() plot.show() 8 / 0 plot_images.append(plot.getImagePlus()) IJ.log('sFOV ' + str(sFOV)) IJ.log('fitGoodness ' + str(cv.getFitGoodness())) IJ.log('formula ' + str(cv.getFormula())) fit_params = cv.getParams() IJ.log('fit_params' + str(fit_params)) # write the fit results to file g.write('sFOV\t' + str(sFOV) + '\t' + 'a\t' + str(fit_params[0]) + '\t' + 'b\t' + str(fit_params[1]) + '\t' + 'c\t' + str(fit_params[2]) + '\t' + 'formula\t' + str(cv.getFormula()) + '\t' + 'fitGoodness\t' + str(cv.getFitGoodness()) + '\n') # # # # # The following commented code applies a scan correction using bigwarp. # # # # # A grid of landmarks is generated, saved into bigwarp format, then applied. # # # # # It is slow and needs to be optimized. # # # # create mesh