Eidolon
Classes | Functions | Variables
eidolon.plugins.SegmentPlugin Namespace Reference

Classes

class  LVSeg2DMixin
 
class  LVSegView
 
class  Seg2DWidget
 
class  SegmentPlugin
 
class  SegPropertyWidget
 
class  SegSceneObject
 

Functions

def getContourPlane (contour)
 
def contourOnPlane (contour, center, norm)
 
def contoursCoplanar (con1, con2)
 
def adjustContoursToImage (seg, image)
 
def yieldContourIntersects (ray, contour)
 
def pointInContour (pt, contour, plane=None, bb=None, center=None)
 
def reinterpolateContour (contour, elemtype, refine, numnodes)
 
def reinterpolateCircularContour (contour, elemtype, startdir, refine, numnodes)
 
def getContourRelativeDir (contours, pos)
 
def sortContours (contours, startdir=None)
 
def triangulateContour (contour, skipErrors=False)
 
def estimateHemiThickness (contours)
 
def getHemiAxis (contours)
 
def getHemisphereControls (contours, inner=True)
 
def mapContoursToPlanes (contours)
 
def generateContoursFromMask (images, numctrls, innerSeg=True, minSegSize=100, refine=2, task=None)
 
def generateApexContours (contours, scale=0.5, givenapex=None)
 
def calculateAHAField (nodes, xis, inds, topcenter, norm, apex, startpos, include17)
 
def calculateCavityField (xis, inds)
 
def cartToPolarXi (n)
 
def generatePCRTriHemisphere (ctrls, refine, task=None)
 
def generatePCRTetHemisphere (ctrls, refine, task=None)
 
def generateDefaultHemisphereMesh (refine, center, scale, outerrad, innerrad, numctrls=36, numrings=12)
 
def generateHemisphereSurface (name, contours, refine, startpos, apex=None, reinterpolateVal=0, calcAHA=False, elemtype=None, innerSurface=True, task=None)
 
def generateHemisphereVolume (name, contours, refine, startpos, apex=None, reinterpolateVal=0, calcAHA=False, elemtype=None, innerOnly=True, task=None)
 
def generateImageMaskRange (process, contours, contourtimes, planes, images, labelfunc)
 
def generateImageMask (name, contours, contourtimes, template, labelfunc='1', task=None)
 

Variables

 DatafileParams = enum('name','title','type','srcimage')
 
 SegmentTypes = enum('LVPool','LV')
 
string segExt = '.seg'
 
int defaultNumNodes = 16
 
 SegViewPoints
 

Function Documentation

◆ adjustContoursToImage()

def eidolon.plugins.SegmentPlugin.adjustContoursToImage (   seg,
  image 
)

◆ calculateAHAField()

def eidolon.plugins.SegmentPlugin.calculateAHAField (   nodes,
  xis,
  inds,
  topcenter,
  norm,
  apex,
  startpos,
  include17 
)
Calculates an AHA field for the hemisphere defined by (nodes,inds,xis). The plane defined by (topcenter,norm) should be
the top of the hemisphere aligned with the center axis. The `apex' node should be node at the bottom of the inside
surface. The `startpos' vector is a point in space which marks the plane the regions should start from, so if this is
below `topcenter' then nodes above that plane will be put in region 18. If `include17' is True then region 17 at
the apex is defined, otherwise regions 13-16 extend to the bottom (eg. for pool meshes). Vector `norm' should be
the long axis normal pointing from top to apex. The return value is a RealMatrix defining a per-element field which
assigns each element to a AHA region or 18 if below `startpos'.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateCavityField()

def eidolon.plugins.SegmentPlugin.calculateCavityField (   xis,
  inds 
)
Calculates a pseudo-AHA field for a cavity mesh. This is done base entirely on radial direction.
Here is the call graph for this function:

◆ cartToPolarXi()

def eidolon.plugins.SegmentPlugin.cartToPolarXi (   n)
Converts a cartesian coordinate `n' on the unit sphere to a xi coordinate in a hemisphere space with xi_2=0. The
process is to convert `n' to polar space then convert that coordinate to xi space where xi_0 is the circumferential
angle around the whole hemisphere, xi_1 is the height value from the rim to the apex, and xi_2 is the depth value
from the inner to outer surface (always 0 with this function). All xi values range over the unit interval.

