Package bar :: Module base :: Class barPath
[hide private]
[frames] | no frames]

Class barPath


Class of objects describing enclosed path denoting particular area in the slice.

Note that 'path' does not mean 'structure' because structure may consist of many paths.

Nested Classes [hide private]
Instance Methods [hide private]
 
__init__(self, pathID, pathDefinition, fillColor, properties=None, clearPathDef=False)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
str
_getPathDefinition(self)
Returns: SVG path definition
 
_setPathDefinition(self, newPathDefinition, clearPathDef=False)
Assign the path definition.
bool
_validatePath(self, pathDefinition)
Validate SVG path definition: Path definition has to contain at least three points and 'closepath'command in order to be considered as valid path.
int
_getGrowlevel(self)
Returns: gap filling level for the path
 
_setGrowlevel(self, Growlevel=None)
Set gap filling level for the path.
 
_validateID(self, id)
Validate identifier of the path.
 
_setID(self, newPathID)
Assign the identifier of the path.
str
_getID(self)
Returns: SVG path identifier
str
_getPathType(self)
Returns: value of 'type' property
 
_setPathType(self, newPathType)
Assign the value of the 'type' property.
(int, int, int, int)
_getBbox(self)
Return value of the 'boundingBox' property.
 
_setBbox(self, newBBox)
Raise ValueError
str
_getColor(self)
Returns: fill colour of the path in hexadecimal represenatation
 
_setColor(self, newColor)
Assign the fill colour of the path.
str
_getCorrespondingStructureName(self)
Returns: name of the structure corresponding to the path
str
_getCorrespondingLabelID(self)
Returns: identifier of the corresponding label
 
_setCorrespondingLabelID(self, newID)
Raise ValueError.
 
_rename(self, newStructName)
Change the structure corresponding to the path.
 
__affineTransform(self, M)
Transform the location of the path in SVG coordinate system.
 
affineTransform(self, M)
An alias for self.__affineTransform(M).
 
__setCrispEdges(self, boolValue)
Set the value of 'shape-rendering' attribute.
bool
__getCrispEdges(self)
Returns: True when the value of 'shape-rendering' attribute is 'crisp-edges', False otherwise.

Inherited from barAtlasSlideElement: getXMLelement

Inherited from barAtlasSlideElement (private): _getTextNodeXMLelement

Inherited from barObject: __str__, getElementById, writeXMLtoFile

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]
cls
fromXML(cls, svgPathElement, clearPathDef=False)
Create path object from its XML representation.
Static Methods [hide private]
str
simplifyPathDef(pathDefinition)
Change definition of path to absolute coordinates and eliminate all command shortcuts.

Inherited from barObject (private): _getAttributesDict

Class Variables [hide private]
str _elementName = 'path'
name of the represented XML element

Inherited from barAtlasSlideElement (private): _attributes, _attributesNS

Properties [hide private]
str id
The path identifier.
string type
Attribute holding type of the feature delineated by given path.
int growlevel
Gap filling level for the path.
str pathDef
The SVG path definition.
(int, int, int, int) boundingBox
The path bounding box description (x1, y1, x2, y2), where x1, y2 are coordinates of top-left corner of bounding box and x2, y2 are coordinates of bottom-right corner of bounding box.
(int, int, int, int) bbx
An alias for boundingBox property.
str color
The fill colour of the path in hexadecimal represenatation.
str structName
Name of the structure corresponding to the path.
str relLabelID
The identifier of the label corresponding to the path.
bool crispEdges
Property related to the 'shape-rendering' SVG path attribute.

Inherited from object: __class__

Method Details [hide private]

__init__(self, pathID, pathDefinition, fillColor, properties=None, clearPathDef=False)
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • pathID (str) - identifier of the path element that will be stored as path id in XML representation (valid path id)
  • pathDefinition (str) - definition of the path (valid SVG path definition)
  • fillColor (str) - color string in hexadecimal format (might begin with "#" char or not)
  • properties ({str : ?}) - SVG attribute name to value mapping appended to the XML representation of the path
  • clearPathDef (bool) - indicates if the pathDefinition has to be converted to parser-compatible format
Overrides: object.__init__

fromXML(cls, svgPathElement, clearPathDef=False)
Class Method

 

Create path object from its XML representation.

Parameters:
  • svgPathElement (xml.dom.node) - XML representation of the object
Returns: cls
created object
Overrides: barAtlasSlideElement.fromXML

simplifyPathDef(pathDefinition)
Static Method

 

Change definition of path to absolute coordinates and eliminate all command shortcuts.

Parameters:
  • pathDefinition (str) - path definition
Returns: str
simplified path

_getPathDefinition(self)

 
Returns: str
SVG path definition

_setPathDefinition(self, newPathDefinition, clearPathDef=False)

 

Assign the path definition.

Parameters:
  • newPathDefinition (str) - new SVG path definition
  • clearPathDef (bool) - indicates if the newPathDefinition has to be validated and converted to parser-compatible format; if true and newPathDefinition is invalid raise ValueError

_validatePath(self, pathDefinition)

 

Validate SVG path definition: Path definition has to contain at least three points and 'closepath'command in order to be considered as valid path.

Parameters:
  • pathDefinition (str) - SVG path definition to be validated.
Returns: bool
True, if path definition is correct, False otherwise

_getGrowlevel(self)

 
Returns: int
gap filling level for the path

_setGrowlevel(self, Growlevel=None)

 

Set gap filling level for the path.

Parameters:
  • Growlevel (int) - new level of gap filling that should be forced when tracing is performed

