Search in sources :

Example 1 with DataProcessor

use of uk.ac.sussex.gdsc.smlm.filters.DataProcessor in project GDSC-SMLM by aherbert.

the class FitEngineConfiguration method createSpotFilter.

/**
 * Create the spot filter for identifying candidate maxima. The actual border, search width and
 * smoothing parameters can be configured relative to the configured standard deviations or left
 * absolute. The standard deviation is used to determine the Half-Width at Half-Maximum (HWHM) for
 * each dimension and the parameters set as follows.
 *
 * <pre>
 * int search = (int) Math.ceil(getSearch() * hwhmMax);
 * int border = (int) Math.floor(getBorder() * hwhmMax);
 * // For each filter
 * double smooth = getSmooth(i) * hwhmMin;
 * </pre>
 *
 * @return the maxima spot filter
 */
public MaximaSpotFilter createSpotFilter() {
    // Respect the absolute parameter absolute flag for all the distances.
    // Get the half-width at half maximum
    final double hwhmMin = getHwhmMin();
    final double hwhmMax = getHwhmMax();
    // Note: rounding to 2 decimal places is a simple method for removing small errors
    // in floating point precision from creating an incorrect integer
    // Region for maxima finding
    int search = (int) Math.ceil(convert(getSearchParameter(), hwhmMax, 2));
    if (search < 1) {
        search = 1;
    }
    // Border where peaks are ignored
    int border = (int) Math.floor(convert(getBorderParameter(), hwhmMax, 2));
    if (border < 0) {
        border = 0;
    }
    final DataProcessor processor0 = createDataProcessor(border, 0, hwhmMin);
    final DataFilterSettings f = fitEngineSettings.getDataFilterSettings();
    final int filterCount = f.getDataFiltersCount();
    final MaximaSpotFilter spotFilter;
    if (f.getDataFilterType() == DataFilterType.JURY && filterCount > 1) {
        final DataProcessor[] processors = new DataProcessor[filterCount];
        processors[0] = processor0;
        for (int i = 1; i < filterCount; i++) {
            processors[i] = createDataProcessor(border, i, hwhmMin);
        }
        spotFilter = new JurySpotFilter(search, border, processors);
    } else if (f.getDataFilterType() == DataFilterType.DIFFERENCE && filterCount > 1) {
        final DataProcessor processor1 = createDataProcessor(border, 1, hwhmMin);
        spotFilter = new DifferenceSpotFilter(search, border, processor0, processor1);
    } else {
        spotFilter = new SingleSpotFilter(search, border, processor0);
    }
    if (getFitConfiguration().isPerPixelCameraType()) {
        if (!spotFilter.isWeighted()) {
            throw new IllegalStateException("Camera type requires a weighted spot filter: " + fitConfiguration.getCameraType());
        }
        final CameraModel model = fitConfiguration.getCameraModel();
        if (model == null || !model.isPerPixelModel()) {
            throw new IllegalStateException("Weighted spot filter requires a per-pixel camera model");
        }
    }
    return spotFilter;
}
Also used : CameraModel(uk.ac.sussex.gdsc.smlm.model.camera.CameraModel) MaximaSpotFilter(uk.ac.sussex.gdsc.smlm.filters.MaximaSpotFilter) JurySpotFilter(uk.ac.sussex.gdsc.smlm.filters.JurySpotFilter) DifferenceSpotFilter(uk.ac.sussex.gdsc.smlm.filters.DifferenceSpotFilter) GaussianDataProcessor(uk.ac.sussex.gdsc.smlm.filters.GaussianDataProcessor) MedianDataProcessor(uk.ac.sussex.gdsc.smlm.filters.MedianDataProcessor) CircularMeanDataProcessor(uk.ac.sussex.gdsc.smlm.filters.CircularMeanDataProcessor) DataProcessor(uk.ac.sussex.gdsc.smlm.filters.DataProcessor) AverageDataProcessor(uk.ac.sussex.gdsc.smlm.filters.AverageDataProcessor) BlockAverageDataProcessor(uk.ac.sussex.gdsc.smlm.filters.BlockAverageDataProcessor) DataFilterSettings(uk.ac.sussex.gdsc.smlm.data.config.FitProtos.DataFilterSettings) SingleSpotFilter(uk.ac.sussex.gdsc.smlm.filters.SingleSpotFilter)

Example 2 with DataProcessor

use of uk.ac.sussex.gdsc.smlm.filters.DataProcessor in project GDSC-SMLM by aherbert.

the class SmoothImage method createSpotFilter.

private MaximaSpotFilter createSpotFilter() {
    final int search = 1;
    final int border = 0;
    final DataProcessor processor0 = FitEngineConfiguration.createDataProcessor(border, filters[settings.filter1], settings.smooth1);
    if (settings.differenceFilter) {
        final DataProcessor processor1 = FitEngineConfiguration.createDataProcessor(border, filters[settings.filter2], settings.smooth2);
        return new DifferenceSpotFilter(search, border, processor0, processor1, settings.allowInversion);
    }
    return new SingleSpotFilter(search, border, processor0);
}
Also used : DifferenceSpotFilter(uk.ac.sussex.gdsc.smlm.filters.DifferenceSpotFilter) DataProcessor(uk.ac.sussex.gdsc.smlm.filters.DataProcessor) SingleSpotFilter(uk.ac.sussex.gdsc.smlm.filters.SingleSpotFilter)

Aggregations

DataProcessor (uk.ac.sussex.gdsc.smlm.filters.DataProcessor)2 DifferenceSpotFilter (uk.ac.sussex.gdsc.smlm.filters.DifferenceSpotFilter)2 SingleSpotFilter (uk.ac.sussex.gdsc.smlm.filters.SingleSpotFilter)2 DataFilterSettings (uk.ac.sussex.gdsc.smlm.data.config.FitProtos.DataFilterSettings)1 AverageDataProcessor (uk.ac.sussex.gdsc.smlm.filters.AverageDataProcessor)1 BlockAverageDataProcessor (uk.ac.sussex.gdsc.smlm.filters.BlockAverageDataProcessor)1 CircularMeanDataProcessor (uk.ac.sussex.gdsc.smlm.filters.CircularMeanDataProcessor)1 GaussianDataProcessor (uk.ac.sussex.gdsc.smlm.filters.GaussianDataProcessor)1 JurySpotFilter (uk.ac.sussex.gdsc.smlm.filters.JurySpotFilter)1 MaximaSpotFilter (uk.ac.sussex.gdsc.smlm.filters.MaximaSpotFilter)1 MedianDataProcessor (uk.ac.sussex.gdsc.smlm.filters.MedianDataProcessor)1 CameraModel (uk.ac.sussex.gdsc.smlm.model.camera.CameraModel)1