use of uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings in project GDSC-SMLM by aherbert.
the class ResultsManager method showInteractiveTable.
/**
* Show interactive table.
*
* @param results the results
* @param resultsTableSettings the results table settings
*/
public static void showInteractiveTable(MemoryPeakResults results, ResultsTableSettings resultsTableSettings) {
final PeakResultTableModel model = new PeakResultTableModel(results, true, resultsTableSettings);
final PeakResultTableModelFrame frame = new PeakResultTableModelFrame(model);
frame.setTitle(results.getName());
frame.setVisible(true);
// Save changes to the interactive table settings
model.addSettingsUpdatedAction(s -> {
// Load the latest settings and save the table options
final ResultsSettings.Builder resultsSettings = SettingsManager.readResultsSettings(0).toBuilder();
resultsSettings.setResultsTableSettings(s);
SettingsManager.writeSettings(resultsSettings.build());
});
}
use of uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsSettings in project GDSC-SMLM by aherbert.
the class ResultsManager method showDialog.
private boolean showDialog() {
final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addHelp(HelpUrls.getUrl("results-manager"));
settings = Settings.load();
resultsSettings = SettingsManager.readResultsSettings(0).toBuilder();
gd.addMessage("Read the Peak Results and output to a new format");
gd.addMessage("Select the Peak Results");
addInput(gd, INPUT_NAME, settings.inputOption, new FilenameLoadOption[] { new FilenameLoadOption(settings.inputFilename) }, InputSource.MEMORY, InputSource.FILE);
final Choice inputChoice = gd.getLastChoice();
addTableResultsOptions(gd, resultsSettings, FLAG_TABLE_FORMAT);
addImageResultsOptions(gd, resultsSettings);
addFileResultsOptions(gd, resultsSettings, 0);
addInMemoryResultsOptions(gd, resultsSettings);
final Label messageLabel = (Label) gd.getMessage();
final Checkbox saveCheckbox = gd.getLastCheckbox();
// Hide the in-memory settings if the input is not a file
if (ImageJUtils.isShowGenericDialog()) {
final Label saveLabel = gd.getLastLabel();
final ItemListener listener = event -> {
final boolean enable = INPUT_FILE.equals(inputChoice.getSelectedItem());
if (enable != messageLabel.isVisible()) {
messageLabel.setVisible(enable);
saveCheckbox.setVisible(enable);
saveLabel.setVisible(enable);
gd.pack();
}
};
// Run once to set up
listener.itemStateChanged(null);
inputChoice.addItemListener(listener);
}
gd.showDialog();
if (gd.wasCanceled()) {
return false;
}
settings.inputOption = ResultsManager.getInputSource(gd);
settings.inputFilename = gd.getNextString();
resultsSettings.getResultsTableSettingsBuilder().setResultsTableFormatValue(gd.getNextChoiceIndex());
resultsSettings.getResultsImageSettingsBuilder().setImageTypeValue(gd.getNextChoiceIndex());
resultsSettings.getResultsFileSettingsBuilder().setFileFormatValue(gd.getNextChoiceIndex());
resultsSettings.getResultsFileSettingsBuilder().setResultsFilename(gd.getNextString());
resultsSettings.getResultsInMemorySettingsBuilder().setInMemory(gd.getNextBoolean());
gd.collectOptions();
// Check arguments
try {
final ResultsImageSettings.Builder imageSettings = resultsSettings.getResultsImageSettingsBuilder();
if (imageSettings.getImageType() == ResultsImageType.DRAW_INTENSITY_AVERAGE_PRECISION || imageSettings.getImageType() == ResultsImageType.DRAW_LOCALISATIONS_AVERAGE_PRECISION) {
ParameterUtils.isAboveZero("Image precision", imageSettings.getAveragePrecision());
}
ParameterUtils.isAboveZero("Image scale", imageSettings.getScale());
if (extraOptions) {
ParameterUtils.isPositive("Image rolling window", imageSettings.getRollingWindowSize());
}
} catch (final IllegalArgumentException ex) {
IJ.error(TITLE, ex.getMessage());
return false;
}
settings.save();
SettingsManager.writeSettings(resultsSettings.build());
return true;
}
Aggregations