◆ contourOnPlane()

def eidolon.plugins.SegmentPlugin.contourOnPlane (   contour,
  center,
  norm 
)
Returns True if the points of `contour' are on the plane (center,norm).
Here is the caller graph for this function:

◆ contoursCoplanar()

def eidolon.plugins.SegmentPlugin.contoursCoplanar (   con1,
  con2 
)
Returns True if the plane normals of `con1' and `con2' match and the barycenter of `con2' is on the plane of `con1'.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ estimateHemiThickness()

def eidolon.plugins.SegmentPlugin.estimateHemiThickness (   contours)
Estimate the thickness of the hemisphere defined by sorted contour list `contours' by averaging the difference in
bound box radii of coplanar contours. If `contours' defines a surface, 0 is returned.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateApexContours()

def eidolon.plugins.SegmentPlugin.generateApexContours (   contours,
  scale = 0.5,
  givenapex = None 
)
Given contours for a hemisphere in top-to-bottom sorted order, define extra contours and an apex point which will
close off the bottom of the hemisphere and maintain continuity. Return the final apex and a list of contour lists
containing the mid ring, a contour entirely composed of final apex points, and the inverted mid ring needed for
continuity when interpolating up to the apex.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateContoursFromMask()

def eidolon.plugins.SegmentPlugin.generateContoursFromMask (   images,
  numctrls,
  innerSeg = True,
  minSegSize = 100,
  refine = 2,
  task = None 
)
Generate contours for the masks given in the list of ShareImage objects `images'. This returns a list of 
(timestep,nodes list) pairs of contours with `numctrls' number of nodes are in world space coordinates. An outer
contour for each non-blank image is first created, if the area of this is greater than `minSegSize' then it is added
to the result list. If `innerSeg' is True then there is expected to be an inner region which is then also converted 
to a contour. The `refine' value sets the refinement of the contour interpolation function used when reducing contours.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateDefaultHemisphereMesh()

def eidolon.plugins.SegmentPlugin.generateDefaultHemisphereMesh (   refine,
  center,
  scale,
  outerrad,
  innerrad,
  numctrls = 36,
  numrings = 12 
)
Generates a uniform hemisphere with the top center at `center', scaled by vector `scale', with an outer radius of
`outerrad' and inner radius of `innerad' (the thickness of the hemisphere will uniformly be outerrad-innerrad). The
values `numctrls' and `numrings' control how many control points are created for the control point matrix.
Here is the call graph for this function:

◆ generateHemisphereSurface()

def eidolon.plugins.SegmentPlugin.generateHemisphereSurface (   name,
  contours,
  refine,
  startpos,
  apex = None,
  reinterpolateVal = 0,
  calcAHA = False,
  elemtype = None,
  innerSurface = True,
  task = None 
)
Create a hemisphere triangle mesh for the contour set `contours' which are expected to define a tube for which an
apex will be added. The contours will be sorted in order along a common axis with the largest topmost since this
routine is expecting a hemispherical shape. The `startdir' direction is used to sort the control points of each
contour to align them, as best as possible, on an axis from the contour's center in the direction of `startdir'
so that there's minimal twisting in the mesh. The contours are expected to use a continuous basis `elemtype'
such that node ordering doesn't affect shape (eg. Line1PCR).

If `reinterpolateVal' is a value greater than 0, each contour with N control points is reinterpolated to have that
many times N new control points, the first will be on the ray from each contour's center and pointing in the
direction `startdir'. This will almost certainly change the mesh's shape but a large `reinterpolateVal' value
(such as 20) will minimize this.

The resulting contour control points are amalgamated into the control points for a Quad2PCR surface. Xi values for
a geodesic hemisphere (a buckydome) are calculated on this surface to produce the hemisphere. This routine will
produce a mesh with 10*(4**(refine+1)) triangles. A field defining which regions of the AHA division scheme each
element belongs to is also generated, assuming that `startdir' points towards the center of the RV.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateHemisphereVolume()

