use of uk.ac.sussex.gdsc.smlm.results.BinaryFilePeakResults in project GDSC-SMLM by aherbert.
the class ResultsManager method addFileResults.
/**
* Adds the file results.
*
* @param resultsList the results list
* @param resultsSettings the results settings
* @param resultsFilename the results filename
* @param showDeviations the show deviations
* @param showEndFrame the show end frame
* @param showId the show id
* @param showCategory the show category
* @return the peak results
*/
public static PeakResults addFileResults(PeakResultsList resultsList, ResultsFileSettings resultsSettings, String resultsFilename, boolean showDeviations, boolean showEndFrame, boolean showId, boolean showCategory) {
if (resultsSettings.getFileFormatValue() > 0 && resultsFilename != null) {
final File file = new File(resultsFilename);
final File parent = file.getParentFile();
if (parent != null && parent.exists()) {
PeakResults results;
switch(resultsSettings.getFileFormat()) {
case BINARY:
results = new BinaryFilePeakResults(resultsFilename, showDeviations, showEndFrame, showId, resultsSettings.getShowPrecision(), showCategory);
break;
case TEXT:
final TextFilePeakResults f = new TextFilePeakResults(resultsFilename, showDeviations, showEndFrame, showId, resultsSettings.getShowPrecision(), showCategory);
f.setDistanceUnit(resultsSettings.getDistanceUnit());
f.setIntensityUnit(resultsSettings.getIntensityUnit());
f.setAngleUnit(resultsSettings.getAngleUnit());
f.setComputePrecision(true);
results = f;
break;
case MALK:
results = new MalkFilePeakResults(resultsFilename);
break;
case TSF:
results = new TsfPeakResultsWriter(resultsFilename);
break;
default:
throw new IllegalArgumentException("Unsupported file format: " + resultsSettings.getFileFormat());
}
resultsList.addOutput(results);
return results;
}
}
return null;
}
use of uk.ac.sussex.gdsc.smlm.results.BinaryFilePeakResults in project GDSC-SMLM by aherbert.
the class ResultsManager method save.
private static boolean save(ResultsFileSettings resultsSettings, MemoryPeakResults source) {
// Assume the directory exists
String resultsFilename;
try {
resultsFilename = new File(resultsSettings.getResultsDirectory(), source.getName() + ".results." + ResultsProtosHelper.getExtension(resultsSettings.getFileFormat())).getCanonicalPath();
} catch (final IOException ex) {
return false;
}
PeakResults results;
switch(resultsSettings.getFileFormat()) {
case BINARY:
results = new BinaryFilePeakResults(resultsFilename, source.hasDeviations(), source.hasEndFrame(), source.hasId(), resultsSettings.getShowPrecision());
break;
case TEXT:
final TextFilePeakResults f = new TextFilePeakResults(resultsFilename, source.hasDeviations(), source.hasEndFrame(), source.hasId(), resultsSettings.getShowPrecision());
f.setDistanceUnit(resultsSettings.getDistanceUnit());
f.setIntensityUnit(resultsSettings.getIntensityUnit());
f.setAngleUnit(resultsSettings.getAngleUnit());
f.setComputePrecision(true);
results = f;
break;
case MALK:
results = new MalkFilePeakResults(resultsFilename);
break;
case TSF:
results = new TsfPeakResultsWriter(resultsFilename);
break;
default:
throw new IllegalArgumentException("Unsupported file format: " + resultsSettings.getFileFormat());
}
results.copySettings(source);
results.begin();
results.addAll(source.toArray());
results.end();
ImageJUtils.log("Saved %s to %s", source.getName(), resultsFilename);
return true;
}
Aggregations