Search in sources :

Example 16 with DirectFilter

use of uk.ac.sussex.gdsc.smlm.results.filter.DirectFilter in project GDSC-SMLM by aherbert.

the class BenchmarkFilterAnalysis method findOptimum.

@Nullable
@Override
public SearchResult<FilterScore> findOptimum(double[][] points) {
    gaIteration++;
    SimpleFilterScore max = filterScoreOptimum;
    final FilterScoreResult[] scoreResults = scoreFilters(setStrength(new FilterSet(searchSpaceToFilters(points))), false);
    if (scoreResults == null) {
        return null;
    }
    for (int index = 0; index < scoreResults.length; index++) {
        final FilterScoreResult scoreResult = scoreResults[index];
        final SimpleFilterScore result = new SimpleFilterScore(scoreResult, true, scoreResult.criteria >= minCriteria);
        if (result.compareTo(max) < 0) {
            max = result;
        }
    }
    filterScoreOptimum = max;
    // Add the best filter to the table
    // This filter may not have been part of the scored subset so use the entire results set for
    // reporting
    final DirectFilter filter = max.result.filter;
    final FractionClassificationResult r = scoreFilter(filter, defaultMinimalFilter, gaResultsList, coordinateStore);
    final StringBuilder text = createResult(filter, r);
    add(text, gaIteration);
    gaWindow.accept(text.toString());
    return new SearchResult<>(filter.getParameters(), max);
}
Also used : FilterSet(uk.ac.sussex.gdsc.smlm.results.filter.FilterSet) IDirectFilter(uk.ac.sussex.gdsc.smlm.results.filter.IDirectFilter) DirectFilter(uk.ac.sussex.gdsc.smlm.results.filter.DirectFilter) FractionClassificationResult(uk.ac.sussex.gdsc.core.match.FractionClassificationResult) SearchResult(uk.ac.sussex.gdsc.smlm.search.SearchResult) Nullable(uk.ac.sussex.gdsc.core.annotation.Nullable)

Example 17 with DirectFilter

use of uk.ac.sussex.gdsc.smlm.results.filter.DirectFilter in project GDSC-SMLM by aherbert.

the class PeakFit method configureSmartFilter.

/**
 * Show a dialog to configure the smart filter.
 *
 * <p>If the fit configuration isSmartFilter is not enabled then this method returns true. If it
 * is enabled then a dialog is shown to input the configuration for a smart filter. If no valid
 * filter can be created from the input then the method returns false.
 *
 * <p>Note: If the smart filter is successfully configured then the user may want to disable the
 * standard fit validation.
 *
 * @param fitConfig the fit config
 * @return true, if successful
 */
public static boolean configureSmartFilter(final FitConfiguration fitConfig) {
    if (!fitConfig.isSmartFilter()) {
        return true;
    }
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    String xml = fitConfig.getSmartFilterString();
    if (TextUtils.isNullOrEmpty(xml)) {
        xml = fitConfig.getDefaultSmartFilterXml();
    }
    gd.addMessage("Smart filter (used to pick optimum results during fitting)");
    gd.addTextAreas(uk.ac.sussex.gdsc.core.utils.XmlUtils.convertQuotes(xml), null, 8, 60);
    // Add message about precision filtering
    gd.addMessage(TextUtils.wrap("Note: Smart filters using precision may require a local background level. " + "Ensure the camera calibration is correct including any bias.", 80));
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    xml = gd.getNextText();
    final Filter f = Filter.fromXml(xml);
    if (!(f instanceof DirectFilter)) {
        return false;
    }
    fitConfig.setDirectFilter((DirectFilter) f);
    return true;
}
Also used : Filter(uk.ac.sussex.gdsc.smlm.results.filter.Filter) DirectFilter(uk.ac.sussex.gdsc.smlm.results.filter.DirectFilter) PlugInFilter(ij.plugin.filter.PlugInFilter) SpotFilter(uk.ac.sussex.gdsc.smlm.filters.SpotFilter) DirectFilter(uk.ac.sussex.gdsc.smlm.results.filter.DirectFilter) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)

Example 18 with DirectFilter

use of uk.ac.sussex.gdsc.smlm.results.filter.DirectFilter in project GDSC-SMLM by aherbert.

the class FitConfiguration method updateFilterSettings.

private void updateFilterSettings() {
    updateMinSignal();
    updatePrecisionThreshold();
    updateCoordinateShift();
    updateWidthThreshold();
    updateMinWidthThreshold();
    updateZFilter();
    // Recreate the smart filter
    if (!filterSettings.getSmartFilter()) {
        return;
    }
    final String xml = filterSettings.getSmartFilterString();
    if (TextUtils.isNullOrEmpty(xml)) {
        return;
    }
    final Filter f = Filter.fromXml(xml);
    if (f == null || !(f instanceof DirectFilter)) {
        // Throw to ensure the filter is OK
        throw new IllegalStateException("Unrecognised smart filter: " + xml);
    // or
    // setDirectFilter(null);
    }
    // This updates the SmartFilter flag and the SmartFilterString.
    // Just set the filter directly
    // setDirectFilter((DirectFilter) f);
    this.directFilter = (DirectFilter) f;
}
Also used : Filter(uk.ac.sussex.gdsc.smlm.results.filter.Filter) IDirectFilter(uk.ac.sussex.gdsc.smlm.results.filter.IDirectFilter) MultiFilter(uk.ac.sussex.gdsc.smlm.results.filter.MultiFilter) DirectFilter(uk.ac.sussex.gdsc.smlm.results.filter.DirectFilter) IDirectFilter(uk.ac.sussex.gdsc.smlm.results.filter.IDirectFilter) DirectFilter(uk.ac.sussex.gdsc.smlm.results.filter.DirectFilter)

Aggregations

DirectFilter (uk.ac.sussex.gdsc.smlm.results.filter.DirectFilter)18 IDirectFilter (uk.ac.sussex.gdsc.smlm.results.filter.IDirectFilter)14 Filter (uk.ac.sussex.gdsc.smlm.results.filter.Filter)9 MultiPathFilter (uk.ac.sussex.gdsc.smlm.results.filter.MultiPathFilter)9 MaximaSpotFilter (uk.ac.sussex.gdsc.smlm.filters.MaximaSpotFilter)7 FilterSet (uk.ac.sussex.gdsc.smlm.results.filter.FilterSet)7 FractionClassificationResult (uk.ac.sussex.gdsc.core.match.FractionClassificationResult)6 ArrayList (java.util.ArrayList)5 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)5 Nullable (uk.ac.sussex.gdsc.core.annotation.Nullable)4 Checkbox (java.awt.Checkbox)3 LinkedList (java.util.LinkedList)3 ConcurrentRuntimeException (org.apache.commons.lang3.concurrent.ConcurrentRuntimeException)3 Ticker (uk.ac.sussex.gdsc.core.logging.Ticker)3 GenericDialog (ij.gui.GenericDialog)2 NonBlockingGenericDialog (ij.gui.NonBlockingGenericDialog)2 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)2 SimpleRegression (org.apache.commons.math3.stat.regression.SimpleRegression)2 BasePoint (uk.ac.sussex.gdsc.core.match.BasePoint)2 FractionalAssignment (uk.ac.sussex.gdsc.core.match.FractionalAssignment)2