def eidolon.plugins.SegmentPlugin.generateHemisphereVolume (   name,
  contours,
  refine,
  startpos,
  apex = None,
  reinterpolateVal = 0,
  calcAHA = False,
  elemtype = None,
  innerOnly = True,
  task = None 
)
Create a hemisphere tetrahedral mesh for the contour set `contours' which are expected to define a tube for which an
apex will be added. The contours will be sorted in order along a common axis with the largest topmost since this
routine is expecting a hemispherical shape. The `startdir' direction is used to sort the control points of each
contour to align them, as best as possible, on an axis from the contour's center in the direction of `startdir'
so that there's minimal twisting in the mesh. The contours are expected to use a continuous basis `elemtype'
such that node ordering doesn't affect shape (eg. Line1PCR).

If `reinterpolateVal' is a value greater than 0, each contour with N control points is reinterpolated to have that
many times N new control points, the first will be on the ray from each contour's center and pointing in the
direction `startdir'. This will almost certainly change the mesh's shape but a large `reinterpolateVal' value
(such as 20) will minimize this.

The resulting contour control points are amalgamated into the control points for a Hex3PCR volume. Xi values for
a geodesic hemisphere (a buckydome) are calculated on the xi_2=0 and xi_2=1 surfaces of this volume to produce a
mesh composed of prism elements, these are decomposed into tetrahedrons in a way that allows adjacent elements to
have adjacent faces. If `innerOnly' is True then a mesh within the inner contours is produced, if False then the
contour set is expected to have 2 contours per plane defining and inner and outer boundary for which a hollow
hemispherical mesh will be produced.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateImageMask()

