edu.mit.sketch.clocksketch.analysis
Class DrawingAnalyzer

java.lang.Object
  extended by edu.mit.sketch.clocksketch.analysis.DrawingAnalyzer

public class DrawingAnalyzer
extends java.lang.Object

This class provides ways to analyze and identify aspects of a PenDrawing. It also organizes PenDrawings by putting Strokes into Symbols

Author:
David Pitman

Nested Class Summary
static class DrawingAnalyzer.DigitOrder
          Enums for the order in which the digits were drawn.
 
Field Summary
static java.lang.String ARC
           
static java.lang.String COMPLEX
           
static java.lang.String ELLIPSE
          These are all simple symbol types that we classify a stroke(s) as
static double handOutsideRadiusFraction
          The fraction that determines how far away from the center of the clockface one end point of the hand must be in terms of the clockface's radius Determined experimentally with patient data to be, approximately, a good value.
static double handWithinRadiusFraction
          The fraction that determines how close the center of the clockface one end point of the hand must be in terms of the clockface's radius Determined experimentally with patient data to be, approximately, a good value.
static int k
          Global variable related to regression analysis.
static java.lang.String LINE
           
static java.lang.String NOTCLASSIFIED
           
static java.lang.String POLYGON
           
static java.lang.String SPIRAL
           
 
Constructor Summary
DrawingAnalyzer()
           
DrawingAnalyzer(PenDrawing drawingArg)
          Constructs a DrawingAnalyzer with a Drawing passed in.
 
Method Summary
static double calculateAdjustedMean(double[] valuesArg, int fraction)
          Produces the equivalent of an interquartile mean, but instead of removing the lower and top fourth of the sorted data, removes 1/fraction from the top and bottom of the data The array passed in is sorted by size within the function.
static double[] calculateLinearRegression(double[][] points)
          Calculates the values of linear regression given the set of points.
static void classifyClockfaceDrawing(PenDrawing drawing)
          Goes through the strokes in the drawing and attempts to classify all of the strokes into various Clockface symbols.
static double[] endPointsCorrelation(Point startPoint, Point endPoint, double lengthOfStroke)
          Returns the x, y, and shortest-distance correlation (between 0 and 1) of how close the endpoints are given the length of the stroke.
static int findValuesAbove(double[] valuesArg, double threshold, double thresholdmultiplier)
          Given the list of values, a threshold, and a multiplier for that threshhold, returns the number of values > (threshhold*threshold multiplier)
static double getDistance(Point firstPoint, Point secondPoint)
          Finds the Euclidian distance between two points.
static double getDistanceWithoutHooklets(Stroke stroke)
           
static double getLengthWithoutHooklets(Stroke stroke)
           
static boolean isCircle(Stroke stroke)
           
static boolean isLine(Stroke stroke)
           
static double summedValueDistribution(double[] valuesArg, double sigma)
          Returns the sum of all the Gaussian distribution results of the values.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELLIPSE

public static final java.lang.String ELLIPSE
These are all simple symbol types that we classify a stroke(s) as

See Also:
Constant Field Values

ARC

public static final java.lang.String ARC
See Also:
Constant Field Values

LINE

public static final java.lang.String LINE
See Also:
Constant Field Values

POLYGON

public static final java.lang.String POLYGON
See Also:
Constant Field Values

COMPLEX

public static final java.lang.String COMPLEX
See Also:
Constant Field Values

SPIRAL

public static final java.lang.String SPIRAL
See Also:
Constant Field Values

NOTCLASSIFIED

public static final java.lang.String NOTCLASSIFIED
See Also:
Constant Field Values

k

public static final int k
Global variable related to regression analysis.

See Also:
Constant Field Values

handWithinRadiusFraction

public static final double handWithinRadiusFraction
The fraction that determines how close the center of the clockface one end point of the hand must be in terms of the clockface's radius Determined experimentally with patient data to be, approximately, a good value.

See Also:
Constant Field Values

handOutsideRadiusFraction

public static final double handOutsideRadiusFraction
The fraction that determines how far away from the center of the clockface one end point of the hand must be in terms of the clockface's radius Determined experimentally with patient data to be, approximately, a good value.

See Also:
Constant Field Values
Constructor Detail

DrawingAnalyzer

public DrawingAnalyzer()

DrawingAnalyzer

public DrawingAnalyzer(PenDrawing drawingArg)
Constructs a DrawingAnalyzer with a Drawing passed in.

Parameters:
drawingArg -
Method Detail

classifyClockfaceDrawing

public static void classifyClockfaceDrawing(PenDrawing drawing)
Goes through the strokes in the drawing and attempts to classify all of the strokes into various Clockface symbols. Will erase all of the current symbols within the drawing and create new symbols within the drawing.

Parameters:
drawing -

findValuesAbove

public static int findValuesAbove(double[] valuesArg,
                                  double threshold,
                                  double thresholdmultiplier)
Given the list of values, a threshold, and a multiplier for that threshhold, returns the number of values > (threshhold*threshold multiplier)

Parameters:
valuesArg -
threshold -
thresholdmultiplier -

summedValueDistribution

public static double summedValueDistribution(double[] valuesArg,
                                             double sigma)
Returns the sum of all the Gaussian distribution results of the values.

Parameters:
valuesArg -
sigma -

calculateAdjustedMean

public static double calculateAdjustedMean(double[] valuesArg,
                                           int fraction)
Produces the equivalent of an interquartile mean, but instead of removing the lower and top fourth of the sorted data, removes 1/fraction from the top and bottom of the data The array passed in is sorted by size within the function.

Parameters:
valuesArg -
fraction -

isLine

public static boolean isLine(Stroke stroke)

isCircle

public static boolean isCircle(Stroke stroke)

getLengthWithoutHooklets

public static double getLengthWithoutHooklets(Stroke stroke)

getDistanceWithoutHooklets

public static double getDistanceWithoutHooklets(Stroke stroke)

getDistance

public static double getDistance(Point firstPoint,
                                 Point secondPoint)
Finds the Euclidian distance between two points.

Parameters:
firstPoint -
secondPoint -
Returns:
if either point is null, returns NaN

endPointsCorrelation

public static double[] endPointsCorrelation(Point startPoint,
                                            Point endPoint,
                                            double lengthOfStroke)
Returns the x, y, and shortest-distance correlation (between 0 and 1) of how close the endpoints are given the length of the stroke. The method uses a simplified gaussian distribution where r=exp(-(foo^2)/(2*sigma^2)) where foo is the distance (x,y,shortest) and sigma=(lengthOfStroke/(distance between points))

Parameters:
startPoint -
endPoint -
lengthOfStroke -
Returns:
{ x Correlation, y Correlation, shortest-distance Correlation }

calculateLinearRegression

public static double[] calculateLinearRegression(double[][] points)
Calculates the values of linear regression given the set of points.

Parameters:
points - [0] = x value, [1] = y value
Returns:
{beta, alpha, r}