_validateID(self, id)

 

Validate identifier of the path.

The basic rule of valid 3dBAR path id is that it is list of values separated with '_' (underscore) character. First value has to start exactly with 'structure' string, the second element is an actual uniqe id of the path while the last value is name of structure represented by particular path.

Renember: NO SPACES are allowed!

Example of proper 3dBAR path id is 'structureXX_genetared-from-label-6_Olf' while wrong definition could be 'str_Olf_from label 87'

Parameters:
  • id (str) - SVG path identifier to be validated

Note: Method does not validate uniqness of given ID, only it's formal corectness.

_setID(self, newPathID)

 

Assign the identifier of the path.

Parameters:
  • newPathID (str) - new value of SVG path identifier

_getID(self)

 
Returns: str
SVG path identifier

_getPathType(self)

 
Returns: str
value of 'type' property

_setPathType(self, newPathType)

 

Assign the value of the 'type' property.

Parameters:
  • newPathType (str) - new value of the 'type' property

_getBbox(self)

 

Return value of the 'boundingBox' property.

Returns: (int, int, int, int)
the bounding box description (x1, y1, x2, y2)

_getColor(self)

 
Returns: str
fill colour of the path in hexadecimal represenatation

_setColor(self, newColor)

 

Assign the fill colour of the path.

Parameters:
  • newColor (str) - new fill colour of the path in hexadecimal format (may begin with "#" char or not)

_getCorrespondingStructureName(self)

 
Returns: str
name of the structure corresponding to the path

_getCorrespondingLabelID(self)

 
Returns: str
identifier of the corresponding label

_rename(self, newStructName)

 

Change the structure corresponding to the path.

Parameters:
  • newStructName (str) - name of the new structure corresponding to the path

__affineTransform(self, M)

 

Transform the location of the path in SVG coordinate system.

Parameters:
  • M (numpy 3x3 array) - transformation matrix

affineTransform(self, M)

 

An alias for self.__affineTransform(M).

Parameters:
  • M - transformation matrix
Overrides: barAtlasSlideElement.affineTransform

__setCrispEdges(self, boolValue)

 

Set the value of 'shape-rendering' attribute.

Parameters:
  • boolValue (bool) - True if 'shape-rendering' has to be 'crisp-edges', False if it has to be 'geometric-precision'

__getCrispEdges(self)

 
Returns: bool
True when the value of 'shape-rendering' attribute is 'crisp-edges', False otherwise.

Property Details [hide private]

id

The path identifier.

Get Method:
_getID(self) - Returns: SVG path identifier
Set Method:
_setID(self, newPathID) - Assign the identifier of the path.
Type:
str

type

Attribute holding type of the feature delineated by given path. For example it can be like 'gray matter', 'white matter', 'single cell', 'ventricle', and other... This property would be extended when INCF DAI common metadata set will be well established.

Get Method:
_getPathType(self) - Returns: value of 'type' property
Set Method:
_setPathType(self, newPathType) - Assign the value of the 'type' property.
Type:
string

growlevel

Gap filling level for the path.

Baceuse barPath class is used in already traced files, gap filling level describes with which gap filling level tracing was performed. So in such case it has only informative purpose.

By default Growlevel is set to 0 which means that no erosion filter was applied.

Get Method:
_getGrowlevel(self) - Returns: gap filling level for the path
Set Method:
_setGrowlevel(self, Growlevel=None) - Set gap filling level for the path.
Type:
int

pathDef

The SVG path definition.

Get Method:
_getPathDefinition(self) - Returns: SVG path definition
Set Method:
_setPathDefinition(self, newPathDefinition, clearPathDef=False) - Assign the path definition.
Type:
str

boundingBox

The path bounding box description (x1, y1, x2, y2), where x1, y2 are coordinates of top-left corner of bounding box and x2, y2 are coordinates of bottom-right corner of bounding box.

Please note that bounding box is only approximation of actual bounding box and may be slightly larger as it is based on extreme coordinated of control points creating given path. However, the difference is neglectable.

Read-only property.

Get Method:
_getBbox(self) - Return value of the 'boundingBox' property.
Set Method:
_setBbox(self, newBBox) - Raise ValueError
Type:
(int, int, int, int)

bbx

An alias for boundingBox property.

Get Method:
_getBbox(self) - Return value of the 'boundingBox' property.
Set Method:
_setBbox(self, newBBox) - Raise ValueError
Type:
(int, int, int, int)

color

The fill colour of the path in hexadecimal represenatation.

Get Method:
_getColor(self) - Returns: fill colour of the path in hexadecimal represenatation
Set Method:
_setColor(self, newColor) - Assign the fill colour of the path.
Type:
str

structName

Name of the structure corresponding to the path.

Get Method:
_getCorrespondingStructureName(self) - Returns: name of the structure corresponding to the path
Set Method:
_rename(self, newStructName) - Change the structure corresponding to the path.
Type:
str

relLabelID

The identifier of the label corresponding to the path.

Read-only property.

Get Method:
_getCorrespondingLabelID(self) - Returns: identifier of the corresponding label
Set Method:
_setCorrespondingLabelID(self, newID) - Raise ValueError.
Type:
str

crispEdges

Property related to the 'shape-rendering' SVG path attribute.

See getter and setter for details.

Get Method:
__getCrispEdges(self) - Returns: True when the value of 'shape-rendering' attribute is 'crisp-edges', False otherwise.
Set Method:
__setCrispEdges(self, boolValue) - Set the value of 'shape-rendering' attribute.
Type:
bool