use of uk.ac.sussex.gdsc.smlm.results.filter.FilterSet 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);
}
use of uk.ac.sussex.gdsc.smlm.results.filter.FilterSet in project GDSC-SMLM by aherbert.
the class FilterAnalysis method addPrecisionHysteresisFilters.
private void addPrecisionHysteresisFilters(List<FilterSet> filterSets) {
if (!settings.hysteresisPrecisionFilter) {
return;
}
for (int precisionGap = settings.minPrecisionGap; precisionGap <= settings.maxPrecisionGap; precisionGap += settings.incPrecisionGap) {
final List<Filter> filters = new LinkedList<>();
for (int precision = settings.minPrecision; precision <= settings.maxPrecision; precision++) {
filters.add(new PrecisionHysteresisFilter(2, 0, 1, 0, precision, precisionGap));
}
filterSets.add(new FilterSet(filters));
}
}
use of uk.ac.sussex.gdsc.smlm.results.filter.FilterSet in project GDSC-SMLM by aherbert.
the class FilterAnalysis method addSnrFilters.
private void addSnrFilters(List<FilterSet> filterSets) {
if (!settings.snrFilter) {
return;
}
for (double w = settings.minWidth; w <= settings.maxWidth; w += settings.incWidth) {
final WidthFilter wf = new WidthFilter((float) w);
final List<Filter> filters = new LinkedList<>();
for (int snr = settings.minSnr; snr <= settings.maxSnr; snr++) {
filters.add(new AndFilter(wf, new SnrFilter(snr)));
}
filterSets.add(new FilterSet(filters));
}
}
use of uk.ac.sussex.gdsc.smlm.results.filter.FilterSet in project GDSC-SMLM by aherbert.
the class FilterAnalysis method analyse.
/**
* Run different filtering methods on a set of labelled peak results outputting performance
* statistics on the success of the filter to an ImageJ table.
*
* <p>If the peak result original value is set to 1 it is considered a true peak, 0 for a false
* peak. Filtering is done using e.g. SNR threshold, Precision thresholds, etc. The statistics
* reported are shown in a table, e.g. precision, Jaccard, F-score.
*
* <p>For each filter set a plot is shown of the Jaccard score verses the filter value, thus
* filters should be provided in ascending numerical order otherwise they are sorted.
*
* @param resultsList the results list
* @param filterSets the filter sets
*/
public void analyse(List<MemoryPeakResults> resultsList, List<FilterSet> filterSets) {
final Consumer<String> output = createResultsWindow();
plots = new ArrayList<>(settings.plotTopN);
bestFilter = new HashMap<>();
bestFilterOrder = new LinkedList<>();
IJ.showStatus("Analysing filters ...");
final int total = countFilters(filterSets);
int count = 0;
for (final FilterSet filterSet : filterSets) {
IJ.showStatus("Analysing " + filterSet.getName() + " ...");
count = runAnalysis(output, filterSet, resultsList, count, total);
}
ImageJUtils.finished();
showPlots();
calculateSensitivity(resultsList);
}
use of uk.ac.sussex.gdsc.smlm.results.filter.FilterSet in project GDSC-SMLM by aherbert.
the class FilterAnalysis method addSnrHysteresisFilters.
private void addSnrHysteresisFilters(List<FilterSet> filterSets) {
if (!settings.hysteresisSnrFilter) {
return;
}
for (double w = settings.minWidth; w <= settings.maxWidth; w += settings.incWidth) {
final WidthFilter wf = new WidthFilter((float) w);
for (int snrGap = settings.minSnrGap; snrGap <= settings.maxSnrGap; snrGap += settings.incSnrGap) {
final List<Filter> filters = new LinkedList<>();
for (int snr = settings.minSnr; snr <= settings.maxSnr; snr++) {
filters.add(new AndFilter(wf, new SnrHysteresisFilter(2, 0, 1, 0, snr, snrGap)));
}
filterSets.add(new FilterSet(filters));
}
}
}
Aggregations