use of uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsFileSettings in project GDSC-SMLM by aherbert.
the class ResultsManager method addFileResults.
private void addFileResults(PeakResultsList resultsList, boolean showDeviations, boolean showEndFrame, boolean showId, boolean showCategory) {
final ResultsFileSettings resultsFileSettings = this.resultsSettings.getResultsFileSettings();
if (!TextUtils.isNullOrEmpty(resultsFileSettings.getResultsFilename())) {
// Remove extension
final String resultsFilename = FileUtils.replaceExtension(resultsFileSettings.getResultsFilename(), ResultsProtosHelper.getExtension(resultsFileSettings.getFileFormat()));
if (fileInput && settings.inputFilename.equals(resultsFilename)) {
IJ.log(TITLE + ": Input and output files are the same, skipping output ...");
return;
}
// Update
this.resultsSettings.getResultsFileSettingsBuilder().setResultsFilename(resultsFilename);
SettingsManager.writeSettings(this.resultsSettings.build());
// Check if file exists
final File file = new File(resultsFilename);
if (file.exists()) {
final YesNoCancelDialog d = new YesNoCancelDialog(IJ.getInstance(), TITLE, "Overwrite existing file?\n" + resultsFilename);
if (!d.yesPressed()) {
return;
}
}
addFileResults(resultsList, resultsFileSettings, resultsFilename, showDeviations, showEndFrame, showId, showCategory);
}
}
use of uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsFileSettings in project GDSC-SMLM by aherbert.
the class ResultsManager method batchSave.
/**
* Batch save a set of results files.
*/
private void batchSave() {
if (MemoryPeakResults.isMemoryEmpty()) {
IJ.error(TITLE, "No localisations in memory");
return;
}
final MultiDialog md = createMultiDialog(TITLE);
md.setSelected(lastSelected.get());
md.setHelpUrl(HelpUrls.getUrl("batch-save-results"));
md.showDialog();
if (md.wasCancelled()) {
return;
}
final List<String> selected = md.getSelectedResults();
if (selected.isEmpty()) {
return;
}
lastSelected.set(selected);
resultsSettings = SettingsManager.readResultsSettings(0).toBuilder();
final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
addFileResultsOptions(gd, resultsSettings, FLAG_RESULTS_DIRECTORY | FLAG_NO_SECTION_HEADER);
gd.addHelp(HelpUrls.getUrl("batch-save-results"));
gd.showDialog();
if (gd.wasCanceled()) {
return;
}
gd.collectOptions();
final ResultsFileSettings.Builder b = resultsSettings.getResultsFileSettingsBuilder();
final String dir = gd.getNextString();
b.setFileFormatValue(gd.getNextChoiceIndex());
b.setResultsDirectory(dir);
SettingsManager.writeSettings(resultsSettings);
if (!new File(dir).exists()) {
IJ.error(TITLE, "Output directory does not exist");
return;
}
final ResultsFileSettings resultsFileSettings = resultsSettings.getResultsFileSettings();
if (resultsFileSettings.getFileFormatValue() <= 0) {
IJ.error(TITLE, "No output file format");
return;
}
int count = 0;
for (final String name : selected) {
final MemoryPeakResults r = MemoryPeakResults.getResults(name);
if (r != null && save(resultsFileSettings, r)) {
count++;
}
}
IJ.showStatus("Saved " + TextUtils.pleural(count, "dataset"));
}
use of uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsFileSettings in project GDSC-SMLM by aherbert.
the class PeakFit method addFileResults.
private void addFileResults(PeakResultsList resultsList) {
final ResultsFileSettings resultsFileSettings = this.resultsSettings.getResultsFileSettings();
if (resultsFileSettings.getFileFormat().getNumber() > 0) {
String resultsFilename = null;
if (resultsFileSettings.getResultsDirectory() != null && new File(resultsFileSettings.getResultsDirectory()).exists()) {
resultsFilename = resultsFileSettings.getResultsDirectory() + File.separatorChar + source.getName() + ".results." + ResultsProtosHelper.getExtension(resultsFileSettings.getFileFormat());
// This is used for running via other code calling PeakFit methods,
// i.e. not as an ImageJ plugin.
} else if (pluginFlags == 0) {
resultsFilename = resultsFileSettings.getResultsFilename();
}
final PeakResults r = ResultsManager.addFileResults(resultsList, resultsFileSettings, resultsFilename, this.resultsSettings.getShowDeviations(), getShowEndFrame(), false, false);
if (r instanceof FilePeakResults) {
final FilePeakResults fr = (FilePeakResults) r;
fr.setSortAfterEnd(Prefs.getThreads() > 1);
}
}
}
Aggregations