de.unihalle.informatik.MiToBo.apps.neurites2D
Class NeuriteDetector2DAlgos

java.lang.Object
  extended by de.unihalle.informatik.MiToBo.apps.neurites2D.NeuriteDetector2DAlgos

public class NeuriteDetector2DAlgos
extends java.lang.Object

 
 The class implements the basic algorithm for neurite detection based on a
 2D multichannel fluorescence image.
 
 The basic steps are:
  1. pre-segmentation step to get a coarse contour of the neurons, yielding a
     initialization for the active contour models (snake)
  2. refinement of the initial contours by the active contour models
  3. identification of structural neuron parts, like soma, neurites and
     growth cones via a wavelet based detection
  
 A lot of intermediate results are save to the special result directories.
 After detection of the neurites a result table with all measured morphology
 values is shown. An result image showing the detected neurites with their
 neurite traces and special points is saved to the output directory.
 
 

Author:
Danny Misiak
See Also:
NeuriteExtractor2D

Nested Class Summary
static class NeuriteDetector2DAlgos.DetectorExternalEnergy
          Label for different external energies of the snake which can be used by the detector.
 
Field Summary
private  double alpha
          Weighting factor for snake length term.
private  double beta
          Weighting factor for snake curvature term.
private  MTBNeurite2DSet detectedNeuritesSet
          Final set of detected neurites.
private  NeuriteDetector2DAlgos.DetectorExternalEnergy energyLabel
          Label of available external snake energies, which are usable by the detector.
private  java.lang.String file_name_noExtension
          Current image name without file extension.
private  java.lang.String fileName
          File name of the current multichannel fluorescence image.
private  int height
          Image size in y-direction, given in pixel.
private  MTBImage inputImage
          Multichannel fluorescence image of the labeled neuron.
private  int maxFragmentDistance
          Maximum distance to connect a fragment to a detected neuron, given in pixel.
private  int maxIterations
          Number of snake iterations.
private  int maxSpineLength
          Maximum length to define a branch of a neurite as spine (filopodia-like protrusion) in pixel.
private  double motionFraction
          Minimum fraction of points which should have stooped to move until the snake optimization stops.
private  java.awt.Color neuriteColor
          Region color of detected neurites to view the neurites in the result image.
private  int neuriteMaskSize
          Mask size of average neurite with in pixel.
private  int[] neuronChannels
          Channel numbers, including the neuron stains for detection of the neurons in the current multichannel fluorescence image.
private  MTBImage neuronMIP
          Maximum intensity projection (MIP) image of the neuron.
private  double niblackConstant
          Application based constant for Niblack thresholding.
private  int nucleiChannel
          Channel number, including the nuclei, in the current multichannel fluorescence image.
private  MTBImage nucleus
          Fluorescence labeled nuclei image from the multichannel microscope image.
private  double nucleusRatio
          Ratio of nucleus pixels which should be included in a intact neuron region to specify the neuron region as active and use for detection.
private  int nucleusSize
          Minimum size of nucleus region to set region as intact nucleus.
private  org.rosuda.JRI.Rengine rEngine
          R engine to start R thread.
private  int resampleConstant
          Constant for resampling the snake control points.
private  java.lang.String result_energy
          Result directory for snake energy results.
private  java.lang.String result_extraction
          Result directory for neurite extraction results.
private  java.lang.String result_presegmentation
          Result directory for pre-segmentation.
private  java.lang.String result_snakes
          Result directory for snake results.
private  java.lang.String resultDir
          Main directory for result output.
private  MTBTableModel resultTable
          Result table showing the the detection and morphology measurements.
private  int[] snakeIterCount
          Number of snake iterations used in current optimization process.
private  double stepSize
          Step size value for a snake step (gamma) during optimization.
private  java.lang.Boolean verbose
          Verbose flag for standard console outputs.
private  int width
          Image size in x-direction, given in pixel.
 
Constructor Summary
NeuriteDetector2DAlgos()
          Standard constructor.
NeuriteDetector2DAlgos(MTBImage _inputImage, int _nucleiChannel, int _nucleusSize, double _nucleusRation, int[] _neuronChannels, double _niblackConstant, int _maxFragmentDistance, java.lang.String _pathToFile, java.lang.String _resultDir, NeuriteDetector2DAlgos.DetectorExternalEnergy _energyLabel, double _alpha, double _beta, double _stepSize, double _motionFraction, int _maxIterations, int _resampleConstant, int _maxSpineLength, int _neuriteMaskSize, java.awt.Color _neuriteColor, MTBTableModel _table, java.lang.Boolean _verbose, org.rosuda.JRI.Rengine _re)
          Constructor.
 
