Class PlausibilityCalibrator

java.lang.Object
sc.fiji.snt.analysis.curation.PlausibilityCalibrator

public class PlausibilityCalibrator extends Object
Infers PlausibilityCheck thresholds from a collection of reference Trees. For each configurable parameter the calibrator collects the corresponding metric across every parent-child fork (live checks) or every path (deep checks) and derives thresholds from percentile statistics.

Typical usage:


 PlausibilityCalibrator cal = new PlausibilityCalibrator(trees);
 CalibrationResult result = cal.calibrate();
 result.applyTo(monitor);            // updates all thresholds
 System.out.println(result.toTable()); // human-readable summary
 
Author:
Tiago Ferreira
See Also:
  • Field Details

    • CURATION_EXTENSION

      public static final String CURATION_EXTENSION
      The file extension for curation preset files (without leading dot).
      See Also:
    • BUILT_IN_PRESETS

      public static final String[] BUILT_IN_PRESETS
      Names of built-in curation presets bundled with SNT (without the .curation extension). This list must be kept in sync with the files under src/main/resources/curations/.
  • Constructor Details

    • PlausibilityCalibrator

      public PlausibilityCalibrator(Collection<Tree> trees)
      Creates a calibrator from a collection of reference trees.
      Parameters:
      trees - the reference trees (must not be null or empty)
      Throws:
      IllegalArgumentException - if trees is null or empty
  • Method Details

    • setUpperPercentile

      public void setUpperPercentile(double percentile)
      Sets the percentile used for "flag if above" thresholds (e.g., max fork angle, max radius ratio). Default is 95.
      Parameters:
      percentile - the upper percentile (0-100)
    • setLowerPercentile

      public void setLowerPercentile(double percentile)
      Sets the percentile used for "flag if below" thresholds (e.g., min fork angle, min terminal branch length). Default is 5.
      Parameters:
      percentile - the lower percentile (0-100)
    • calibrate

      Runs the calibration against all reference trees and returns a PlausibilityCalibrator.CalibrationResult containing the inferred thresholds.
      Returns:
      the calibration result (never null)
    • getCurationsDirectory

      public static File getCurationsDirectory(File workspaceDir)
      Returns the curations subdirectory inside the given workspace directory. Creates the directory if it does not exist.
      Parameters:
      workspaceDir - the SNT workspace directory (e.g., from SNTPrefs.getWorkspaceDir())
      Returns:
      the curations directory (<workspaceDir>/curations/)
    • listCurationFiles

      public static File[] listCurationFiles(File workspaceDir)
      Lists all .curation files in the curations subdirectory of the given workspace directory.
      Parameters:
      workspaceDir - the SNT workspace directory
      Returns:
      an array of curation files (may be empty, never null)
    • save

      public static void save(PlausibilityMonitor monitor, File file, String comment) throws IOException
      Saves the current state of a PlausibilityMonitor (thresholds and enabled states) to a .curation properties file.
      Parameters:
      monitor - the monitor whose state will be saved
      file - the target file (should have .curation extension)
      comment - an optional header comment (e.g., cell type description)
      Throws:
      IOException - if writing fails
    • load

      public static void load(File file, PlausibilityMonitor monitor) throws IOException
      Loads thresholds and enabled states from a .curation properties file and applies them to the given monitor.
      Parameters:
      file - the curation file to load
      monitor - the monitor to update
      Throws:
      IOException - if reading fails
    • loadBuiltIn

      public static void loadBuiltIn(String presetName, PlausibilityMonitor monitor) throws IOException
      Loads a built-in curation preset bundled in the SNT JAR and applies it to the given monitor. Preset names correspond to entries in BUILT_IN_PRESETS.
      Parameters:
      presetName - the preset name (without extension), e.g. "dummy1"
      monitor - the monitor to update
      Throws:
      IOException - if reading fails
      IllegalArgumentException - if the preset resource is not found