use of uk.ac.sussex.gdsc.smlm.data.config.FitProtos.DataFilterSettings 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;
}
use of uk.ac.sussex.gdsc.smlm.data.config.FitProtos.DataFilterSettings in project GDSC-SMLM by aherbert.
the class FitEngineConfiguration method getNumberOfFilters.
/**
* Gets the number of filters for the configured filter type.
*
* @return the number of filters
*/
public int getNumberOfFilters() {
final DataFilterSettings f = fitEngineSettings.getDataFilterSettings();
final int filterCount = f.getDataFiltersCount();
if (f.getDataFilterType() == DataFilterType.JURY && filterCount > 1) {
return filterCount;
} else if (f.getDataFilterType() == DataFilterType.DIFFERENCE && filterCount > 1) {
return 2;
} else {
// Single filter
return 1;
}
}
Aggregations