Method Summary
 double getAlpha()
          Get weighting factor for snake length term.
 double getBeta()
          Get weighting factor for snake curvature term.
 MTBNeurite2DSet getDetectedNeuritesSet()
          Get set of detected neurites.
 NeuriteDetector2DAlgos.DetectorExternalEnergy getEnergyLabel()
          Get energy label for external energy, used for optimization.
private  MTBImage getExtEnergyInit()
          Calculate the initial image for the external energy of the snake.
 MTBImage getInputImage()
          Get multichannel fluorescence input image.
 int getMaxFragmentDistance()
          Get maximum fragment distance , in pixel.
 int getMaxIterations()
          Get maximum number of iterations to finish snake optimization,
 int getMaxSpineLength()
          Get maximum length of a spine, in pixel.
 double getMotionFraction()
          Get minimum motion fraction of snake control points, to finish snake optimization.
 java.awt.Color getNeuriteColor()
          Get neurite region color (RGB) for result image.
 int getNeuriteMaskSize()
          Get maximum neurite mask size, in pixel.
 int[] getNeuronChannles()
          Get neuron channels, used for detection.
 double getNiblackConstant()
          Get Niblack thresholding constant.
 int getNucleiChannel()
          Get channel number, including the labeled nuclei.
 double getNucleusRatio()
          Get ratio of nucleus pixels which should be included in an intact neuron region
 int getNucleusSize()
          Get minimum nucleus size of nuclei regions
 int getResampleConstant()
          Get constant for snake point resampling.
 java.lang.String getResultDir()
          Get directory of intermediate and final results.
 MTBTableModel getResultTable()
          Get final result table of morphology measurements.
private  java.util.Vector<MTBSnakePoint2D> getSnakeControlPoints(MTBContour2D initContour)
          Method to get each 7th point of the initial contour as snake control point.
 int[] getSnakeIterCount()
          Get snake iteration counts, used for optimization.
private  MTBRegion2DSet getSnakeRegion(MTBPolygon2DSet theSnakes)
          Get the region which is included in the snake contour.
 double getStepSize()
          Get step size of snake point movement.
private  void init()
          Initialize detector.
 void neuriteDetection(MTBContour2DSet initContourSet)
          Main method for 2D neurite detection.
private  MTBPolygon2DSet optimizeSnakes(MTBPolygon2DSet initSnakeSet)
          Optimization of the snakes (main snake and inner snakes) with its specified parameters and energies.
 MTBContour2DSet preSegmentation()
          Method for pre-segmentation.
private  void setResultDirs()
          Create all output directories for the single detection steps.
private  boolean testRegions(MTBRegion2D cell, MTBRegion2D core)
          Test whether the number of pixels from a neuron region contains more than 90% of the pixels from a nucleus region.
private  boolean testRegions2(MTBRegion2D cell, MTBRegion2D core)
          Test whether a single pixel from a neuron region contains a pixel from a nucleus region.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alpha

private double alpha
Weighting factor for snake length term.


beta

private double beta
Weighting factor for snake curvature term.


detectedNeuritesSet

private MTBNeurite2DSet detectedNeuritesSet
Final set of detected neurites.


energyLabel

private NeuriteDetector2DAlgos.DetectorExternalEnergy energyLabel
Label of available external snake energies, which are usable by the detector.


file_name_noExtension

private java.lang.String file_name_noExtension
Current image name without file extension.


fileName

private java.lang.String fileName
File name of the current multichannel fluorescence image.


height

private int height
Image size in y-direction, given in pixel.


inputImage

private MTBImage inputImage
Multichannel fluorescence image of the labeled neuron.


maxFragmentDistance

private int maxFragmentDistance
Maximum distance to connect a fragment to a detected neuron, given in pixel.


maxIterations

private int maxIterations
Number of snake iterations.


maxSpineLength

private int maxSpineLength
Maximum length to define a branch of a neurite as spine (filopodia-like protrusion) in pixel.


motionFraction

private double motionFraction
Minimum fraction of points which should have stooped to move until the snake optimization stops.


neuriteColor

private java.awt.Color neuriteColor
Region color of detected neurites to view the neurites in the result image.


neuriteMaskSize

