Class TabularParser

java.lang.Object
sc.fiji.snt.analysis.sholl.parsers.TabularParser
All Implemented Interfaces:
Parser, ProfileProperties

public class TabularParser extends Object implements Parser
A Parser for extracting Sholl profiles from tabular data.

TabularParser processes data from tables (CSV files, ResultsTables, etc.) containing radial distance and intersection count columns to generate Sholl analysis profiles. This is useful for analyzing pre-computed Sholl data or importing results from external analysis tools.

The parser supports both ImageJ1 (ResultsTable) and ImageJ2 (DoubleTable) table formats, and can automatically detect spatial calibration units from column headers.

Example usage:
 // Parse from CSV file
 TabularParser parser = new TabularParser("data.csv", "Distance_um", "Intersections");
 parser.parse();
 Profile profile = parser.getProfile();
 
 // Parse subset of rows from ResultsTable
 TabularParser parser2 = new TabularParser(resultsTable, "Radius", "Count", 5, 25);
 parser2.parse();
 
Author:
Tiago Ferreira
See Also:
  • Constructor Details

    • TabularParser

      public TabularParser(File table, String radiiColumnHeader, String countsColumnHeader) throws IOException
      Constructs a TabularParser from a table file.

      Loads and parses a table file (CSV, TSV, etc.) containing Sholl analysis data. The file should have columns for radial distances and intersection counts.

      Parameters:
      table - the File containing the tabular data
      radiiColumnHeader - the header name of the column containing radial distances
      countsColumnHeader - the header name of the column containing intersection counts
      Throws:
      IOException - if the file cannot be read or parsed
      IllegalArgumentException - if the specified column headers are not found
    • TabularParser

      public TabularParser(String filePath, String radiiColumnHeader, String countsColumnHeader) throws IOException
      Constructs a TabularParser from a table file path.

      Convenience constructor that accepts a file path string instead of a File object.

      Parameters:
      filePath - the path to the file containing the tabular data
      radiiColumnHeader - the header name of the column containing radial distances
      countsColumnHeader - the header name of the column containing intersection counts
      Throws:
      IOException - if the file cannot be read or parsed
      IllegalArgumentException - if the specified column headers are not found
    • TabularParser

      public TabularParser(ij.measure.ResultsTable table, String radiiColumnHeader, String countsColumnHeader, int startRow, int endRow)
      Constructs a TabularParser from an ImageJ1 ResultsTable with row range specification.

      This constructor allows parsing a specific subset of rows from the table, which is useful for analyzing partial data or excluding outliers.

      Parameters:
      table - the ImageJ1 ResultsTable containing the data
      radiiColumnHeader - the header name of the column containing radial distances
      countsColumnHeader - the header name of the column containing intersection counts
      startRow - the first row to include in parsing (0-based, -1 for start of table)
      endRow - the last row to include in parsing (0-based, -1 for end of table)
      Throws:
      IllegalArgumentException - if the table is null/empty or column headers are not found
    • TabularParser

      public TabularParser(net.imagej.table.ResultsTable table, String radiiColumnHeader, String countsColumnHeader)
      Constructs a TabularParser from an ImageJ2 ResultsTable.

      Convenience constructor for ImageJ2 ResultsTable objects.

      Parameters:
      table - the ImageJ2 ResultsTable containing the data
      radiiColumnHeader - the header name of the column containing radial distances
      countsColumnHeader - the header name of the column containing intersection counts
      Throws:
      IllegalArgumentException - if the table is null/empty or column headers are not found
    • TabularParser

      public TabularParser(org.scijava.table.DoubleTable table, String radiiColumnHeader, String countsColumnHeader)
      Constructs a TabularParser from a DoubleTable.

      This constructor works with SciJava DoubleTable objects, providing compatibility with the ImageJ2 table framework.

      Parameters:
      table - the DoubleTable containing the data
      radiiColumnHeader - the header name of the column containing radial distances
      countsColumnHeader - the header name of the column containing intersection counts
      Throws:
      IllegalArgumentException - if the table is null/empty or column headers are not found
  • Method Details

    • parse

      public void parse()
      Parses the tabular data to extract the Sholl profile.

      This method reads the specified columns from the table, creates ProfileEntry objects for each row, and builds a complete Sholl profile. It also attempts to automatically detect spatial calibration units from the radii column header.

      The parsing process:
      1. Creates a new Profile object
      2. Reads data from the specified radii and counts columns
      3. Creates ProfileEntry objects for each data row
      4. Sets profile metadata and properties
      5. Attempts to detect and set spatial calibration
      Specified by:
      parse in interface Parser
    • restrictToSubset

      public void restrictToSubset(int firstRow, int lastRow)
    • 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
    • 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
    • main

      public static void main(String... args)