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

Class barVectorSlide


An abstract class representing all types of vector slides - slides that are based on SVG drawings.


Attention: This class is an abstract class and should never be instanced.

Nested Classes [hide private]
Instance Methods [hide private]
 
__init__(self, slideTemplate='\n<svg baseProfile="full" id="body"\nheight="900"\nwidth="120..., slideNumber=0)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
[barStructureLabel, ...]
_getLabels(self)
Returns: labels of the SVG slide
{str : barMetadataElement, ...}
_getMetadata(self)
Returns: names of particular metadata to its representation mapping
 
updateMetadata(self, metadataList)
 
_setMetadata(self, metadataElement)
Add metadata to the slide.
 
addLabel(self, newLabel)
Add label to the slide.
xml.dom.minidom.Document
_getSlideTemplate(self)
Returns: SVG slide template
 
_setSlideTemplate(self, newSlideTemplate)
Assign new slide template.
 
_validateSlideTemplate(self, newSlideTemplate)
A stub of method.
 
alignToRefMatrix(self, refTuple)
Transform slide in the way that current transformation matrix will be equal to refTuple.
 
Show(self, binFile='eog', tempFilename='/tmp/barTemp.svg')
Display the slide in external SVG browser.
 
getLabelByName(self, labelCaption, labelType=None, oType='id')
Find labels matching searching criteria (caption of the label and optionally its type).
 
retypeLabelByCaption(self, labelCaption, targetType)
Change class of representation of the requested label.
 
deleteLabelByCaption(self, labelCaption)
Remove from the slide every label of requested caption.
 
deleteLabelByID(self, labelID)
Remove from the slide label of requested ID.
 
renameLabelByCaption(self, oldCaption, newCaption)
Change the caption of every label of requested caption.
[labelType]
__getAllLabelsWithType(self, labelType)
Returns: labels of requested type contained in the slide
 
__affineTransform(self, M)
Transform the location of all paths in SVG coordinate system.
barVectorSlide
affineTransform(self, M)
Transform the location of all paths in SVG coordinate system.
 
__validateMetadata(self)
Check if all necessary metadata elements are provided.
(float, float) or (float, float, float)
svg2srs(self, svgCoord, ndims=2)
Returns: spatial coordinates corresponding to given svg coordinates
(float, float)
srs2svg(self, spatialCoord)
Returns: SVG coordinates corresponding to provided spatial coordinates
 
getCommentLabels(self)
An alias to self.__getAllLabelsWithType(self._clsCommentLabel).
 
getRegularLabels(self)
An alias to self.__getAllLabelsWithType(self._clsRegularLabel).
 
getSpotLabels(self)
An alias to self.__getAllLabelsWithType(self._clsSpotLabel).
{str : barStructureLabel}
_generateLabelIndex(self)
Returns: label identifier to label representation mapping

Inherited from barObject: __str__, getElementById, getXMLelement, writeXMLtoFile

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

Class Methods [hide private]
xml.dom.minidom.Document
_fromXML_ParseXML(cls, svgDocument, fixDrawing)
Part of XML parsing subroutine responsible for parsing given SVG document into xml.dom.minidom object.
 
_fromXML_BeforeCleanUpHook(cls, slide, svgdom)
Customization hook allowing the developers implementing additional methods or features during parsing of XML document.
 
_fromXML_AfterCleanUpHook(cls, slide, svgdom)
Customization hook allowing the developers implementing additional methods or features during parsing of XML document.
None
_fromXML_LoadMetadata(cls, slide, svgdom)
Part of XML parsing subroutine responsible for extracting metadata from provided XML element corresponding to CAF slide.
None
_fromXML_Cleanup(cls, slide, svgdom)
Part of XML parsing subroutine responsible for preparing XML template for given slide.
Static Methods [hide private]

Inherited from barObject (private): _getAttributesDict

Instance Variables [hide private]
xml.dom.minidom.Document slideTemplate
an empty SVG document which can be filled with labels, structures and metadata
{str : barStructureLabel, ...} _labels
label ID to label representation mapping
{str : barMetadataElement, ...} _metadata
names of particular metadata to its representation mapping
int slideNumber
slide number
Properties [hide private]
[barStructureLabel, ...] labels
Labels of the slide.
{str : barStructureLabel} labelIndex
Label identifier to label representation mapping.
{str : barMetadataElement, ...} metadata
Slide metadata.

Inherited from object: __class__

Method Details [hide private]

__init__(self, slideTemplate='\n<svg baseProfile="full" id="body"\nheight="900"\nwidth="120..., slideNumber=0)
(Constructor)

 

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

Parameters:
  • slideTemplate (str) - SVG slide template
  • slideNumber (int) - slide number
Overrides: object.__init__

_getLabels(self)

 
Returns: [barStructureLabel, ...]
labels of the SVG slide

_getMetadata(self)

 
Returns: {str : barMetadataElement, ...}
names of particular metadata to its representation mapping

_setMetadata(self, metadataElement)

 

Add metadata to the slide.

Parameters:

addLabel(self, newLabel)

 

Add label to the slide.

Parameters:

_getSlideTemplate(self)

 
Returns: xml.dom.minidom.Document
SVG slide template

_setSlideTemplate(self, newSlideTemplate)

 

Assign new slide template.

Parameters:
  • newSlideTemplate (str) - new slide template

To Do: Add slide validation before replacing the template. See _validateSlideTemplate.

_validateSlideTemplate(self, newSlideTemplate)

 

A stub of method.

To Do: Implement template validation.

alignToRefMatrix(self, refTuple)

 

Transform slide in the way that current transformation matrix will be equal to refTuple.

Workflow:

  1. Get initial transformation matrix from metadata.
  2. Calculate corrections basing on initial transformation matrix and reference matrix.
  3. Embed corrections as SVG transformation and put corrected transformation matrix as 3dBAR metedata.
Parameters:
  • refTuple ((float, float, float, float)) - reference transformation matrix (sxref, xref, syref, yref) for aligning

Note: Scaling can be either positive and negative. When scaling is positive it means that stereotaxic axis has the same direction as image axis. When scaling is negative stereotaxic and image axes are oriented in opposite directions. Be very careful in such case.

Show(self, binFile='eog', tempFilename='/tmp/barTemp.svg')

 

Display the slide in external SVG browser.

Parameters:
  • binFile (str) - name of the executable file that will be used instead of the detault SVG browser
  • tempFilename (str) - temporary file name used to store svg slide

getLabelByName(self, labelCaption, labelType=None, oType='id')

 

Find labels matching searching criteria (caption of the label and optionally its type).

Parameters:
  • labelCaption (str) - caption of the label
  • labelType (class) - the label class
  • oType (str) - When set to 'id' IDs of selected labels are returned, if 'ref' references are returned
Returns:
depends on oType

retypeLabelByCaption(self, labelCaption, targetType)

 

Change class of representation of the requested label.

Parameters:
  • targetType (class) - new class of the label representation
  • labelCaption (str) - caption of labels which representation class has to be changed

deleteLabelByCaption(self, labelCaption)

 

Remove from the slide every label of requested caption.

Parameters:
  • labelCaption (str) - caption of labels to be daleted

deleteLabelByID(self, labelID)

 

Remove from the slide label of requested ID.

Parameters:
  • labelID (str) - identifier of the label to be deleted

renameLabelByCaption(self, oldCaption, newCaption)

 

Change the caption of every label of requested caption.

Parameters:
  • oldCaption (str) - caption to be replaced
  • newCaption (str) - new caption of labels of caption oldCaption

__getAllLabelsWithType(self, labelType)

 
Parameters:
  • labelType (class) - requested type of labels
Returns: [labelType]
labels of requested type contained in the slide

__affineTransform(self, M)

 

Transform the location of all paths in SVG coordinate system.

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

affineTransform(self, M)

 

Transform the location of all paths in SVG coordinate system.

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

__validateMetadata(self)

 

Check if all necessary metadata elements are provided. If not - raise KeyError.

svg2srs(self, svgCoord, ndims=2)

 
Parameters:
  • svgCoord ((float, float)) - coordinates in svg coordinate system to be converted into spatial coordinates.
  • ndims (int) - number of dimensions of returned value (determines if output value will be 2 or 3 dimensional; when ndims == 3 coronal coordinate is also included)
Returns: (float, float) or (float, float, float)
spatial coordinates corresponding to given svg coordinates

Requires: All metadata has to be provided and correct.

srs2svg(self, spatialCoord)

 
Parameters:
  • spatialCoord ((float, float)) - spatial coorrdinate to be converted into SVG coordinate
Returns: (float, float)
SVG coordinates corresponding to provided spatial coordinates

Requires: All metadata has to be provided and correct.

_generateLabelIndex(self)

 
Returns: {str : barStructureLabel}
label identifier to label representation mapping

_fromXML_ParseXML(cls, svgDocument, fixDrawing)
Class Method

 

Part of XML parsing subroutine responsible for parsing given SVG document into xml.dom.minidom object. This method may be overriden in subclasses if more features are required.

Parameters:
  • svgDocument (xml.dom.minidom.Document or str or file) - SVG slide (DOM XML or filename or file handler)
  • fixDrawing (bool) - indicates if path definitions has to be redefined with absolute coordinates
Returns: xml.dom.minidom.Document
xml.dom.minidom.Document

_fromXML_BeforeCleanUpHook(cls, slide, svgdom)
Class Method

 

Customization hook allowing the developers implementing additional methods or features during parsing of XML document. This hook is executed after parsing whole slide, just before cleaning all unnecessary elements and extracting slide template.

_fromXML_AfterCleanUpHook(cls, slide, svgdom)
Class Method

 

Customization hook allowing the developers implementing additional methods or features during parsing of XML document. This hook is executed just after removing all unnecessary elements and before assigning slide's template.

_fromXML_LoadMetadata(cls, slide, svgdom)
Class Method

 

Part of XML parsing subroutine responsible for extracting metadata from provided XML element corresponding to CAF slide. This method can be overriden in subclasses if more features are required.

Parameters:
  • slide (barVectorSlide) - Slide to which metadata extracted from svgdom will be assigned
  • svgdom (xml.dom.minidom.Document or str or file) - SVG slide (DOM XML or filename or file handler)
Returns: None
None

_fromXML_Cleanup(cls, slide, svgdom)
Class Method

 

Part of XML parsing subroutine responsible for preparing XML template for given slide. This method can be overriden in subclasses if more features are required.

Parameters:
  • slide (barVectorSlide) - Currently processed slide.
  • svgdom (xml.dom.minidom.Document or str or file) - SVG slide (DOM XML or filename or file handler)
Returns: None
None

Instance Variable Details [hide private]

slideTemplate

SVG slide template.

Property of non-consistent type.

Get Method:
_getSlideTemplate(self) - Returns: SVG slide template
Set Method:
_setSlideTemplate(self, newSlideTemplate) - Assign new slide template.
Type:
xml.dom.minidom.Document

Property Details [hide private]

labels

Labels of the slide.

Read-only property.

Get Method:
_getLabels(self) - Returns: labels of the SVG slide
Type:
[barStructureLabel, ...]

labelIndex

Label identifier to label representation mapping.

Read-only property.

Get Method:
_generateLabelIndex(self) - Returns: label identifier to label representation mapping
Type:
{str : barStructureLabel}

metadata

Slide metadata.

Property of non-consistent type.

Get Method:
_getMetadata(self) - Returns: names of particular metadata to its representation mapping
Type:
{str : barMetadataElement, ...}