def eidolon.plugins.SegmentPlugin.generateImageMask (   name,
  contours,
  contourtimes,
  template,
  labelfunc = '1',
  task = None 
)
Generate a mask image from the given contour segmentation `contours'. The image `template' is used as the spatial
definition of the resulting image, the contours are expected to be coplanar with the planes of this image. The
expression `labelfunc' determines what the mask value should be for each pixel found within at least one contour.
It will have available to it the point `pt' in image coordinate space corresponding to the current pixel, the
SharedImage `img' currently being filled, and `contours' list of contour objects in image coordinate space which
`pt' falls within. The default expression will set any pixel within a contour to 1, ie. a binary mask. The `contours'
list should contain lists of vec3 nodes in world space coordinates, and `contourtimes' a timestep value for each 
contour to align each correctly in time. 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generateImageMaskRange()

def eidolon.plugins.SegmentPlugin.generateImageMaskRange (   process,
  contours,
  contourtimes,
  planes,
  images,
  labelfunc 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generatePCRTetHemisphere()

def eidolon.plugins.SegmentPlugin.generatePCRTetHemisphere (   ctrls,
  refine,
  task = None 
)
Generate a hemispherical tet mesh from the control point lattice `ctrls' with refinement value `refine'. The number
of total tets is 140*(4**(`refine'+1)). The `ctrls' lattice is expected to be indexed in ZYX order, len(ctrls)==2.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generatePCRTriHemisphere()

def eidolon.plugins.SegmentPlugin.generatePCRTriHemisphere (   ctrls,
  refine,
  task = None 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getContourPlane()

def eidolon.plugins.SegmentPlugin.getContourPlane (   contour)
Returns the plane definition for the contour points `contour'. The (center,normal) pair is the barycenter of the
points in `contour' and the normal is calculated as the 3 point normal with `center', the first point in `contour',
and a second point farther from the first point than the average distance between successive points. This routine
assumes the points of `contour' are in circular order, actually do lie on a common plane, and are not colinear.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getContourRelativeDir()

def eidolon.plugins.SegmentPlugin.getContourRelativeDir (   contours,
  pos 
)
Given a list of unsorted contours `contours' and a position `pos', returns a direction in plane with the largest
contour which points from the contour center to `pos'.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHemiAxis()

def eidolon.plugins.SegmentPlugin.getHemiAxis (   contours)
For the given sorted hemisphere contours, returns the normal of the shape pointing from top to apex.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHemisphereControls()

def eidolon.plugins.SegmentPlugin.getHemisphereControls (   contours,
  inner = True 
)
Get the control points from the contour list `contours' defining a hemisphere surface, assuming `contours' defines
a volume hemisphere segmentation. If `inner' is True then the inner segmentation is chosen, the outer otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mapContoursToPlanes()

def eidolon.plugins.SegmentPlugin.mapContoursToPlanes (   contours)
Returns a map relating (center,normal) pairs to a list of contours lying on that plane. The `contours' list should
contains tuples of the form (nodes,name,timestep) storing the nodes in world space as 3-tuples, contour name, and
contour timestep respective. Each value in the returned map will be sorted in temporal order.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pointInContour()

def eidolon.plugins.SegmentPlugin.pointInContour (   pt,
  contour,
  plane = None,
  bb = None,
  center = None 
)
Returns True if `pt' is within `contour', which is on plane `plane' if given and has BoundBox `bb' if given.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reinterpolateCircularContour()

def eidolon.plugins.SegmentPlugin.reinterpolateCircularContour (   contour,
  elemtype,
  startdir,
  refine,
  numnodes 
)
Reinterpolate `contour' with basis `elemtype' to produce a new one with `numnodes' control nodes. A polygon of
refine*len(contour) vertices is first calculated by interpolating at even-spaced xi distances along the contour
(which assumes it's circular). A ray is then cast from the center of the polygon at regular angle intervals starting
from the direction of `startdir'. The intersection points of these rays with the polygon are used as the control
points for the resulting contour. The result is guaranteed to have coplanar points which are uniformly distributed
in space, but is only an approximation of the shape defined by `contour'. This approximation becomes closer with
increasing values of both `refine' and `numnodes' (only one being large won't accomplish much). The more circular
`contour' is the smoother and more accurate the result, but more than that `contour' cannot overlap itself.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reinterpolateContour()

def eidolon.plugins.SegmentPlugin.reinterpolateContour (   contour,
  elemtype,
  refine,
  numnodes 
)
Reinterpolate `contour' with basis `elemtype' to produce a new one with `numnodes' control nodes. A polygon of
refine*len(contour) vertices is first calculated by interpolating at even-spaced xi distances along the contour.
The algorithm then chooses `numnodes' nodes from this polygon that are roughly evenly spaced apart and returns them.
Here is the call graph for this function:

◆ sortContours()

def eidolon.plugins.SegmentPlugin.sortContours (   contours,
  startdir = None 
)
Accepts a 2D matrix of contour vec3 points `contours' plus a vector `startdir' pointing in the, direction considered
to be to the right of the contour stack and sorts the contours in order from top to bottom. The `startdir' value is
used to reorder the points of each contour so that the first point is on the ray pointing from the center of the
contour in the direction of `startdir'. If this argument isn't given then this sorting isn't done. The resulting
contour 2D matrix contains vec3 objects.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ triangulateContour()

def eidolon.plugins.SegmentPlugin.triangulateContour (   contour,
  skipErrors = False 
)
Returns a list of index triples for a triangulation of `contour', assuming it doesn't overlap itself. This uses the
triangulation by ear reduction algorithm. If `skipErrors' is True, any time an ear can't be found a guess is made,
this ensures the algorithm works if `contour' overlaps itself but will likely produce an overlapping triangulation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ yieldContourIntersects()

def eidolon.plugins.SegmentPlugin.yieldContourIntersects (   ray,
  contour 
)
Yield each position in space where `ray' intersects a line segment between successive points in `contour'.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ DatafileParams

DatafileParams = enum('name','title','type','srcimage')

◆ defaultNumNodes

int defaultNumNodes = 16

◆ segExt

string segExt = '.seg'

◆ SegmentTypes

SegmentTypes = enum('LVPool','LV')

◆ SegViewPoints

SegViewPoints
Initial value:
1 = enum(
2  ('rvAttach','RV Anterior Attachment',color(1,0,1)),
3  ('ch2Apex','2 Chamber Long Axis Apex',color(1,0,0)),
4  ('ch3Apex','3 Chamber Long Axis Apex',color(0,0.75,0)),
5  ('ch4Apex','4 Chamber Long Axis Apex',color(0,0,1))
6 )