@ALDAOperator(genericExecutionMode=NONE, level=STANDARD, allowBatchMode=false) public class NeuriteExtractor2D extends MTBOperator
MTBNeurite2D
objects.
Note: Don't know why operator cannot run twice without restart of MiToBo.
Maybe a threading problem of the R engine.MTBNeuriteSkelGraph
,
MTBNeurite2DSet
Modifier and Type | Class and Description |
---|---|
static class |
NeuriteExtractor2D.NeuronColor
Color of binary neuron image foreground.
|
Modifier and Type | Field and Description |
---|---|
private Vector<Vector<Double>> |
avgNeuriteWidths
Vector of neurite widths, containing 3 elements. 1. average width of whole
neurite, 2. average width of neurite shaft, and 3. average width of growth
cone.
|
private MTBNeurite2DSet |
extractedNeurites |
private Vector<Vector<Vector<Point2D.Double>>> |
featurePoints
Vector of detected feature points for each neurite.
|
private int |
height
Height of the binary neuron image.
|
private int |
maxSpineLength |
private Vector<MTBNeuriteSkelGraph> |
neuriteGraphs
Vector of neurite graphs, one for each localized neurite.
|
private int |
neuriteMaskSize |
private int[] |
neuriteShaftLengths
Array of detected lengths of the neurite shafts, without growth cone
regions.
|
private MTBRegion2D |
neuronCoarseSoma
2D region of the coarse cell body region (soma).
|
private NeuriteExtractor2D.NeuronColor |
neuronColor |
private MTBImageByte |
neuronImage
Define extractor parameters.
|
private MTBNeuriteSkelGraph |
neuronSkelGraph
NSG of the whole neuron.
|
private de.unihalle.informatik.Alida.datatypes.ALDDirectoryString |
outputDir |
private org.rosuda.JRI.Rengine |
rEngine
R engine to call R scripts.
|
private MTBImageByte |
skelImage
Binary skeleton image of the whole neuron.
|
private int |
width
Width of the binary neuron image.
|
Constructor and Description |
---|
NeuriteExtractor2D()
Standard constructor.
|
NeuriteExtractor2D(MTBImageByte _neuronImage,
NeuriteExtractor2D.NeuronColor _neuronColor,
int _neuriteMaskSize,
int _maxSpineLength,
org.rosuda.JRI.Rengine _rEngine,
String _outputDir)
Constructor to create a new neurite extraction object.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
callNeuriteScript(String sourceFile,
String scriptArg)
Call a specified R script for neurite calculations.
|
void |
cleanNeurites(MTBNeurite2DSet tmpNeuriteSet)
Method to clean up the extracted neurites, due to multiple features along a
NSG path or feature shifts at the start point due to different NSG lengths.
|
private org.rosuda.JRI.Rengine |
createRengine()
Method to generate a R thread inside the java application.
|
MTBImageByte |
drawLine2D(Line2D.Double line,
Point2D.Double point)
Draws a 2D line into the neuron image.
|
private MTBRegion2D |
generateCoarseSoma()
Compute a coarse neuron cell body region (soma).
|
private MTBRegion2DSet |
generateNeuriteRegions(Vector<Vector<Vector<Line2D.Double>>> lines,
Vector<Vector<Vector<Point2D.Double>>> points)
Generate neurite region from calculated features.
|
private MTBNeuriteSkelGraph |
generateSkelGraph()
Compute the skeleton graph for the complete neuron region.
|
private Line2D.Double |
getBorderLine(Point2D.Double p,
Point2D.Double normalVec)
Get borderlines between soma/neurite shaft and neurite shaft/growth cone.
|
MTBNeurite2DSet |
getExtractedNeurites()
Get extracted neurites as result of the NeuriteExtraction2D operator.
|
int |
getMaxSpineLength()
Get maximum length of a spine (filopodia-like protrusion) in pixel.
|
private Vector<Vector<Vector<Line2D.Double>>> |
getNeuriteFeatures(Vector<Point2D.Double> startPoints)
Method to calculate the neurite features from the neurite width profile.
|
int |
getNeuriteMaskSize()
Get neurite mask size in pixel.
|
NeuriteExtractor2D.NeuronColor |
getNeuronColor()
Get binary neuron color.
|
MTBImageByte |
getNeuronImage()
Get input image of the binary neuron.
|
private Point2D.Double |
getNormal(Point2D.Double p1,
Point2D.Double p2)
Get normal vector between two points.
|
org.rosuda.JRI.Rengine |
getREngine()
Get R engine.
|
private Vector<Point2D.Double> |
getStartPoints()
Get the skeleton start points of every single neurite from the inside of
the coarse cell body region.
|
private void |
init()
Initialization method.
|
protected void |
operate() |
private static boolean |
saveNeuriteWidthList(Vector<Double[]> neuriteWidths,
String file)
Method to save the neurites width profile in a file.
|
void |
setMaxSpineLength(int _maxSpineLength)
Set maximum length of a spine (filopodia-like protrusion) in pixel.
|
void |
setNeuriteMaskSize(int _neuriteMaskSize)
Set neurite mask size in pixel.
|
void |
setNeuronColor(NeuriteExtractor2D.NeuronColor _neuronColor)
Set binary neuron color.
|
void |
setNeuronImage(MTBImageByte _neuronImage)
Set input image of the binary neuron.
|
void |
setREngine(org.rosuda.JRI.Rengine _rEngine)
Set R engine.
|
private Point2D.Double |
standardization(Point2D.Double p)
Get unit vector.
|
void |
validateCustom()
Custom validation of some input parameters.
|
readResolve
addOperatorExecutionProgressEventListener, addParameter, addParameter, addParameterUnconditioned, fieldContained, fireOperatorExecutionProgressEvent, getALDPortHashAccessKey, getConstructionMode, getDocumentation, getHidingMode, getInactiveParameterNames, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterDescriptorUnconditioned, getParameterNames, getParameterUnconditioned, getSupplementalNames, getVerbose, getVersion, handleOperatorExecutionProgressEvent, hasInOutParameters, hasParameter, isAnnotatedParameter, isConfigured, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, removeOperatorExecutionProgressEventListener, removeParameter, runOp, runOp, runOp, setConstructionMode, setConstructionMode, setConstructionMode, setHidingMode, setName, setParameter, setParameterUnconditioned, setVerbose, toStringVerbose, unconfiguredItems, validate, validateGeneric, writeHistory, writeHistory, writeHistory
@Parameter(label="Binary Neuron Image", required=true, direction=IN, description="Binary neuron input image.", mode=STANDARD, dataIOOrder=0) private transient MTBImageByte neuronImage
@Parameter(label="Output Directory", required=true, direction=IN, description="Output directory for neurite extraction.", mode=STANDARD, dataIOOrder=1) private de.unihalle.informatik.Alida.datatypes.ALDDirectoryString outputDir
@Parameter(label="Neurite Mask Size", required=true, direction=IN, description="Neurite mask size in pixel.", mode=STANDARD, dataIOOrder=2) private int neuriteMaskSize
@Parameter(label="Binary Neuron Color", required=true, direction=IN, description="Binary color of the neuron.", mode=STANDARD, dataIOOrder=3) private NeuriteExtractor2D.NeuronColor neuronColor
@Parameter(label="Maximum Spine Length", required=true, direction=IN, description="Maximum length of a spine in pixel.", mode=STANDARD, dataIOOrder=4) private int maxSpineLength
@Parameter(label="Extracted Neurites", required=true, direction=OUT, description="Set of extracted neurites.") private transient MTBNeurite2DSet extractedNeurites
private transient int width
private transient int height
private transient org.rosuda.JRI.Rengine rEngine
private transient MTBRegion2D neuronCoarseSoma
private transient MTBNeuriteSkelGraph neuronSkelGraph
private transient MTBImageByte skelImage
private transient Vector<MTBNeuriteSkelGraph> neuriteGraphs
private transient Vector<Vector<Vector<Point2D.Double>>> featurePoints
private transient int[] neuriteShaftLengths
public NeuriteExtractor2D() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public NeuriteExtractor2D(MTBImageByte _neuronImage, NeuriteExtractor2D.NeuronColor _neuronColor, int _neuriteMaskSize, int _maxSpineLength, org.rosuda.JRI.Rengine _rEngine, String _outputDir) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
_neuronImage
- binary neuron image_neuronColor
- binary neuron color, e.g. 0 (black) or 255 (white)_neuriteMaskSize
- mask size of average neurite width, in pixel_maxSpineLength
- maximum length of a branch to define it as spine, in pixel_rEngine
- engine to call R scripts_outputFile
- file path for feature outputde.unihalle.informatik.Alida.exceptions.ALDOperatorException
public void validateCustom() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
validateCustom
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public MTBImageByte getNeuronImage()
public void setNeuronImage(MTBImageByte _neuronImage)
public NeuriteExtractor2D.NeuronColor getNeuronColor()
public void setNeuronColor(NeuriteExtractor2D.NeuronColor _neuronColor)
public int getNeuriteMaskSize()
public void setNeuriteMaskSize(int _neuriteMaskSize)
public org.rosuda.JRI.Rengine getREngine()
public void setREngine(org.rosuda.JRI.Rengine _rEngine)
public int getMaxSpineLength()
public void setMaxSpineLength(int _maxSpineLength)
public MTBNeurite2DSet getExtractedNeurites()
MTBNeurite2D
objects.private void init()
private org.rosuda.JRI.Rengine createRengine()
protected void operate() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
operate
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
private static boolean saveNeuriteWidthList(Vector<Double[]> neuriteWidths, String file)
neuriteWidths
- width values of the neuritefile
- file name for storing the dataprivate boolean callNeuriteScript(String sourceFile, String scriptArg)
sourceFile
- neurite calculation R script filescriptArg
- input directory path for the R scriptprivate MTBRegion2D generateCoarseSoma()
private MTBNeuriteSkelGraph generateSkelGraph()
private Vector<Point2D.Double> getStartPoints() throws NeuriteExtractor2DException
NeuriteExtractor2DException
private Vector<Vector<Vector<Line2D.Double>>> getNeuriteFeatures(Vector<Point2D.Double> startPoints)
startPoints
- points to build up the single neurite graphsprivate Line2D.Double getBorderLine(Point2D.Double p, Point2D.Double normalVec)
p
- feature pointnormalVec
- normal vector for feature pointprivate Point2D.Double getNormal(Point2D.Double p1, Point2D.Double p2)
p1
- first pointp2
- second pointprivate Point2D.Double standardization(Point2D.Double p)
p
- point of vector, other coordinate is (0,0)private MTBRegion2DSet generateNeuriteRegions(Vector<Vector<Vector<Line2D.Double>>> lines, Vector<Vector<Vector<Point2D.Double>>> points)
lines
- detected feature lines for every neuritepoints
- detected feature points for every feature linepublic MTBImageByte drawLine2D(Line2D.Double line, Point2D.Double point)
This function implements the Bresenham algorithm. Code was 'stolen' from
Wikipedia, http://de.wikipedia.org/wiki/Bresenham-Algorithmus
, and
then translated into Java (German comments where kept).
xstart
- x-coordinate of start point.ystart
- y-coordinate of start point.xend
- x-coordinate of end point.yend
- y-coordinate of end point.value
- Color/gray-scale value of the polygon.public void cleanNeurites(MTBNeurite2DSet tmpNeuriteSet)
tmpNeuriteSet
- current temporary neurite setCopyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.