Search in sources :

Example 1 with TSFPeakResultsWriter

use of gdsc.smlm.results.TSFPeakResultsWriter in project GDSC-SMLM by aherbert.

the class PeakFit method addFileResults.

private void addFileResults(PeakResultsList resultsList) {
    String filename = null;
    if (resultsSettings.resultsDirectory != null && new File(resultsSettings.resultsDirectory).exists()) {
        filename = resultsSettings.resultsDirectory + File.separatorChar + source.getName() + ".results." + resultsSettings.getResultsFileFormat().getExtension();
    } else if (resultsSettings.resultsFilename != null && resultsSettings.resultsFilename.length() > 0) {
        filename = resultsSettings.resultsFilename;
    }
    if (filename != null) {
        PeakResults r;
        switch(resultsSettings.getResultsFileFormat()) {
            case GDSC_BINARY:
                r = new BinaryFilePeakResults(filename, resultsSettings.showDeviations);
                break;
            case GDSC_TEXT:
                r = new FilePeakResults(filename, resultsSettings.showDeviations);
                break;
            case MALK:
                r = new MALKFilePeakResults(resultsSettings.resultsFilename);
                break;
            case TSF:
                r = new TSFPeakResultsWriter(resultsSettings.resultsFilename);
                break;
            default:
                throw new RuntimeException("Unsupported file format: " + resultsSettings.getResultsFileFormat());
        }
        if (r instanceof FilePeakResults) {
            FilePeakResults fr = (FilePeakResults) r;
            fr.setSortAfterEnd(Prefs.getThreads() > 1);
            fr.setPeakIdColumnName("Frame");
        }
        resultsList.addOutput(r);
    }
}
Also used : MALKFilePeakResults(gdsc.smlm.results.MALKFilePeakResults) BinaryFilePeakResults(gdsc.smlm.results.BinaryFilePeakResults) TSFPeakResultsWriter(gdsc.smlm.results.TSFPeakResultsWriter) PeakResults(gdsc.smlm.results.PeakResults) IJTablePeakResults(gdsc.smlm.ij.results.IJTablePeakResults) MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults) IJImagePeakResults(gdsc.smlm.ij.results.IJImagePeakResults) BinaryFilePeakResults(gdsc.smlm.results.BinaryFilePeakResults) MALKFilePeakResults(gdsc.smlm.results.MALKFilePeakResults) FilePeakResults(gdsc.smlm.results.FilePeakResults) File(java.io.File) BinaryFilePeakResults(gdsc.smlm.results.BinaryFilePeakResults) MALKFilePeakResults(gdsc.smlm.results.MALKFilePeakResults) FilePeakResults(gdsc.smlm.results.FilePeakResults)

Example 2 with TSFPeakResultsWriter

use of gdsc.smlm.results.TSFPeakResultsWriter in project GDSC-SMLM by aherbert.

the class ResultsManager method addFileResults.

private void addFileResults(PeakResultsList resultsList, boolean showDeviations, boolean showEndFrame, boolean showId) {
    if (resultsSettings.resultsFilename != null && resultsSettings.resultsFilename.length() > 0) {
        // Remove extension
        resultsSettings.resultsFilename = Utils.replaceExtension(resultsSettings.resultsFilename, resultsSettings.getResultsFileFormat().getExtension());
        if (fileInput && inputFilename.equals(resultsSettings.resultsFilename)) {
            IJ.log(TITLE + ": Input and output files are the same, skipping output ...");
            return;
        }
        // Check if file exists
        File file = new File(resultsSettings.resultsFilename);
        if (file.exists()) {
            YesNoCancelDialog d = new YesNoCancelDialog(IJ.getInstance(), TITLE, "Overwrite existing file?\n" + resultsSettings.resultsFilename);
            if (!d.yesPressed())
                return;
        }
        File parent = file.getParentFile();
        if (parent != null && parent.exists()) {
            PeakResults r;
            switch(resultsSettings.getResultsFileFormat()) {
                case GDSC_BINARY:
                    r = new BinaryFilePeakResults(resultsSettings.resultsFilename, showDeviations, showEndFrame, showId);
                    break;
                case GDSC_TEXT:
                    r = new FilePeakResults(resultsSettings.resultsFilename, showDeviations, showEndFrame, showId);
                    break;
                case MALK:
                    r = new MALKFilePeakResults(resultsSettings.resultsFilename);
                    break;
                case TSF:
                    r = new TSFPeakResultsWriter(resultsSettings.resultsFilename);
                    break;
                default:
                    throw new RuntimeException("Unsupported file format: " + resultsSettings.getResultsFileFormat());
            }
            if (r instanceof FilePeakResults) {
                FilePeakResults fr = (FilePeakResults) r;
                fr.setPeakIdColumnName("Frame");
            }
            resultsList.addOutput(r);
        }
    }
}
Also used : MALKFilePeakResults(gdsc.smlm.results.MALKFilePeakResults) BinaryFilePeakResults(gdsc.smlm.results.BinaryFilePeakResults) TSFPeakResultsWriter(gdsc.smlm.results.TSFPeakResultsWriter) PeakResults(gdsc.smlm.results.PeakResults) IJImagePeakResults(gdsc.smlm.ij.results.IJImagePeakResults) IJTablePeakResults(gdsc.smlm.ij.results.IJTablePeakResults) MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults) BinaryFilePeakResults(gdsc.smlm.results.BinaryFilePeakResults) MALKFilePeakResults(gdsc.smlm.results.MALKFilePeakResults) FilePeakResults(gdsc.smlm.results.FilePeakResults) YesNoCancelDialog(ij.gui.YesNoCancelDialog) File(java.io.File) BinaryFilePeakResults(gdsc.smlm.results.BinaryFilePeakResults) MALKFilePeakResults(gdsc.smlm.results.MALKFilePeakResults) FilePeakResults(gdsc.smlm.results.FilePeakResults)

Aggregations

IJImagePeakResults (gdsc.smlm.ij.results.IJImagePeakResults)2 IJTablePeakResults (gdsc.smlm.ij.results.IJTablePeakResults)2 BinaryFilePeakResults (gdsc.smlm.results.BinaryFilePeakResults)2 FilePeakResults (gdsc.smlm.results.FilePeakResults)2 MALKFilePeakResults (gdsc.smlm.results.MALKFilePeakResults)2 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)2 PeakResults (gdsc.smlm.results.PeakResults)2 TSFPeakResultsWriter (gdsc.smlm.results.TSFPeakResultsWriter)2 File (java.io.File)2 YesNoCancelDialog (ij.gui.YesNoCancelDialog)1