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);
 }
  public void run(String arg) {
    ImagePlus imp = WindowManager.getCurrentImage();
    Calibration cal = imp.getCalibration();
    GenericDialog gd = new GenericDialog("Options");
    int subsize = 32;
    gd.addNumericField("Subregion Size (pixels)?", subsize, 0);
    int stepsize = 16;
    gd.addNumericField("Step Size?", stepsize, 0);
    int shift = 3;
    gd.addNumericField("STICS temporal Shift?", shift, 0);
    float xoffset = 0.0f;
    gd.addNumericField("X_Offset", xoffset, 5, 15, null);
    float yoffset = 0.0f;
    gd.addNumericField("Y_Offset", yoffset, 5, 15, null);
    float multiplier = 8.0f;
    gd.addNumericField("Velocity Multiplier", multiplier, 5, 15, null);
    float ftime = 1.0f;
    gd.addNumericField("Frame_Time(min)", ftime, 5, 15, null);
    float scaling = (float) cal.pixelWidth;
    gd.addNumericField("Pixel_Size(um)", scaling, 5, 15, null);
    boolean norm = true;
    gd.addCheckbox("Normalize_Vector_lengths?", norm);
    boolean centered = true;
    gd.addCheckbox("Center_Vectors?", centered);
    float magthresh = 0.0f;
    gd.addNumericField("Magnitude_Threshhold?", magthresh, 5, 15, null);
    int rlength = 10;
    gd.addNumericField("Running_avg_length", rlength, 0);
    int inc = 5;
    gd.addNumericField("Start_frame_increment", inc, 0);
    gd.showDialog();
    if (gd.wasCanceled()) {
      return;
    }
    subsize = (int) gd.getNextNumber();
    stepsize = (int) gd.getNextNumber();
    shift = (int) gd.getNextNumber();
    xoffset = (float) gd.getNextNumber();
    yoffset = (float) gd.getNextNumber();
    multiplier = (float) gd.getNextNumber();
    ftime = (float) gd.getNextNumber();
    scaling = (float) gd.getNextNumber();
    norm = gd.getNextBoolean();
    centered = gd.getNextBoolean();
    magthresh = (float) gd.getNextNumber();
    rlength = (int) gd.getNextNumber();
    inc = (int) gd.getNextNumber();

    int width = imp.getWidth();
    int xregions = 1 + (int) (((float) width - (float) subsize) / (float) stepsize);
    int newwidth = xregions * subsize;
    int height = imp.getHeight();
    int yregions = 1 + (int) (((float) height - (float) subsize) / (float) stepsize);
    int newheight = yregions * subsize;
    ImageStack stack = imp.getStack();
    int slices = imp.getNSlices();
    int channels = imp.getNChannels();
    int frames = imp.getNFrames();
    if (frames == 1) {
      frames = slices;
      slices = 1;
    }

    Roi roi = imp.getRoi();
    if (roi == null) {
      roi = new Roi(0, 0, width, height);
    }

    STICS_map map = new STICS_map(subsize, stepsize);
    Object[] tseries = jutils.get3DTSeries(stack, 0, 0, frames, slices, channels);
    map.update_STICS_map(tseries, width, height, 0, rlength, roi.getPolygon(), shift);
    FloatProcessor fp =
        map.get_map(scaling, ftime, stepsize, centered, norm, multiplier, stepsize, magthresh);
    ImageStack vector_stack = new ImageStack(fp.getWidth(), fp.getHeight());
    vector_stack.addSlice("", fp);
    float[][] vel = map.get_scaled_velocities(scaling, ftime, stepsize);
    ImageStack velstack = new ImageStack(map.xregions, map.yregions);
    velstack.addSlice("", vel[0]);
    velstack.addSlice("", vel[1]);
    int velframes = 2;
    IJ.showStatus("frame " + 0 + " calculated");
    for (int i = inc; i < (frames - rlength); i += inc) {
      map.update_STICS_map(tseries, width, height, i, rlength, roi.getPolygon(), shift);
      FloatProcessor fp2 =
          map.get_map(scaling, ftime, stepsize, centered, norm, multiplier, stepsize, magthresh);
      vector_stack.addSlice("", fp2);
      vel = map.get_scaled_velocities(scaling, ftime, stepsize);
      velstack.addSlice("", vel[0]);
      velstack.addSlice("", vel[1]);
      velframes += 2;
      IJ.showStatus("frame " + i + " calculated");
    }
    (new ImagePlus("STICS Vectors", vector_stack)).show();
    ImagePlus imp3 = new ImagePlus("Velocities", velstack);
    imp3.setOpenAsHyperStack(true);
    imp3.setDimensions(2, 1, velframes / 2);
    new CompositeImage(imp3, CompositeImage.COLOR).show();
  }