private int neuriteMaskSize
Mask size of average neurite with in pixel. This mask size is used for the morphological opening to remove neurites from the soma in the neurite extraction step.


neuronChannels

private int[] neuronChannels
Channel numbers, including the neuron stains for detection of the neurons in the current multichannel fluorescence image.


neuronMIP

private MTBImage neuronMIP
Maximum intensity projection (MIP) image of the neuron. This image gives the basis for the automatic detection.


niblackConstant

private double niblackConstant
Application based constant for Niblack thresholding.


nucleiChannel

private int nucleiChannel
Channel number, including the nuclei, in the current multichannel fluorescence image.


nucleus

private MTBImage nucleus
Fluorescence labeled nuclei image from the multichannel microscope image.


nucleusRatio

private double nucleusRatio
Ratio of nucleus pixels which should be included in a intact neuron region to specify the neuron region as active and use for detection.


nucleusSize

private int nucleusSize
Minimum size of nucleus region to set region as intact nucleus.


rEngine

private org.rosuda.JRI.Rengine rEngine
R engine to start R thread.


resampleConstant

private int resampleConstant
Constant for resampling the snake control points.


result_energy

private java.lang.String result_energy
Result directory for snake energy results.


result_extraction

private java.lang.String result_extraction
Result directory for neurite extraction results.


result_presegmentation

private java.lang.String result_presegmentation
Result directory for pre-segmentation.


result_snakes

private java.lang.String result_snakes
Result directory for snake results.


resultDir

private java.lang.String resultDir
Main directory for result output.


resultTable

private MTBTableModel resultTable
Result table showing the the detection and morphology measurements.


snakeIterCount

private int[] snakeIterCount
Number of snake iterations used in current optimization process.


stepSize

private double stepSize
Step size value for a snake step (gamma) during optimization.


verbose

private java.lang.Boolean verbose
Verbose flag for standard console outputs.


width

private int width
Image size in x-direction, given in pixel.

Constructor Detail

NeuriteDetector2DAlgos

public NeuriteDetector2DAlgos()
Standard constructor.


NeuriteDetector2DAlgos

public NeuriteDetector2DAlgos(MTBImage _inputImage,
                              int _nucleiChannel,
                              int _nucleusSize,
                              double _nucleusRation,
                              int[] _neuronChannels,
                              double _niblackConstant,
                              int _maxFragmentDistance,
                              java.lang.String _pathToFile,
                              java.lang.String _resultDir,
                              NeuriteDetector2DAlgos.DetectorExternalEnergy _energyLabel,
                              double _alpha,
                              double _beta,
                              double _stepSize,
                              double _motionFraction,
                              int _maxIterations,
                              int _resampleConstant,
                              int _maxSpineLength,
                              int _neuriteMaskSize,
                              java.awt.Color _neuriteColor,
                              MTBTableModel _table,
                              java.lang.Boolean _verbose,
                              org.rosuda.JRI.Rengine _re)
Constructor.

Parameters:
_inputImage - multichannel fluorescence image
_nucleiChannel - channel number including nuclei image
_nucleusSize - minimum size of nucleus region
_nucleusRation - ratio of nucleus pixels which should be included in an intact neuron region
_neuronChannels - channel numbers including neuron stains for detection
_niblackConstant - constant for niblack thresholding
_maxFragmentDistance - maximum distance to connect a fragment to the neuron, in pixel
_pathToFile - path to current image file
resultDir - directory of output results
_energyLabel - label of available external energies for detection using snakes
_alpha - weighting factor for snake length term
_beta - weighting factor for snake curvature term
_stepSize - step size gamma to move snake in a optimization step
_motionFraction - minimum fraction of not moving points to stop optimization
_maxIterations - maximum iteration to stop optimization
_resampleConstant - constant for resampling snake control points
_maxSpineLength - maximum length of a branch to define it as spine, in pixel
_neuriteMaskSize - mask size of average neurite width, in pixel
_neuriteColor - color for neurite regions in result image
_table - result table
_verbose - flag for standard console outputs
_re - R engine to call R scripts from a Java thread
Method Detail

getAlpha

public double getAlpha()
Get weighting factor for snake length term.


getBeta

public double getBeta()
Get weighting factor for snake curvature term.


getDetectedNeuritesSet

public MTBNeurite2DSet getDetectedNeuritesSet()
Get set of detected neurites.


getEnergyLabel

public NeuriteDetector2DAlgos.DetectorExternalEnergy getEnergyLabel()
Get energy label for external energy, used for optimization.


