Ejemplo n.º 1
0
 void loadParticleResults(String filename, ResultsTable res) {
   try {
     String line;
     FileReader fr = new FileReader(filename);
     BufferedReader br = new BufferedReader(fr);
     java.lang.String header =
         " 	Intensity	X (px)	Y (px)	X (nm)	Y (nm)	Z (nm)	Left-Width(px)	Right-Width (px)	Up-Height (px)	Down-Height (px)	X Symmetry (%)	Y Symmetry (%)	Width minus Height (px)	Frame Number";
     java.lang.String firstline = br.readLine();
     if (!firstline.contains("X (px)	Y (px)	X (nm)	Y (nm)	Z (nm)")) {
       IJ.error("File does not seam to be a Particles Table file");
       IJ.log("Found header: " + firstline);
       IJ.log("Expecting: " + header);
       return;
     }
     res.reset();
     int counter = 1;
     java.util.concurrent.locks.Lock lock = new java.util.concurrent.locks.ReentrantLock();
     ThreadedLoader tloader = new ThreadedLoader();
     // java.lang.String txt = fr.read();
     while ((line = br.readLine()) != null) {
       tloader = new ThreadedLoader();
       tloader.mysetup(res, lock, line);
       tloader.start();
       IJ.showStatus("Loading particle " + counter + "... sit back and relax.");
       counter++;
     }
     try {
       tloader.join();
     } catch (Exception e) {
       IJ.error("" + e);
     }
     if (res.getCounter() < 5000000) {
       IJ.showStatus("Creating particle table, this should take a few seconds...");
       res.show("Results");
     } else
       IJ.showMessage(
           "Warning",
           "Results table has too many particles, they will not be shown but the data still exists within it\nyou can still use all the plugin functionality or save table changes though the 'Save Particle Table' command.");
     fr.close();
     IJ.showStatus("Done loading table...");
   } catch (FileNotFoundException e) {
     IJ.error("File not found exception" + e);
     return;
   } catch (IOException e) {
     IJ.error("IOException exception" + e);
     return;
   } catch (NumberFormatException e) {
     IJ.error("Number format exception" + e);
     return;
   }
 }
Ejemplo n.º 2
0
  public void run() {
    line.trim();
    elements = line.split("\t");
    if (elements.length < 14) return;

    lock.lock();
    res.incrementCounter();
    res.addValue("Intensity", Double.parseDouble(elements[1]));
    res.addValue("X (px)", Double.parseDouble(elements[2]));
    res.addValue("Y (px)", Double.parseDouble(elements[3]));
    res.addValue("X (nm)", Double.parseDouble(elements[4]));
    res.addValue("Y (nm)", Double.parseDouble(elements[5]));
    res.addValue("Z (nm)", Double.parseDouble(elements[6]));
    res.addValue("Left-StdDev (px)", Double.parseDouble(elements[7]));
    res.addValue("Right-StdDev (px)", Double.parseDouble(elements[8]));
    res.addValue("Up-StdDev (px)", Double.parseDouble(elements[9]));
    res.addValue("Down-StdDev (px)", Double.parseDouble(elements[10]));
    res.addValue("X Symmetry (%)", Double.parseDouble(elements[11]));
    res.addValue("Y Symmetry (%)", Double.parseDouble(elements[12]));
    res.addValue("Width minus Height (px)", Double.parseDouble(elements[13]));
    res.addValue("Frame Number", Double.parseDouble(elements[14]));
    lock.unlock();
  }
