use of uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageSettings in project GDSC-SMLM by aherbert.
the class PulseActivationAnalysis method showPulseAnalysisDialog.
private boolean showPulseAnalysisDialog() {
final NonBlockingExtendedGenericDialog gd = new NonBlockingExtendedGenericDialog(title);
gd.addMessage("Plot molecules activated after a pulse");
String[] correctionNames = null;
String[] assignmentNames = null;
if (settings.channels > 1) {
if (settings.channels == 2) {
gd.addNumericField("Crosstalk_21", settings.ct[Settings.C21], 3);
gd.addNumericField("Crosstalk_12", settings.ct[Settings.C12], 3);
} else {
for (int i = 0; i < Settings.ctNames.length; i++) {
gd.addNumericField("Crosstalk_" + Settings.ctNames[i], settings.ct[i], 3);
}
}
gd.addNumericField("Local_density_radius", settings.densityRadius, 0, 6, "nm");
gd.addSlider("Min_neighbours", 0, 15, settings.minNeighbours);
correctionNames = SettingsManager.getNames((Object[]) Settings.specificCorrection);
gd.addChoice("Crosstalk_correction", correctionNames, correctionNames[settings.specificCorrectionIndex]);
for (int c = 1; c <= settings.channels; c++) {
gd.addSlider("Crosstalk_correction_cutoff_C" + c + " (%)", 0, 100, settings.specificCorrectionCutoff[c - 1]);
}
assignmentNames = SettingsManager.getNames((Object[]) Settings.nonSpecificCorrection);
gd.addChoice("Nonspecific_assigment", assignmentNames, assignmentNames[settings.nonSpecificCorrectionIndex]);
gd.addSlider("Nonspecific_assignment_cutoff (%)", 0, 100, settings.nonSpecificCorrectionCutoff);
}
resultsSettingsBuilder = SettingsManager.readResultsSettings(0).toBuilder();
ResultsManager.addImageResultsOptions(gd, resultsSettingsBuilder, ResultsManager.FLAG_IMAGE_NO_LUT);
final Checkbox previewCheckBox = gd.addAndGetCheckbox("Preview", false);
final String buttonLabel = "Draw loop";
gd.addMessage("Click '" + buttonLabel + "' to draw the current ROIs in a loop view");
gd.addAndGetButton(buttonLabel, this::actionPerformed);
magnificationChoice = gd.addAndGetChoice("Magnification", Settings.magnifications, settings.magnification);
gd.addDialogListener(this::dialogItemChanged);
gd.addOptionCollectedListener(event -> addWork(previewCheckBox.getState()));
gd.addHelp(HelpUrls.getUrl(helpKey));
gd.showDialog();
if (gd.wasCanceled()) {
return false;
}
// The dialog was OK'd so run if work was staged in the workflow.
if (workflow.isStaged()) {
workflow.runStaged();
}
// Record options for a macro since the NonBlockingDialog does not
if (Recorder.record) {
if (settings.channels > 1) {
// Suppress null warnings
if (correctionNames == null || assignmentNames == null) {
throw new IllegalStateException();
}
if (settings.channels == 2) {
Recorder.recordOption("Crosstalk_21", Double.toString(settings.ct[Settings.C21]));
Recorder.recordOption("Crosstalk_12", Double.toString(settings.ct[Settings.C12]));
} else {
for (int i = 0; i < Settings.ctNames.length; i++) {
Recorder.recordOption("Crosstalk_" + Settings.ctNames[i], Double.toString(settings.ct[i]));
}
}
Recorder.recordOption("Local_density_radius", Double.toString(settings.densityRadius));
Recorder.recordOption("Min_neighbours", Integer.toString(settings.minNeighbours));
Recorder.recordOption("Crosstalk_correction", correctionNames[settings.specificCorrectionIndex]);
for (int c = 1; c <= settings.channels; c++) {
Recorder.recordOption("Crosstalk_correction_cutoff_C" + c, Double.toString(settings.specificCorrectionCutoff[c - 1]));
}
Recorder.recordOption("Nonspecific_assigment", assignmentNames[settings.nonSpecificCorrectionIndex]);
Recorder.recordOption("Nonspecific_assignment_cutoff (%)", Double.toString(settings.nonSpecificCorrectionCutoff));
}
final ResultsImageSettings s = resultsSettingsBuilder.getResultsImageSettings();
Recorder.recordOption("Image", SettingsManager.getResultsImageTypeNames()[s.getImageTypeValue()]);
if (s.getWeighted()) {
Recorder.recordOption("Weighted");
}
if (s.getEqualised()) {
Recorder.recordOption("Equalised");
}
Recorder.recordOption("Image_Precision", Double.toString(s.getAveragePrecision()));
Recorder.recordOption("Image_Size_mode", SettingsManager.getResultsImageSizeModeNames()[s.getImageSizeModeValue()]);
Recorder.recordOption("Image_Scale", Double.toString(s.getScale()));
Recorder.recordOption("Image_Size", Integer.toString(s.getImageSize()));
Recorder.recordOption("Image_Pixel_size", Double.toString(s.getPixelSize()));
}
SettingsManager.writeSettings(resultsSettingsBuilder);
return true;
}
use of uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageSettings in project GDSC-SMLM by aherbert.
the class ResultsManager method addImageResults.
/**
* Adds the image results.
*
* <p>Note: This always uses {@link ResultsImageMode#IMAGE_ADD}.
*
* @param resultsList the results list
* @param resultsSettings the results settings
* @param bounds the bounds
* @param flags the flags
*/
public static void addImageResults(PeakResultsList resultsList, ResultsImageSettings resultsSettings, Rectangle bounds, int flags) {
if (resultsSettings.getImageTypeValue() > 0) {
final ResultsImageSettings.Builder builder = resultsSettings.toBuilder();
builder.setImageMode(ResultsImageMode.IMAGE_ADD);
final ImageJImagePeakResults image = ImagePeakResultsFactory.createPeakResultsImage(builder, resultsList.getName(), bounds, resultsList.getNmPerPixel());
// Rolling window size is set by the factory method. Unset it if not using extra options.
if (!BitFlagUtils.anySet(flags, FLAG_EXTRA_OPTIONS)) {
image.setRollingWindowSize(0);
}
image.setRepaintDelay(2000);
resultsList.addOutput(image);
}
}
use of uk.ac.sussex.gdsc.smlm.data.config.ResultsProtos.ResultsImageSettings in project GDSC-SMLM by aherbert.
the class PulseActivationAnalysis method addImageResults.
private void addImageResults(PeakResultsList resultsList, String title, Rectangle bounds, double nmPerPixel, ResultsImageSettings imageSettings) {
if (imageSettings.getImageTypeValue() > 0) {
final ResultsImageSettings.Builder builder = imageSettings.toBuilder();
builder.setImageMode(ResultsImageMode.IMAGE_ADD);
final ImageJImagePeakResults image = ImagePeakResultsFactory.createPeakResultsImage(builder, title, bounds, nmPerPixel);
image.setLiveImage(false);
image.setDisplayImage(settings.channels == 1);
resultsList.addOutput(image);
}
}
Aggregations