Search in sources :

Example 11 with OpenDialog

use of ij.io.OpenDialog in project GDSC-SMLM by aherbert.

the class CreateData method saveImageResults.

private void saveImageResults(MemoryPeakResults results) {
    if (!settings.saveImageResults)
        return;
    String[] path = Utils.decodePath(settings.imageResultsFilename);
    OpenDialog chooser = new OpenDialog("Image_Results_File", path[0], path[1]);
    if (chooser.getFileName() != null) {
        settings.imageResultsFilename = chooser.getDirectory() + chooser.getFileName();
        settings.imageResultsFilename = Utils.replaceExtension(settings.imageResultsFilename, "xls");
        FilePeakResults r = new FilePeakResults(settings.imageResultsFilename, false);
        r.copySettings(results);
        r.setPeakIdColumnName("Frame");
        r.begin();
        r.addAll(results.getResults());
        r.end();
    }
}
Also used : OpenDialog(ij.io.OpenDialog) FilePeakResults(gdsc.smlm.results.FilePeakResults)

Example 12 with OpenDialog

use of ij.io.OpenDialog in project GDSC-SMLM by aherbert.

the class Configuration method mouseClicked.

/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
	 */
public void mouseClicked(MouseEvent e) {
    if (// Double-click
    e.getClickCount() > 1) {
        if (e.getSource() == textConfigFile) {
            String[] path = Utils.decodePath(textConfigFile.getText());
            OpenDialog chooser = new OpenDialog("Configuration_File", path[0], path[1]);
            if (chooser.getFileName() != null) {
                String newFilename = chooser.getDirectory() + chooser.getFileName();
                textConfigFile.setText(newFilename);
            }
        }
    }
}
Also used : OpenDialog(ij.io.OpenDialog)

Example 13 with OpenDialog

use of ij.io.OpenDialog in project GDSC-SMLM by aherbert.

the class CreateData method saveFluorophores.

/**
	 * Save the fluorophores to a text file
	 * 
	 * @param fluorophores
	 */
private void saveFluorophores(List<? extends FluorophoreSequenceModel> fluorophores) {
    if (!settings.saveFluorophores || fluorophores == null)
        return;
    String[] path = Utils.decodePath(settings.fluorophoresFilename);
    OpenDialog chooser = new OpenDialog("Fluorophores_File", path[0], path[1]);
    if (chooser.getFileName() != null) {
        settings.fluorophoresFilename = chooser.getDirectory() + chooser.getFileName();
        settings.fluorophoresFilename = Utils.replaceExtension(settings.fluorophoresFilename, "xls");
        BufferedWriter output = null;
        try {
            output = new BufferedWriter(new FileWriter(settings.fluorophoresFilename));
            output.write(createResultsFileHeader());
            output.write("#Id\tn-Blinks\tStart\tStop\t...");
            output.newLine();
            for (int id = 1; id <= fluorophores.size(); id++) {
                FluorophoreSequenceModel f = fluorophores.get(id - 1);
                StringBuffer sb = new StringBuffer();
                sb.append(f.getId()).append("\t");
                sb.append(f.getNumberOfBlinks()).append("\t");
                for (double[] burst : f.getBurstSequence()) {
                    sb.append(Utils.rounded(burst[0], 3)).append("\t").append(Utils.rounded(burst[1], 3)).append("\t");
                }
                output.write(sb.toString());
                output.newLine();
            }
        } catch (Exception e) {
            // Q. Add better handling of errors?
            e.printStackTrace();
            IJ.log("Failed to save fluorophores to file: " + settings.fluorophoresFilename);
        } finally {
            if (output != null) {
                try {
                    output.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
Also used : FluorophoreSequenceModel(gdsc.smlm.model.FluorophoreSequenceModel) FileWriter(java.io.FileWriter) IOException(java.io.IOException) IOException(java.io.IOException) NullArgumentException(org.apache.commons.math3.exception.NullArgumentException) OpenDialog(ij.io.OpenDialog) BufferedWriter(java.io.BufferedWriter)

Aggregations

OpenDialog (ij.io.OpenDialog)13 IOException (java.io.IOException)5 GlobalSettings (gdsc.smlm.ij.settings.GlobalSettings)3 FilePeakResults (gdsc.smlm.results.FilePeakResults)3 FilterSettings (gdsc.smlm.ij.settings.FilterSettings)2 BufferedWriter (java.io.BufferedWriter)2 FileOutputStream (java.io.FileOutputStream)2 FileWriter (java.io.FileWriter)2 NullArgumentException (org.apache.commons.math3.exception.NullArgumentException)2 XStreamException (com.thoughtworks.xstream.XStreamException)1 UnicodeReader (gdsc.core.utils.UnicodeReader)1 BatchSettings (gdsc.smlm.ij.settings.BatchSettings)1 CreateDataSettings (gdsc.smlm.ij.settings.CreateDataSettings)1 ParameterSettings (gdsc.smlm.ij.settings.ParameterSettings)1 FluorophoreSequenceModel (gdsc.smlm.model.FluorophoreSequenceModel)1 LocalisationModel (gdsc.smlm.model.LocalisationModel)1 AttributePeakResult (gdsc.smlm.results.AttributePeakResult)1 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)1 PeakResult (gdsc.smlm.results.PeakResult)1 Trace (gdsc.smlm.results.Trace)1