public void run(String arg) { GenericDialog gd = new GenericDialog("Options"); double sfreq = 20000.0; gd.addNumericField("Sampling Frequency?", sfreq, 1, 10, null); String[] psfchoice = {"3D Gaussian", "Gaus-Lorentz^2", "2D Gaussian"}; gd.addChoice("PSF Type?", psfchoice, psfchoice[0]); String[] filetypechoice = { "Confocor 3 raw", "Short binary trajectory", "PlotWindow trajectory", "Ascii Text File" }; gd.addChoice("File Type?", filetypechoice, filetypechoice[0]); boolean ch2green = true; gd.addCheckbox("Ch2 is green?", ch2green); gd.showDialog(); if (gd.wasCanceled()) { return; } sfreq = gd.getNextNumber(); int psfflag = gd.getNextChoiceIndex(); int fileflag = gd.getNextChoiceIndex(); ch2green = gd.getNextBoolean(); int nfiles = 0; Object[] histograms = null; int xmax = 0; int ymax = 0; String[] names = null; if (fileflag < 2) { jdataio ioclass = new jdataio(); File[] filearray = ioclass.openfiles(OpenDialog.getDefaultDirectory(), IJ.getInstance()); if (filearray.length == 0) { return; } String dir = filearray[0].getAbsolutePath(); int sepindex = dir.lastIndexOf(File.separator); String newdir = dir.substring(0, sepindex + 1); OpenDialog.setDefaultDirectory(newdir); nfiles = filearray.length / 2; if (nfiles > 25) { nfiles = 25; } histograms = new Object[nfiles]; names = organize_c3_files(filearray); for (int i = 0; i < nfiles; i++) { try { int length1 = (int) (((double) filearray[2 * i].length() - 128.0) / 4.0); int length2 = (int) (((double) filearray[2 * i + 1].length() - 128.0) / 4.0); int length3 = (int) (((double) filearray[2 * i].length()) / 2.0); int length4 = (int) (((double) filearray[2 * i + 1].length()) / 2.0); InputStream instream = new BufferedInputStream(new FileInputStream(filearray[2 * i])); InputStream instream2 = new BufferedInputStream(new FileInputStream(filearray[2 * i + 1])); if (fileflag == 0) { int[] pmdata = new int[length1]; int[] pmdata2 = new int[length2]; if (!ioclass.skipstreambytes(instream, 128)) { showioerror(); instream.close(); return; } if (!ioclass.skipstreambytes(instream2, 128)) { showioerror(); instream2.close(); return; } if (!ioclass.readintelintfile(instream, length1, pmdata)) { showioerror(); instream.close(); return; } if (!ioclass.readintelintfile(instream2, length2, pmdata2)) { showioerror(); instream2.close(); return; } if (ch2green) { histograms[i] = (new pmodeconvert()).pm2pch(pmdata2, pmdata, sfreq, 20000000); } else { histograms[i] = (new pmodeconvert()).pm2pch(pmdata, pmdata2, sfreq, 20000000); } } else { float[] tmdata = new float[length3]; float[] tmdata2 = new float[length4]; if (!ioclass.readintelshortfile(instream, length3, tmdata)) { showioerror(); instream.close(); return; } if (!ioclass.readintelshortfile(instream2, length4, tmdata2)) { showioerror(); instream2.close(); return; } if (ch2green) { histograms[i] = (new pmodeconvert()).create_2Dhistogram(tmdata2, tmdata); } else { histograms[i] = (new pmodeconvert()).create_2Dhistogram(tmdata, tmdata2); } } if (((float[][]) histograms[i]).length > xmax) { xmax = ((float[][]) histograms[i]).length; } if (((float[][]) histograms[i])[0].length > ymax) { ymax = ((float[][]) histograms[i])[0].length; } instream.close(); instream2.close(); } catch (IOException e) { showioerror(); return; } } } else { if (fileflag == 2) { ImageWindow iw = WindowManager.getCurrentWindow(); float[][] trajectories = (float[][]) jutils.runPW4VoidMethod(iw, "getYValues"); float[][] tempxvals = (float[][]) jutils.runPW4VoidMethod(iw, "getXValues"); sfreq = 1.0 / ((double) tempxvals[0][1]); nfiles = trajectories.length / 2; if (nfiles > 25) { nfiles = 25; } names = new String[nfiles + 1]; names[nfiles] = "avg"; histograms = new Object[nfiles]; for (int i = 0; i < nfiles; i++) { names[i] = "trajectory " + (i + 1); if (ch2green) { histograms[i] = (new pmodeconvert()) .create_2Dhistogram(trajectories[2 * i + 1], trajectories[2 * i]); } else { histograms[i] = (new pmodeconvert()) .create_2Dhistogram(trajectories[2 * i], trajectories[2 * i + 1]); } if (((float[][]) histograms[i]).length > xmax) { xmax = ((float[][]) histograms[i]).length; } if (((float[][]) histograms[i])[0].length > ymax) { ymax = ((float[][]) histograms[i])[0].length; } } } else { // here we read tab delimited lines from files jdataio ioclass = new jdataio(); File[] filearray = ioclass.openfiles(OpenDialog.getDefaultDirectory(), IJ.getInstance()); if (filearray.length == 0) { return; } String dir = filearray[0].getAbsolutePath(); int sepindex = dir.lastIndexOf(File.separator); String newdir = dir.substring(0, sepindex + 1); OpenDialog.setDefaultDirectory(newdir); nfiles = filearray.length; if (nfiles > 25) { nfiles = 25; } histograms = new Object[nfiles]; names = new String[nfiles + 1]; names[nfiles] = "avg"; for (int i = 0; i < nfiles; i++) { try { names[i] = filearray[i].getName(); BufferedReader d = new BufferedReader(new FileReader(filearray[i])); String[] lines = new String[256]; int counter = 0; do { lines[counter] = d.readLine(); counter++; } while ((lines[counter - 1] != null && lines[counter - 1] != "") && counter < 256); int numcolumns = 0; for (int j = 0; j < counter - 1; j++) { int temp = getncolumns(lines[j]); if (temp > numcolumns) { numcolumns = temp; } } float[][] temphist2 = null; if (ch2green) { temphist2 = new float[numcolumns][counter - 1]; } else { temphist2 = new float[counter - 1][numcolumns]; } for (int k = 0; k < counter - 1; k++) { float[] temp = tab_delim2float(lines[k]); for (int j = 0; j < numcolumns; j++) { if (ch2green) { temphist2[j][k] = temp[j]; } else { temphist2[k][j] = temp[j]; } } } histograms[i] = temphist2; d.close(); } catch (IOException e) { showioerror(); return; } } for (int i = 0; i < nfiles; i++) { if (((float[][]) histograms[i]).length > xmax) { xmax = ((float[][]) histograms[i]).length; } if (((float[][]) histograms[i])[0].length > ymax) { ymax = ((float[][]) histograms[i])[0].length; } } } } // note that here x is green and y is red float[][][] pch = new float[nfiles][xmax][ymax]; for (int i = 0; i < nfiles; i++) { for (int j = 0; j < ((float[][]) histograms[i]).length; j++) { for (int k = 0; k < ((float[][]) histograms[i])[j].length; k++) { pch[i][j][k] = ((float[][]) histograms[i])[j][k]; } } } final PCH2DFitWindow cw = new PCH2DFitWindow(); cw.init(names, pch, psfflag); final Frame f = new Frame("PCH 2D Analysis"); f.setLocation(10, 10); f.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { f.dispose(); } }); f.add(cw); f.pack(); f.setResizable(false); Insets ins = f.getInsets(); cw.totalSize.height = PCH2DFitWindow.H + ins.bottom + ins.top + 65; cw.totalSize.width = PCH2DFitWindow.WR + ins.left + ins.right; f.setSize(cw.totalSize); f.setVisible(true); cw.requestFocus(); }
private void geterrors() { GenericDialog gd = new GenericDialog("Options"); float conf = 0.67f; gd.addNumericField("Confidence Limit", (int) (conf * 100.0f), 5, 10, null); gd.addChoice("Error Parameter", paramsnames, paramsnames[0]); double spacing = 0.01; gd.addNumericField("Chi^2 plot spacing (% of value)?", spacing * 100.0, 2, 10, null); boolean globalerror = false; gd.addCheckbox("Global Fit Error?", globalerror); int dataset = 0; gd.addNumericField("Data Set (for Global Error)", dataset, 0); gd.showDialog(); if (gd.wasCanceled()) { return; } conf = 0.01f * (float) gd.getNextNumber(); int paramindex = (int) gd.getNextChoiceIndex(); spacing = 0.01 * gd.getNextNumber(); globalerror = gd.getNextBoolean(); dataset = (int) gd.getNextNumber(); if (globalerror) { support_plane_errors erclass = new support_plane_errors(this, 0.0001, 50, true, 0.1); int[] erindeces = {paramindex, dataset}; // need to set up all the matrices int nsel = 0; int nparams = 11; for (int i = 0; i < ncurves; i++) { if (include[i]) { nsel++; } } double[][] params = new double[nsel][nparams]; String[][] tempformulas = new String[nsel][nparams]; double[][][] constraints = new double[2][nsel][nparams]; int[][] vflmatrix = new int[nsel][nparams]; float[][] tempdata = new float[nsel][xpts * ypts]; float[][] tempweights = new float[nsel][xpts * ypts]; int nfit = 0; int counter = 0; for (int i = 0; i < ncurves; i++) { if (include[i]) { for (int j = 0; j < nparams; j++) { params[counter][j] = globalparams[i][j]; tempformulas[counter][j] = globalformulas[i][j]; constraints[0][counter][j] = globalconstraints[0][i][j]; constraints[1][counter][j] = globalconstraints[1][i][j]; vflmatrix[counter][j] = globalvflmatrix[i][j]; if (vflmatrix[counter][j] == 0 || (j == 0 && vflmatrix[counter][j] == 2)) { nfit++; } } for (int j = 0; j < xpts; j++) { for (int k = 0; k < ypts; k++) { tempdata[counter][j + k * xpts] = (float) ((double) pch[i][j][k] / (double) nmeas[i]); tempweights[counter][j + k * xpts] = weights[i][j][k]; } } counter++; } } int dofnum = xpts * ypts * nsel - (nfit - 1) - 1; int dofden = xpts * ypts * nsel - nfit - 1; // double flim=FLimit(dofnum,dofden,(double)conf); double flim = (new jdist()).FLimit(dofnum, dofden, (double) conf); IJ.log("FLimit = " + (float) flim); if (flim == Double.NaN && flim < 1.0) { IJ.showMessage("Invalid Limiting F Value"); return; } double truespacing = Math.abs(params[erindeces[1]][erindeces[0]] * spacing); double[][] c2plot = erclass.geterrorsglobal( params, vflmatrix, tempformulas, paramsnames, constraints, tempdata, tempweights, flim, truespacing, erindeces); IJ.log("upper limit = " + c2plot[1][0] + " lower limit = " + c2plot[0][0]); int templength = c2plot[0].length; float[][] c2plotf = new float[2][templength - 1]; for (int i = 0; i < (templength - 1); i++) { c2plotf[0][i] = (float) c2plot[0][i + 1]; c2plotf[1][i] = (float) c2plot[1][i + 1]; } new PlotWindow4( "c2 plot", paramsnames[paramindex] + "[" + dataset + "]", "Chi^2", c2plotf[0], c2plotf[1]) .draw(); } else { support_plane_errors erclass = new support_plane_errors(this, 0.0001, 50, false, 0.1); int errindex = paramindex; float[] tempdata = new float[xpts * ypts]; float[] tempweights = new float[xpts * ypts]; for (int i = 0; i < xpts; i++) { for (int j = 0; j < ypts; j++) { tempdata[i + j * xpts] = (float) ((double) avg[i][j] / (double) nmeas[ncurves]); tempweights[i + j * xpts] = avgweights[i][j]; } } int nfit = 0; for (int i = 0; i < 7; i++) { if (avgfixes[i] == 0) { nfit++; } } int dofnum = xpts * ypts - (nfit - 1) - 1; int dofden = xpts * ypts - nfit - 1; double flim = (new jdist()).FLimit(dofnum, dofden, (double) conf); IJ.log("FLimit = " + (float) flim); if (flim == Double.NaN && flim < 1.0) { IJ.showMessage("Invalid Limiting F Value"); return; } double truespacing = Math.abs(avgparams[errindex] * spacing); double[][] c2plot = erclass.geterrors( avgparams, avgfixes, avgconstraints, tempdata, tempweights, flim, truespacing, errindex); IJ.log("upper limit = " + c2plot[1][0] + " lower limit = " + c2plot[0][0]); int templength = c2plot[0].length; float[][] c2plotf = new float[2][templength - 1]; for (int i = 0; i < (templength - 1); i++) { c2plotf[0][i] = (float) c2plot[0][i + 1]; c2plotf[1][i] = (float) c2plot[1][i + 1]; } new PlotWindow4("c2 plot", paramsnames[errindex], "Chi^2", c2plotf[0], c2plotf[1]).draw(); } }
public void run(String arg) { Frame[] niframes = WindowManager.getNonImageWindows(); String[] titles = new String[niframes.length + 1]; for (int i = 0; i < niframes.length; i++) { titles[i] = niframes[i].getTitle(); } titles[niframes.length] = "Clipboard"; GenericDialog gd = new GenericDialog("Windows"); boolean importfile = false; gd.addCheckbox("Import from file?", importfile); gd.addChoice("Windows", titles, titles[0]); boolean hasxvals = false; gd.addCheckbox("X Vals Column?", hasxvals); boolean multix = false; gd.addCheckbox("Multi_X_Columns?", multix); boolean skipendzeros = false; gd.addCheckbox("Skip_end_zeros?", skipendzeros); String[] delimiters = {"Tab", "Comma", "Space"}; gd.addChoice("Delimiter", delimiters, delimiters[0]); gd.showDialog(); if (gd.wasCanceled()) { return; } importfile = gd.getNextBoolean(); int index = gd.getNextChoiceIndex(); hasxvals = gd.getNextBoolean(); multix = gd.getNextBoolean(); skipendzeros = gd.getNextBoolean(); int delimindex = gd.getNextChoiceIndex(); if (multix) hasxvals = true; String textdata = ""; if (importfile) { OpenDialog od = new OpenDialog("Open File", "", ".txt"); String directory = od.getDirectory(); String name = od.getFileName(); if (name == null) { return; } try { File infile = new File(directory + name); BufferedReader b = new BufferedReader(new FileReader(infile)); textdata = (new jdataio()).readstringfile(b); b.close(); } catch (IOException e) { return; } } else { if (index == niframes.length) { // here we get the data from the clipboard Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); try { if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) { textdata = (String) t.getTransferData(DataFlavor.stringFlavor); } } catch (UnsupportedFlavorException e) { } catch (IOException e) { } if (textdata.equals("")) { IJ.error("Error copying from clipboard."); return; } } else { if (niframes[index] instanceof Editor) { Editor tw = (Editor) niframes[index]; textdata = tw.getText(); } else { if (niframes[index] instanceof TextWindow) { TextWindow tw = (TextWindow) niframes[index]; textdata = tw.getTextPanel().getText(); } else { IJ.showMessage("Not a valid text window"); return; } } } } if (textdata == null) { IJ.showMessage("Error in Obtaining String"); return; } if (textdata.indexOf("\r") >= 0) { textdata = textdata.replace('\r', '\n'); } char[] delims = {'\t', ',', ' '}; delimit_string ds = new delimit_string(delims[delimindex]); String[] rows = ds.getrows(textdata); int lines = rows.length; int columns = ds.getnumcolumns(rows[0]); int ycolumns = columns; if (hasxvals) { if (multix) { ycolumns /= 2; } else { ycolumns--; } } if (multix) { float[][] ydata = new float[ycolumns][lines]; float[][] xdata = new float[ycolumns][lines]; for (int i = 0; i < lines; i++) { float[] temp = ds.delim2float(rows[i], columns); for (int j = 0; j < ycolumns; j++) { ydata[j][i] = temp[2 * j + 1]; xdata[j][i] = temp[2 * j]; } } int[] npts = new int[ycolumns]; for (int i = 0; i < ycolumns; i++) { npts[i] = lines; } if (skipendzeros) { for (int i = 0; i < ycolumns; i++) { int counter = lines - 1; while ((xdata[i][counter] == 0.0f || Float.isNaN(xdata[i][counter])) && counter > 0) { xdata[i][counter] = 0.0f; ydata[i][counter] = 0.0f; npts[i]--; counter--; } } } (new PlotWindow4("Text Plot", "x", "y", xdata, ydata, npts)).draw(); } else { float[][] tempydata = new float[ycolumns][lines]; float[] tempxdata = new float[lines]; float[][] xdata = null; float[][] ydata = null; int startcolumn = 0; if (hasxvals) startcolumn = 1; for (int i = 0; i < lines; i++) { float[] temp = ds.delim2float(rows[i], columns); if (hasxvals) { tempxdata[i] = temp[0]; } else { tempxdata[i] = (float) (i + 1); } for (int j = 0; j < ycolumns; j++) { tempydata[j][i] = temp[j + startcolumn]; } } int[] npts = new int[ycolumns]; npts[0] = lines; if (skipendzeros) { int maxpts = 0; for (int i = 0; i < ycolumns; i++) { int counter = lines - 1; npts[i] = lines; while ((tempydata[i][counter] == 0.0f || Float.isNaN(tempydata[i][counter])) && counter > 0) { npts[i]--; counter--; } if (npts[i] > maxpts) maxpts = npts[i]; IJ.log("" + npts[i]); } ydata = new float[ycolumns][maxpts]; xdata = new float[ycolumns][maxpts]; for (int i = 0; i < ycolumns; i++) { // npts[i]=npts[0]; System.arraycopy(tempxdata, 0, xdata[i], 0, npts[i]); System.arraycopy(tempydata[i], 0, ydata[i], 0, npts[i]); } } else { ydata = tempydata; xdata = new float[ycolumns][]; for (int i = 0; i < ycolumns; i++) { npts[i] = npts[0]; xdata[i] = tempxdata.clone(); } } (new PlotWindow4("Text Plot", "x", "y", xdata, ydata, npts)).draw(); } }
public boolean get_errors(double[] params, int[] fixes) { GenericDialog gd = new GenericDialog("Error Options"); String[] methods = {"Support Plane", "Monte Carlo"}; gd.addChoice("Method", methods, methods[0]); float conf = 0.67f; gd.addNumericField("SP_Confidence Limit (%)", (int) (conf * 100.0f), 5, 10, null); String[] labels = {"P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10"}; gd.addChoice("SP_Parameter", labels, labels[0]); double spacing = 0.01; gd.addNumericField("SP_Chi^2_plot_spacing (% of value)?", spacing * 100.0, 2, 10, null); int ntrials = 100; gd.addNumericField("MC_#_Trials", ntrials, 0); gd.showDialog(); if (gd.wasCanceled()) { return false; } int methodindex = gd.getNextChoiceIndex(); conf = 0.01f * (float) gd.getNextNumber(); int paramindex = gd.getNextChoiceIndex(); spacing = 0.01 * gd.getNextNumber(); ntrials = (int) gd.getNextNumber(); if (methodindex == 0) { support_plane_errors_v2 erclass = new support_plane_errors_v2(this, 0.0001, 50, false, 0.1); int errindex = paramindex; int nfit = 0; for (int i = 0; i < labels.length; i++) { if (fixes[i] == 0) { nfit++; } } int npts = tempdata.length; int dofnum = npts - (nfit - 1) - 1; int dofden = npts - nfit - 1; double flim = (new jdist()).FLimit(dofnum, dofden, (double) conf); IJ.log("FLimit = " + (float) flim); if (flim == Double.NaN && flim < 1.0) { IJ.showMessage("Invalid Limiting F Value"); return false; } double truespacing = Math.abs(params[errindex] * spacing); double[][] c2plot = erclass.geterrors( params, fixes, constraints, tempdata, weights, flim, truespacing, errindex); IJ.log("upper limit = " + c2plot[1][0] + " lower limit = " + c2plot[0][0]); IJ.log( "upper error = " + (c2plot[1][0] - params[errindex]) + " lower error = " + (params[errindex] - c2plot[0][0])); int templength = c2plot[0].length; float[][] c2plotf = new float[2][templength - 1]; for (int i = 0; i < (templength - 1); i++) { c2plotf[0][i] = (float) c2plot[0][i + 1]; c2plotf[1][i] = (float) c2plot[1][i + 1]; } new PlotWindow4("c2 plot", labels[errindex], "Chi^2", c2plotf[0], c2plotf[1]).draw(); } else { StringBuffer sb = new StringBuffer(); sb.append("Trial\t"); for (int i = 0; i < labels.length; i++) { if (fixes[i] == 0) sb.append(labels[i] + "\t"); } sb.append("chi^2"); tw = new TextWindow("Monte Carlo Results", sb.toString(), "", 400, 400); redirect = true; monte_carlo_errors_v2 erclass = new monte_carlo_errors_v2(this, 0.0001, 50, false, 0.1); double[][] errors = erclass.geterrors(params, fixes, constraints, tempdata, weights, ntrials); sb = new StringBuffer(); sb.append("StDev\t"); for (int i = 0; i < errors.length; i++) { float[] ferr = new float[errors[0].length]; for (int j = 0; j < ferr.length; j++) ferr[j] = (float) errors[i][j]; float stdev = jstatistics.getstatistic("StDev", ferr, null); sb.append("" + stdev); if (i < (errors.length - 1)) sb.append("\t"); } tw.append(sb.toString()); redirect = false; } return true; }
public void run(String arg) { String[] labels = { "Masked_Chromosomes", "Unmixed_Image", "Spectral_Image(optional)", "Spectra(optional)" }; ImagePlus[] imps = jutils.selectImages(true, 4, labels); if (imps == null) { return; } if (imps[0] == null) { return; } float[] mask = (float[]) imps[0].getStack().getPixels(2); findblobs3 fb = new findblobs3(imps[0].getWidth(), imps[0].getHeight()); float[] objects = fb.dofindblobs(mask, 0.5f); WaitForUserDialog dg = new WaitForUserDialog( "Optional Input", "Place RoiManager Points on Chromosome Segments (if desired)"); dg.show(); if (!dg.escPressed()) { RoiManager rman = RoiManager.getInstance(); while (rman != null && rman.getCount() > 1) { Roi[] rois = rman.getRoisAsArray(); int[] ids = new int[rois.length]; for (int i = 0; i < rois.length; i++) { Rectangle r = rois[i].getBounds(); ids[i] = (int) objects[r.x + fb.width * r.y]; } objects = fb.link_objects(objects, ids); rman.reset(); dg = new WaitForUserDialog( "Optional Input", "Place More RoiManager Points on Chromosome Segments (if desired)"); dg.show(); if (dg.escPressed()) break; } } int[] areas = fb.get_areas(objects); int[] temprank = jsort.get_javasort_order(areas); int[] arearank = jsort.get_javasort_order(temprank); for (int i = 0; i < fb.nobjects; i++) { arearank[i] = fb.nobjects - arearank[i] - 1; } // if the spectra are available, get them float[][][] spectra = null; Object[] data = null; if (imps[1] != null && imps[2] != null && imps[3] != null) { ImageWindow iw = imps[3].getWindow(); if (iw.getClass().getName().equals("jguis.PlotWindow4")) { float[][] yvals = (float[][]) jutils.runPW4VoidMethod(iw, "getYValues"); data = jutils.stack2array(imps[2].getStack()); Object[] coef = jutils.stack2array(imps[1].getStack()); spectra = new float[fb.nobjects][2][]; for (int i = 0; i < fb.nobjects; i++) { spectra[i][0] = fb.get_object_spectrum(objects, (i + 1), data, "Sum"); spectra[i][1] = new float[yvals[0].length]; float[] tempcoef = fb.get_object_spectrum(objects, (i + 1), coef, "Sum"); for (int j = 0; j < yvals[0].length; j++) { for (int k = 0; k < 5; k++) { spectra[i][1][j] += tempcoef[k] * yvals[k][j]; } } } } } CompositeImage imp = (CompositeImage) imps[0]; imp.setPosition(1, 1, 1); LUT graylut = jutils.get_lut_for_color(Color.white); imp.setChannelColorModel(graylut); imp.setPosition(2, 1, 1); LUT redlut = jutils.get_lut_for_color(Color.red); imp.setChannelColorModel(redlut); imp.setPosition(1, 1, 1); imp.updateAndRepaintWindow(); SkyPanel_v3 sp = new SkyPanel_v3(); int skychan = 6; if (imps[1] != null) skychan = imps[1].getNChannels(); // assume that the sky image has 6 channels and that the second is the unknown green // shift the unknown green to the end ImagePlus skyimp = null; if (imps[1] != null) { Object[] skystack = jutils.stack2array(imps[1].getStack()); // Object[] // skystack2={skystack[0],skystack[2],skystack[3],skystack[4],skystack[5],skystack[1]}; Object[] skystack2 = null; if (skychan == 6) skystack2 = new Object[] {skystack[0], skystack[2], skystack[3], skystack[4], skystack[5]}; else skystack2 = new Object[] {skystack[0], skystack[1], skystack[2], skystack[3], skystack[4]}; skyimp = new ImagePlus( "rearranged", jutils.array2stack(skystack2, imps[1].getWidth(), imps[1].getHeight())); } int nch = 5; if (skyimp != null) nch = skyimp.getStack().getSize(); GenericDialog gd2 = new GenericDialog("Options"); gd2.addNumericField("Area Accuracy (percent)", 30, 0); for (int i = 0; i < nch; i++) { gd2.addNumericField("Ch_" + (i + 1) + "_Contr_Thresh", 0.35, 5, 15, null); } // gd2.addNumericField("Contribution Threshold",0.35,5,15,null); gd2.addCheckbox("Mouse?", false); gd2.addNumericField("Box_Width", 150, 0); gd2.addNumericField("Box_Height", 100, 0); gd2.showDialog(); if (gd2.wasCanceled()) { return; } sp.areathresh = (float) gd2.getNextNumber(); sp.objthresh2 = new float[nch]; for (int i = 0; i < nch; i++) sp.objthresh2[i] = (float) gd2.getNextNumber(); // sp.objthresh=(float)gd2.getNextNumber(); boolean mouse = gd2.getNextBoolean(); int bwidth = (int) gd2.getNextNumber(); int bheight = (int) gd2.getNextNumber(); int[] colorindices = {4, 1, 2, 6, 3}; GenericDialog gd3 = new GenericDialog("Color Options"); for (int i = 0; i < 5; i++) gd3.addChoice( "Ch" + (i + 1) + " Color", SkyPanel_v3.colornames, SkyPanel_v3.colornames[colorindices[i]]); gd3.showDialog(); if (gd3.wasCanceled()) return; for (int i = 0; i < 5; i++) colorindices[i] = gd3.getNextChoiceIndex(); sp.colorindices = colorindices; sp.nch = 5; sp.dapilast = false; sp.cellwidth = bwidth; sp.cellheight = bheight; sp.init(imps[0], skyimp, objects, areas, arearank, fb, true, spectra, data, mouse); SkyPanel_v3.launch_frame(sp); }