getExtEnergyInit

private MTBImage getExtEnergyInit()
Calculate the initial image for the external energy of the snake. This image is used to generate the final external energy in the snake optimization method below.


getInputImage

public MTBImage getInputImage()
Get multichannel fluorescence input image.


getMaxFragmentDistance

public int getMaxFragmentDistance()
Get maximum fragment distance , in pixel.


getMaxIterations

public int getMaxIterations()
Get maximum number of iterations to finish snake optimization,


getMaxSpineLength

public int getMaxSpineLength()
Get maximum length of a spine, in pixel.


getMotionFraction

public double getMotionFraction()
Get minimum motion fraction of snake control points, to finish snake optimization.


getNeuriteColor

public java.awt.Color getNeuriteColor()
Get neurite region color (RGB) for result image.


getNeuriteMaskSize

public int getNeuriteMaskSize()
Get maximum neurite mask size, in pixel. Defines the average width of a neurite.


getNeuronChannles

public int[] getNeuronChannles()
Get neuron channels, used for detection.


getNiblackConstant

public double getNiblackConstant()
Get Niblack thresholding constant.


getNucleiChannel

public int getNucleiChannel()
Get channel number, including the labeled nuclei.


getNucleusRatio

public double getNucleusRatio()
Get ratio of nucleus pixels which should be included in an intact neuron region


getNucleusSize

public int getNucleusSize()
Get minimum nucleus size of nuclei regions


getResampleConstant

public int getResampleConstant()
Get constant for snake point resampling.


getResultDir

public java.lang.String getResultDir()
Get directory of intermediate and final results.


getResultTable

public MTBTableModel getResultTable()
Get final result table of morphology measurements.


getSnakeControlPoints

private java.util.Vector<MTBSnakePoint2D> getSnakeControlPoints(MTBContour2D initContour)
Method to get each 7th point of the initial contour as snake control point.

Parameters:
initContour - initial contour to extract snake control points
Returns:
List of control points of the snake.

getSnakeIterCount

public int[] getSnakeIterCount()
Get snake iteration counts, used for optimization.


getSnakeRegion

private MTBRegion2DSet getSnakeRegion(MTBPolygon2DSet theSnakes)
Get the region which is included in the snake contour.

Parameters:
snake - current snake
Returns:
2D region with all pixels included in the snake, including the snake points.

getStepSize

public double getStepSize()
Get step size of snake point movement.


init

private void init()
Initialize detector.


neuriteDetection

public void neuriteDetection(MTBContour2DSet initContourSet)
                      throws NeuriteDetector2DException
Main method for 2D neurite detection. Using the initial contours of the pre-segmented neurons as input for the active contour models to calculate an exact contour of each neuron.

Parameters:
initContourSet - set of initial contours for snakes
Throws:
NeuriteDetector2DException

optimizeSnakes

private MTBPolygon2DSet optimizeSnakes(MTBPolygon2DSet initSnakeSet)
Optimization of the snakes (main snake and inner snakes) with its specified parameters and energies.

Parameters:
initSnakes - initial snakes for optimization start
Returns:
optimized set of snakes

preSegmentation

public MTBContour2DSet preSegmentation()
                                throws NeuriteDetector2DException
Method for pre-segmentation. Binarization, regions- and contour labeling take place. As result the rough contours of the neurons are returned to be used as initial contours for active contour models in the `neuriteDetection` method.

Returns:
Set of 2D neuron contours.
Throws:
NeuriteDetector2DException

setResultDirs

private void setResultDirs()
Create all output directories for the single detection steps.


testRegions

private boolean testRegions(MTBRegion2D cell,
                            MTBRegion2D core)
Test whether the number of pixels from a neuron region contains more than 90% of the pixels from a nucleus region. The nucleus region must be smaller than the neuron region! If yes, the neuron region contains the nucleus region and is a potential living cell to detect a new neuron region.

Parameters:
cell - region of the neuron cell
core - region of the nucleus
Returns:
True if core region is included with at least 90% of its pixel in the neuron region.

testRegions2

private boolean testRegions2(MTBRegion2D cell,
                             MTBRegion2D core)
Test whether a single pixel from a neuron region contains a pixel from a nucleus region. If yes, the neuron region contains parts of the nucleus region.

Parameters:
cell - region of the neuron cell
core - region of the nucleus
Returns:
Is core included in neuron region false or true.