Class ImageParser

java.lang.Object
org.scijava.AbstractContextual
org.scijava.command.ContextCommand
sc.fiji.snt.analysis.sholl.parsers.ImageParser
All Implemented Interfaces:
Runnable, org.scijava.Cancelable, org.scijava.command.Command, org.scijava.Contextual, org.scijava.plugin.SciJavaPlugin, Parser, ProfileProperties
Direct Known Subclasses:
ImageParser2D, ImageParser3D

public class ImageParser extends org.scijava.command.ContextCommand implements Parser
A Parser for extracting Sholl profiles from image data.

ImageParser analyzes 2D or 3D images to compute intersection counts at various radial distances from a center point. It supports thresholded analysis, multi-channel images, and various sampling strategies including hemishell analysis.

The parser can work with binary images, grayscale images with threshold ranges, or intensity-based analysis. It provides methods for setting analysis parameters such as center point, radii, thresholds, and sampling regions.

Key features include:
  • Support for 2D and 3D image analysis
  • Flexible center point definition (manual coordinates or ROI-based)
  • Customizable radial sampling with automatic or manual radius specification
  • Threshold-based analysis for binary or grayscale images
  • Hemishell analysis for directional sampling
  • Integration with ImageJ's calibration system
Author:
Tiago Ferreira
See Also:
  • Field Details

    • statusService

      protected org.scijava.app.StatusService statusService
    • profile

      protected Profile profile
    • properties

      protected Properties properties
    • center

      protected ShollPoint center
    • radii

      protected ArrayList<Double> radii
    • imp

      protected final ij.ImagePlus imp
    • cal

      protected final ij.measure.Calibration cal
    • voxelSize

      protected final double voxelSize
    • lowerT

      protected double lowerT
    • upperT

      protected double upperT
    • channel

      protected int channel
    • frame

      protected int frame
    • minX

      protected int minX
    • maxX

      protected int maxX
    • minY

      protected int minY
    • maxY

      protected int maxY
    • minZ

      protected int minZ
    • maxZ

      protected int maxZ
    • xc

      protected int xc
    • yc

      protected int yc
    • zc

      protected int zc
    • start

      protected long start
    • running

      protected volatile boolean running
  • Constructor Details

    • ImageParser

      @Deprecated protected ImageParser(ij.ImagePlus imp)
      Deprecated.
    • ImageParser

      protected ImageParser(ij.ImagePlus imp, org.scijava.Context context)
  • Method Details

    • getIsotropicVoxelSize

      public double getIsotropicVoxelSize()
      Gets the isotropic voxel size used for analysis.

      For 2D images, this is the average of pixel width and height. For 3D images, this is the average of pixel width, height, and depth. This value is used as the minimum step size for radial sampling.

      Returns:
      the isotropic voxel size in calibrated units
    • setCenterFromROI

      public void setCenterFromROI() throws IllegalArgumentException
      Computes the center of analysis from the centroid of the active ROI.
      Throws:
      IllegalArgumentException - if image has no current selection or active ROI
    • setCenterFromROI

      public void setCenterFromROI(ij.gui.Roi roi) throws IllegalArgumentException
      Computes the center of analysis from the centroid of the specified ROI.
      Parameters:
      roi - the selection from which the centroid will be computed
      Throws:
      IllegalArgumentException - if roi is null
    • setCenterPx

      public void setCenterPx(int x, int y, int z) throws IndexOutOfBoundsException
      Sets the center of analysis using image (pixel) coordinates.
      Parameters:
      x - the x coordinate (in pixels)
      y - the y coordinate (in pixels)
      z - the z coordinate (in pixels), i.e., slice number (1-based index)
      Throws:
      IndexOutOfBoundsException - if specified coordinates extends beyond image dimensions
    • setCenter

      public void setCenter(double x, double y, double z)
      Sets the center of analysis using real world (calibrated) coordinates.
      Parameters:
      x - the x coordinate (in calibrated units)
      y - the y coordinate (in calibrated units)
      z - the z coordinate (in calibrated units)
    • setThreshold

      public void setThreshold(double lower, double upper)
      Sets the threshold range for pixel inclusion in the analysis.

      Only pixels with intensity values within the specified range will be considered as intersections during Sholl analysis. This is particularly useful for analyzing specific structures in grayscale images.

      Parameters:
      lower - the lower threshold value (inclusive)
      upper - the upper threshold value (inclusive)
    • setRadii

      public void setRadii(double[] radiiArray)
    • setRadii

      public void setRadii(double startRadius, double step, double endRadius)
    • maxPossibleRadius

      public double maxPossibleRadius()
    • setRetrieveIntDensities

      public void setRetrieveIntDensities(boolean retrieveIntDensities)
    • isRetrieveIntDensitiesSet

      public boolean isRetrieveIntDensitiesSet()
    • checkUnsetFields

      protected void checkUnsetFields(boolean includeThreshold)
    • checkUnsetFields

      protected void checkUnsetFields()
    • setHemiShells

      public void setHemiShells(String flag)
    • getCircumferencePoints

      public int[][] getCircumferencePoints(int cx, int cy, int radius)
    • getMask

      public ij.ImagePlus getMask()
    • getMaskProcessor

      public ij.process.ImageProcessor getMaskProcessor(boolean floatProcessor, double[] maskValues)
      Creates a 2D 'Sholl heatmap' by applying measured values to the foreground pixels of a copy of the analyzed image.
      Parameters:
      floatProcessor - if true, a FloatProcessor is returned, if false, a ShortProcessor is returned
      maskValues - the mask values
      Returns:
      the processor containing the heatmap
    • setPosition

      protected void setPosition(int channel, int frame)
    • withinThreshold

      protected boolean withinThreshold(double value)
    • withinXYbounds

      protected boolean withinXYbounds(int x, int y)
    • withinZbounds

      protected boolean withinZbounds(int z)
    • withinBounds

      protected boolean withinBounds(int x, int y, int z)
    • clearStatus

      protected void clearStatus()
    • parse

      public void parse()
      Description copied from interface: Parser
      Performs the parsing operation to extract the Sholl profile.

      This method analyzes the data source and computes intersection counts at various radial distances from the center point. The resulting profile can be retrieved using Parser.getProfile().

      Implementations should handle any necessary preprocessing, validation, and error handling during the parsing process.

      Specified by:
      parse in interface Parser
    • getProfile

      public Profile getProfile()
      Description copied from interface: Parser
      Gets the Sholl profile generated by the parsing operation.

      This method returns the profile containing intersection counts at various radial distances. The profile should only be retrieved after calling Parser.parse() and verifying success with Parser.successful().

      Specified by:
      getProfile in interface Parser
      Returns:
      the Sholl profile, or null if parsing has not been performed or was unsuccessful
    • successful

      public boolean successful()
      Description copied from interface: Parser
      Checks if the parsing operation was successful.

      This method should be called after Parser.parse() to determine if the parsing completed without errors and produced a valid profile.

      Specified by:
      successful in interface Parser
      Returns:
      true if parsing was successful, false otherwise
    • terminate

      public void terminate()
      Description copied from interface: Parser
      Terminates the parsing operation.

      This method should be called to clean up resources and stop any ongoing parsing operations. It may be used to interrupt long-running analyses or to ensure proper cleanup when the parser is no longer needed.

      Specified by:
      terminate in interface Parser
    • reset

      public void reset()
    • run

      public void run()
      Specified by:
      run in interface Runnable