use of uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsFileFormat in project GDSC-SMLM by aherbert.
the class PeakResultsReaderTest method checkScannerMatchesNonScanner.
private static void checkScannerMatchesNonScanner(RandomSeed seed, boolean showDeviations, boolean showEndFrame, boolean showId, boolean showPrecision, boolean showCategory, boolean sort) {
final UniformRandomProvider rg = RngUtils.create(seed.getSeed());
final MemoryPeakResults out = createResults(rg, 1000, showDeviations, showEndFrame, showId, showPrecision, showCategory);
final String filename = createFile();
final ResultsFileFormat fileFormat = ResultsFileFormat.TEXT;
writeFile(false, fileFormat, showDeviations, showEndFrame, showId, showPrecision, showCategory, sort, out, filename);
final MemoryPeakResults in = readFile(filename, false);
final MemoryPeakResults in2 = readFile(filename, true);
checkEqual(fileFormat, showDeviations, showEndFrame, showId, showPrecision, showCategory, sort, in, in2);
}
use of uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsFileFormat in project GDSC-SMLM by aherbert.
the class ResultsManager method addFileResultsOptions.
/**
* Adds the file results options.
*
* @param gd the dialog
* @param resultsSettings the results settings
* @param flags the flags
*/
public static void addFileResultsOptions(final ExtendedGenericDialog gd, final Builder resultsSettings, final int flags) {
if (BitFlagUtils.anyNotSet(flags, FLAG_NO_SECTION_HEADER)) {
gd.addMessage("--- File output ---");
}
final ResultsFileSettings.Builder fileSettings = resultsSettings.getResultsFileSettingsBuilder();
gd.addChoice("Results_format", SettingsManager.getResultsFileFormatNames(), fileSettings.getFileFormatValue(), new OptionListener<Integer>() {
@Override
public boolean collectOptions(Integer field) {
fileSettings.setFileFormatValue(field);
return collectOptions(false);
}
@Override
public boolean collectOptions() {
return collectOptions(true);
}
private boolean collectOptions(boolean silent) {
final ResultsFileFormat resultsFileFormat = fileSettings.getFileFormat();
if (!ResultsProtosHelper.isGdsc(resultsFileFormat)) {
return false;
}
final ExtendedGenericDialog egd = new ExtendedGenericDialog(TITLE, null);
if (resultsFileFormat == ResultsFileFormat.TEXT) {
egd.addChoice("File_distance_unit", SettingsManager.getDistanceUnitNames(), fileSettings.getDistanceUnitValue());
egd.addChoice("File_intensity_unit", SettingsManager.getIntensityUnitNames(), fileSettings.getIntensityUnitValue());
egd.addChoice("File_angle_unit", SettingsManager.getAngleUnitNames(), fileSettings.getAngleUnitValue());
egd.addCheckbox("File_show_precision", fileSettings.getShowPrecision());
}
egd.addCheckbox("Show_deviations", resultsSettings.getShowDeviations());
egd.setSilent(silent);
egd.showDialog(true, gd);
if (egd.wasCanceled()) {
return false;
}
fileSettings.setDistanceUnitValue(egd.getNextChoiceIndex());
fileSettings.setIntensityUnitValue(egd.getNextChoiceIndex());
fileSettings.setAngleUnitValue(egd.getNextChoiceIndex());
fileSettings.setShowPrecision(egd.getNextBoolean());
resultsSettings.setShowDeviations(egd.getNextBoolean());
return true;
}
});
if (BitFlagUtils.anySet(flags, FLAG_RESULTS_DIRECTORY)) {
gd.addDirectoryField("Results_directory", fileSettings.getResultsDirectory());
} else if (BitFlagUtils.anySet(flags, FLAG_RESULTS_FILE)) {
gd.addFilenameField("Results_file", fileSettings.getResultsFilename());
} else {
// However we can set the initial directory if we have a results file.
if (fileSettings.getResultsFilename() != null) {
final File dir = new File(fileSettings.getResultsFilename()).getParentFile();
if (dir != null) {
OpenDialog.setDefaultDirectory(dir.getPath());
}
}
gd.addFilenameField("Results_file", "");
}
}
Aggregations