public void run(ImageProcessor ip) { global1 = imp.getGlobalCalibration()!=null; if (!showDialog(imp)) return; if (choiceIndex==customIndex) { showPlot(null, null, imp.getCalibration(), null); return; } else if (imp.getType()==ImagePlus.GRAY32) { if (choiceIndex==0) imp.getCalibration().setValueUnit(unit); else IJ.error("Calibrate", "Function must be \"None\" for 32-bit images,\nbut you can change the Unit."); } else calibrate(imp); }
double[] getData(String xData) { int len = xData.length(); StringBuffer sb = new StringBuffer(len); for (int i=0; i<len; i++) { char c = xData.charAt(i); if ((c>='0'&&c<='9') || c=='-' || c=='.' || c==',' || c=='\n' || c=='\r' || c==' ') sb.append(c); } xData = sb.toString(); StringTokenizer st = new StringTokenizer(xData); int nTokens = st.countTokens(); if (nTokens<1) return new double[0]; int n = nTokens; double data[] = new double[n]; for (int i=0; i<n; i++) { data[i] = getNum(st); } return data; }
} else if (choiceIndex<=nFits) { function = choiceIndex - 1; x = getData(xText); y = getData(yText); if (cal.isSigned16Bit() || imp.getProperty("WasSigned")!=null) { for (int i=0; i<x.length; i++) imp.setProperty("WasSigned", "WasSigned"); if (!validateXValues(imp, x)) return; if (!cal.calibrated() || y.length!=0 || function!=oldFunction) { parameters = doCurveFitting(x, y, function); if (parameters==null) { //minimization failed IJ.error(curveFitError); Fitter.plot(curveFitter, bitDepth==8); else showPlot(x, y, cal, fitGoodness);
public boolean showDialog(ImagePlus imp) { String defaultChoice; Calibration cal = imp.getCalibration(); functions = getFunctionList(cal.getFunction()==Calibration.CUSTOM); int function = cal.getFunction(); oldFunction = function; defaultChoice=NONE; String tmpText = getMeans(); if (!importedValues && !tmpText.equals("")) xText = tmpText; gd.addTextAreas(xText, yText, 20, 14); gd.addPanel(makeButtonPanel(gd)); gd.addCheckbox("Global calibration", IJ.isMacro()?false:global1); gd.addCheckbox("Show plot", IJ.isMacro()?false:showPlotFlagSaved);
double[] p = cal.getCoefficients(); if (fit<=Calibration.LOG2) { drawLabel(plot, CurveFitter.fList[fit]); ly += 0.04; drawLabel(plot, "a="+IJ.d2s(p[0],6,10)); drawLabel(plot, "b="+IJ.d2s(p[1],6,10)); if (np>=3) drawLabel(plot, "c="+IJ.d2s(p[2],6,10)); if (np>=4) drawLabel(plot, "d="+IJ.d2s(p[3],6,10)); if (np>=5) drawLabel(plot, "e="+IJ.d2s(p[4],6,10)); ly += 0.04; {drawLabel(plot, "R^2="+rSquared); rSquared=null;} plot.show();
} else if (choiceIndex<=nFits) { function = choiceIndex - 1; x = getData(xText); y = getData(yText); if (cal.isSigned16Bit() || imp.getProperty("WasSigned")!=null) { for (int i=0; i<x.length; i++) imp.setProperty("WasSigned", "WasSigned"); if (!validateXValues(imp, x)) return; if (!cal.calibrated() || y.length!=0 || function!=oldFunction) { parameters = doCurveFitting(x, y, function); if (parameters==null) { //minimization failed IJ.error(curveFitError); Fitter.plot(curveFitter, bitDepth==8); else showPlot(x, y, cal, fitGoodness);
public boolean showDialog(ImagePlus imp) { String defaultChoice; Calibration cal = imp.getCalibration(); functions = getFunctionList(cal.getFunction()==Calibration.CUSTOM); int function = cal.getFunction(); oldFunction = function; defaultChoice=NONE; String tmpText = getMeans(); if (!importedValues && !tmpText.equals("")) xText = tmpText; gd.addTextAreas(xText, yText, 20, 14); gd.addPanel(makeButtonPanel(gd)); gd.addCheckbox("Global calibration", IJ.isMacro()?false:global1); gd.addCheckbox("Show plot", IJ.isMacro()?false:showPlotFlagSaved);
double[] p = cal.getCoefficients(); if (fit<=Calibration.LOG2) { drawLabel(plot, CurveFitter.fList[fit]); ly += 0.04; drawLabel(plot, "a="+IJ.d2s(p[0],6,10)); drawLabel(plot, "b="+IJ.d2s(p[1],6,10)); if (np>=3) drawLabel(plot, "c="+IJ.d2s(p[2],6,10)); if (np>=4) drawLabel(plot, "d="+IJ.d2s(p[3],6,10)); if (np>=5) drawLabel(plot, "e="+IJ.d2s(p[4],6,10)); ly += 0.04; {drawLabel(plot, "R^2="+rSquared); rSquared=null;} plot.show();
public void run(ImageProcessor ip) { global1 = imp.getGlobalCalibration()!=null; if (!showDialog(imp)) return; if (choiceIndex==customIndex) { showPlot(null, null, imp.getCalibration(), null); return; } else if (imp.getType()==ImagePlus.GRAY32) { if (choiceIndex==0) imp.getCalibration().setValueUnit(unit); else IJ.error("Calibrate", "Function must be \"None\" for 32-bit images,\nbut you can change the Unit."); } else calibrate(imp); }
double[] getData(String xData) { int len = xData.length(); StringBuffer sb = new StringBuffer(len); for (int i=0; i<len; i++) { char c = xData.charAt(i); if ((c>='0'&&c<='9') || c=='-' || c=='.' || c==',' || c=='\n' || c=='\r' || c==' ') sb.append(c); } xData = sb.toString(); StringTokenizer st = new StringTokenizer(xData); int nTokens = st.countTokens(); if (nTokens<1) return new double[0]; int n = nTokens; double data[] = new double[n]; for (int i=0; i<n; i++) { data[i] = getNum(st); } return data; }