Ejemplo n.º 3
0
  public boolean analyseParticles(MyFunctions f) {
    GenericDialog gd = new GenericDialog("Analyse PALM/STORM Particles");
    gd.addNumericField("Minimum SNR", prefs.get("QuickPALM.snr", 5), 2);
    gd.addNumericField("Maximum FWHM (in px)", prefs.get("QuickPALM.fwhm", 4), 0);
    gd.addNumericField("Image plane pixel size (nm)", prefs.get("QuickPALM.pixelsize", 106), 2);
    gd.addCheckbox("Smart SNR", prefs.get("QuickPALM.smartsnr", true));
    gd.addCheckbox(
        "3D PALM (astigmatism) - will require calibration file",
        prefs.get("QuickPALM.is3d", false));
    gd.addCheckbox("Online rendering", prefs.get("QuickPALM.view", true));
    gd.addCheckbox("Attach to running acquisition", prefs.get("QuickPALM.attach", false));
    gd.addCheckbox("Stream particle info directly into file", prefs.get("QuickPALM.stream", true));
    gd.addMessage("\n");
    // -----------------------------------------
    gd.addMessage("-- Online rendering settings (used only if selected) --");
    gd.addMessage("\n");
    gd.addNumericField("Pixel size of rendered image (nm)", 30, 2);
    gd.addNumericField("Accumulate last (0 to accumulate all frames)", 0, 0);
    gd.addNumericField("Update every (frames)", 10, 0);
    // gd.addNumericField("Allow color saturation (%)", 50, 0);
    gd.addMessage("\n");
    // -----------------------------------------
    gd.addMessage("-- Attach to running acquisition settings (used only if selected) --");
    gd.addMessage("\n");
    gd.addStringField(
        "_Image name pattern (NN...NN represents the numerical change)",
        prefs.get("QuickPALM.pattern", "imgNNNNNNNNN.tif"),
        20);
    gd.addNumericField("Start NN...NN with", 0, 0);
    gd.addNumericField("In acquisition max. wait time for new image (ms)", 50, 0);
    gd.addMessage("\n");
    // -----------------------------------------
    gd.addMessage("-- Advanced settings (don't normally need to be changed) --");
    gd.addMessage("\n");
    gd.addNumericField("_Minimum symmetry (%)", prefs.get("QuickPALM.symmetry", 50), 0);
    gd.addNumericField(
        "Local threshold (% maximum intensity)", prefs.get("QuickPALM.lthreshold", 20), 0);
    gd.addNumericField("_Maximum iterations per frame", prefs.get("QuickPALM.maxiter", 1000), 0);
    gd.addNumericField(
        "Threads (each takes ~3*[frame size] in memory)", prefs.get("QuickPALM.nthreads", 50), 0);
    gd.addMessage("\n\nDon't forget to save the table in the end...");

    gd.showDialog();
    if (gd.wasCanceled()) return false;

    snr = (int) gd.getNextNumber();
    prefs.set("QuickPALM.snr", snr);
    fwhm = gd.getNextNumber();
    prefs.set("QuickPALM.fwhm", fwhm);
    pixelsize = gd.getNextNumber();
    prefs.set("QuickPALM.pixelsize", pixelsize);

    smartsnr = gd.getNextBoolean();
    prefs.set("QuickPALM.smartsnr", smartsnr);
    is3d = gd.getNextBoolean();
    prefs.set("QuickPALM.is3d", is3d);
    view = gd.getNextBoolean();
    prefs.set("QuickPALM.view", view);
    attach = gd.getNextBoolean();
    prefs.set("QuickPALM.attach", attach);

    if (gd.getNextBoolean()) {
      f.psave = new ParticleSaver();
      f.psave.setup();
      prefs.set("QuickPALM.stream", true);
    } else prefs.set("QuickPALM.stream", false);
    // --

    magn = pixelsize / gd.getNextNumber();
    viewer_accumulate = (int) gd.getNextNumber();
    viewer_update = (int) gd.getNextNumber();

    // --
    pattern = gd.getNextString().trim();
    prefs.set("QuickPALM.pattern", pattern);
    prefix = pattern.substring(0, pattern.indexOf("N"));
    sufix = pattern.substring(pattern.lastIndexOf("N") + 1, pattern.length());
    nimchars = pattern.split("N").length - 1;
    nimstart = (int) gd.getNextNumber();
    waittime = (int) gd.getNextNumber();

    // --

    symmetry = gd.getNextNumber() / 100;
    prefs.set("QuickPALM.symmetry", symmetry);
    pthrsh = gd.getNextNumber() / 100;
    prefs.set("QuickPALM.lthreshold", pthrsh * 100);
    maxpart = (int) gd.getNextNumber();
    prefs.set("QuickPALM.maxiter", maxpart);
    threads = (int) gd.getNextNumber();
    prefs.set("QuickPALM.nthreads", threads);

    return true;
  }