コード例 #1
0
  public void run(String arg) {
    GenericDialog gd = new GenericDialog("Options");
    gd.addCheckbox("Acceptor_First", true);
    gd.showDialog();
    if (gd.wasCanceled()) return;
    boolean a1 = gd.getNextBoolean();
    int asp = 0;
    int dsp = 1;
    int aop = 2;
    int dop = 3;
    int atp = 4;
    int dtp = 5;
    if (!a1) {
      asp = 1;
      dsp = 0;
      aop = 3;
      dop = 2;
      atp = 5;
      dtp = 4;
    }
    ImageWindow iw = WindowManager.getCurrentWindow();
    float[][] xvals = (float[][]) jutils.runPW4VoidMethod(iw, "getXValues");
    float[][] yvals = (float[][]) jutils.runPW4VoidMethod(iw, "getYValues");
    int[] npts = (int[]) jutils.runPW4VoidMethod(iw, "getNpts");
    int maxpts = (int) jstatistics.getstatistic("Max", npts, null);
    int nsets = npts.length / 6;
    float[][] rtxvals = new float[nsets][maxpts];
    float[][] rtavals = new float[nsets][maxpts];
    float[][] rtdvals = new float[nsets][maxpts];
    int[] rtnpts = new int[nsets];
    int fretlength = 10;
    float[][] stfretvals = new float[nsets][fretlength];
    float[][] offfretvals = new float[nsets][fretlength];
    TextWindow tw = jutils.selectTable("DNA Damage FRET");
    if (tw == null)
      tw =
          new TextWindow(
              "DNA Damage FRET",
              "title\tacceptor\tdonor\testripe\teoff\tmaxart\tmaxdrt",
              "",
              400,
              200);
    // note that st stands for stripe and off is for areas off the damage stripe
    for (int i = 0; i < npts.length / 6; i++) {
      int len = npts[i * 6];
      int damageindex = findbleach(yvals[i * 6 + dsp], len);
      int fretindex = findbleach(yvals[i * 6 + atp], len);
      IJ.log("set " + i + " damage pos = " + damageindex + " , fret pos = " + fretindex);
      int predamagestart = damageindex - 4;
      int prefretstart = fretindex - 5;
      float staccpredam = getavg(yvals[i * 6 + asp], len, predamagestart, damageindex - 1);
      float stdonpredam = getavg(yvals[i * 6 + dsp], len, predamagestart, damageindex - 1);
      float nucaccpredam = getavg(yvals[i * 6 + atp], len, predamagestart, damageindex - 1);
      float nucdonpredam = getavg(yvals[i * 6 + dtp], len, predamagestart, damageindex - 1);
      float stdonprefret = getavg(yvals[i * 6 + dsp], len, prefretstart, fretindex - 2);
      float stdonafret = getavg(yvals[i * 6 + dsp], len, fretindex, fretindex + 3);
      float offdonprefret = getavg(yvals[i * 6 + dop], len, prefretstart, fretindex - 2);
      float offdonafret = getavg(yvals[i * 6 + dop], len, fretindex, fretindex + 3);
      float estripe = 1.0f - stdonprefret / stdonafret;
      float eoff = 1.0f - offdonprefret / offdonafret;
      rtnpts[i] = len;
      for (int j = 0; j < len; j++) {
        rtxvals[i][j] = j - damageindex - 1;
        rtavals[i][j] =
            (yvals[i * 6 + asp][j] / staccpredam) / (yvals[i * 6 + atp][j] / nucaccpredam);
        rtdvals[i][j] =
            (yvals[i * 6 + dsp][j] / stdonpredam) / (yvals[i * 6 + dtp][j] / nucdonpredam);
      }
      float[] smart = (float[]) algutils.get_subarray(rtavals[i], 0, fretindex);
      float[] smdrt = (float[]) algutils.get_subarray(rtdvals[i], 0, fretindex);
      jsmooth.blur1D(smart, 2.0f);
      jsmooth.blur1D(smdrt, 2.0f);
      float maxart = 0.0f;
      float maxdrt = 0.0f;
      for (int j = 0; j < fretindex - 2; j++) {
        if (smart[j] > maxart) maxart = smart[j];
        if (smdrt[j] > maxdrt) maxdrt = smdrt[j];
      }

      stfretvals[i] = getregion(yvals[i * 6 + dsp], len, prefretstart, fretlength);
      offfretvals[i] = getregion(yvals[i * 6 + dop], len, prefretstart, fretlength);
      tw.append(
          iw.getTitle()
              + "-"
              + (i + 1)
              + "\t"
              + staccpredam
              + "\t"
              + stdonpredam
              + "\t"
              + estripe
              + "\t"
              + eoff
              + "\t"
              + maxart
              + "\t"
              + maxdrt);
    }
    new PlotWindow4("Stripe_FRET_profiles", "time", "intensity", stfretvals, null).draw();
    new PlotWindow4("OffStripe_FRET_profiles", "time", "intensity", offfretvals, null).draw();
    new PlotWindow4("Acc_Rt_profiles", "time", "intensity", rtxvals, rtavals, rtnpts).draw();
    new PlotWindow4("Don_Rt_profiles", "time", "intensity", rtxvals, rtdvals, rtnpts).draw();
  }
コード例 #2
0
  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();
  }