Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve annotation groups #66

Merged
merged 4 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions src/scaffoldmaker/meshtypes/meshtype_3d_heartatria1.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,10 @@ def generateBaseMesh(cls, region, options):
coordinates = findOrCreateFieldCoordinates(fm)
cache = fm.createFieldcache()

laGroup = AnnotationGroup(region, 'left atrium', FMANumber = 7097, lyphID = 'Lyph ID unknown')
raGroup = AnnotationGroup(region, 'right atrium', FMANumber = 7096, lyphID = 'Lyph ID unknown')
aSeptumGroup = AnnotationGroup(region, 'interatrial septum', FMANumber = 7108, lyphID = 'Lyph ID unknown')
fossaGroup = AnnotationGroup(region, 'fossa ovalis', FMANumber = 9246, lyphID = 'Lyph ID unknown')
laGroup = AnnotationGroup(region, "left atrium myocardium", FMANumber = 7285, lyphID = "Lyph ID unknown")
raGroup = AnnotationGroup(region, "right atrium myocardium", FMANumber = 7282, lyphID = "Lyph ID unknown")
aSeptumGroup = AnnotationGroup(region, "interatrial septum", FMANumber = 7108, lyphID = "Lyph ID unknown")
fossaGroup = AnnotationGroup(region, "fossa ovalis", FMANumber = 9246, lyphID = "Lyph ID unknown")
laaGroup = AnnotationGroup(region, 'left atrial appendage', FMANumber = 7219, lyphID = 'Lyph ID unknown')
raaGroup = AnnotationGroup(region, 'right atrial appendage', FMANumber = 7218, lyphID = 'Lyph ID unknown')
annotationGroups = [ laGroup, raGroup, aSeptumGroup, fossaGroup, laaGroup, raaGroup ]
Expand Down Expand Up @@ -3164,6 +3164,41 @@ def generateBaseMesh(cls, region, options):
nid1 = raTrackSurfaceFirstNodeIdentifier + e2*nodesCount1 + e1
element.setNodesByIdentifier(eft2d, [ nid1, nid1 + 1, nid1 + nodesCount1, nid1 + nodesCount1 + 1 ])

# create endocardium and epicardium groups
fm.defineAllFaces()
laGroup.addSubelements()
raGroup.addSubelements()
aSeptumGroup.addSubelements()
mesh2d = fm.findMeshByDimension(2)
is_exterior = fm.createFieldIsExterior()
is_exterior_face_xi3_0 = fm.createFieldAnd(is_exterior, fm.createFieldIsOnFace(Element.FACE_TYPE_XI3_0))
is_exterior_face_xi3_1 = fm.createFieldAnd(is_exterior, fm.createFieldIsOnFace(Element.FACE_TYPE_XI3_1))
is_la = laGroup.getFieldElementGroup(mesh2d)
is_ra = raGroup.getFieldElementGroup(mesh2d)
is_la_endo = fm.createFieldAnd(is_la, is_exterior_face_xi3_0)
is_ra_endo = fm.createFieldOr(fm.createFieldAnd(fm.createFieldAnd(is_ra, is_exterior_face_xi3_0),
fm.createFieldNot(is_la_endo)),
fm.createFieldAnd(aSeptumGroup.getFieldElementGroup(mesh2d), is_exterior_face_xi3_1))
is_a_epi = fm.createFieldAnd(fm.createFieldOr(is_la, is_ra),
fm.createFieldAnd(is_exterior_face_xi3_1,
fm.createFieldNot(aSeptumGroup.getFieldElementGroup(mesh2d))))
laEndoGroup = AnnotationGroup(region, "Endocardium of left atrium", FMANumber = 7286, lyphID = 'Lyph ID unknown')
laEndoGroup.getMeshGroup(mesh2d).addElementsConditional(is_la_endo)
raEndoGroup = AnnotationGroup(region, "Endocardium of right atrium", FMANumber = 7281, lyphID = 'Lyph ID unknown')
raEndoGroup.getMeshGroup(mesh2d).addElementsConditional(is_ra_endo)
# Note I could not find any epicardium of atria
aEpiGroup = AnnotationGroup(region, "Epicardium of atrium", FMANumber = 0, lyphID = 'Lyph ID unknown')
aEpiGroup.getMeshGroup(mesh2d).addElementsConditional(is_a_epi)
del is_exterior
del is_exterior_face_xi3_0
del is_exterior_face_xi3_1
del is_la
del is_ra
del is_la_endo
del is_ra_endo
del is_a_epi
annotationGroups += [ laEndoGroup, raEndoGroup, aEpiGroup ]

fm.endChange()
return annotationGroups

Expand Down
8 changes: 4 additions & 4 deletions src/scaffoldmaker/meshtypes/meshtype_3d_heartatria2.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ def generateBaseMesh(cls, region, options):
coordinates = findOrCreateFieldCoordinates(fm)
cache = fm.createFieldcache()

laGroup = AnnotationGroup(region, 'left atrium', FMANumber = 7097, lyphID = 'Lyph ID unknown')
raGroup = AnnotationGroup(region, 'right atrium', FMANumber = 7096, lyphID = 'Lyph ID unknown')
aSeptumGroup = AnnotationGroup(region, 'interatrial septum', FMANumber = 7108, lyphID = 'Lyph ID unknown')
fossaGroup = AnnotationGroup(region, 'fossa ovalis', FMANumber = 9246, lyphID = 'Lyph ID unknown')
laGroup = AnnotationGroup(region, "left atrium myocardium", FMANumber = 7285, lyphID = "Lyph ID unknown")
raGroup = AnnotationGroup(region, "right atrium", FMANumber = 7282, lyphID = "Lyph ID unknown")
hsorby marked this conversation as resolved.
Show resolved Hide resolved
aSeptumGroup = AnnotationGroup(region, "interatrial septum", FMANumber = 7108, lyphID = "Lyph ID unknown")
fossaGroup = AnnotationGroup(region, "fossa ovalis", FMANumber = 9246, lyphID = "Lyph ID unknown")
lipvGroup = AnnotationGroup(region, 'left inferior pulmonary vein', FMANumber = 49913, lyphID = 'Lyph ID unknown')
lspvGroup = AnnotationGroup(region, 'left superior pulmonary vein', FMANumber = 49916, lyphID = 'Lyph ID unknown')
ripvGroup = AnnotationGroup(region, 'right inferior pulmonary vein', FMANumber = 49911, lyphID = 'Lyph ID unknown')
Expand Down
39 changes: 36 additions & 3 deletions src/scaffoldmaker/meshtypes/meshtype_3d_heartventricles1.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ def generateBaseMesh(cls, region, options):

mesh = fm.findMeshByDimension(3)

lvGroup = AnnotationGroup(region, 'left ventricle', FMANumber = 7101, lyphID = 'Lyph ID unknown')
rvGroup = AnnotationGroup(region, 'right ventricle', FMANumber = 7098, lyphID = 'Lyph ID unknown')
vSeptumGroup = AnnotationGroup(region, 'interventricular septum', FMANumber = 7133, lyphID = 'Lyph ID unknown')
lvGroup = AnnotationGroup(region, "left ventricle myocardium", FMANumber = 9558, lyphID = 'Lyph ID unknown')
rvGroup = AnnotationGroup(region, "right ventricle myocardium", FMANumber = 9535, lyphID = 'Lyph ID unknown')
vSeptumGroup = AnnotationGroup(region, "interventricular septum", FMANumber = 7133, lyphID = 'Lyph ID unknown')
annotationGroups = [ lvGroup, rvGroup, vSeptumGroup ]

# annotation fiducial points
Expand Down Expand Up @@ -1037,6 +1037,39 @@ def generateBaseMesh(cls, region, options):
for meshGroup in meshGroups:
meshGroup.addElement(element)

# create endocardium and epicardium groups
fm.defineAllFaces()
lvGroup.addSubelements()
rvGroup.addSubelements()
vSeptumGroup.addSubelements()
mesh2d = fm.findMeshByDimension(2)
is_exterior = fm.createFieldIsExterior()
is_exterior_face_xi3_0 = fm.createFieldAnd(is_exterior, fm.createFieldIsOnFace(Element.FACE_TYPE_XI3_0))
is_exterior_face_xi3_1 = fm.createFieldAnd(is_exterior, fm.createFieldIsOnFace(Element.FACE_TYPE_XI3_1))
is_lv = lvGroup.getFieldElementGroup(mesh2d)
is_rv = rvGroup.getFieldElementGroup(mesh2d)
is_lv_endo = fm.createFieldAnd(is_lv, is_exterior_face_xi3_0)
is_rv_endo = fm.createFieldOr(fm.createFieldAnd(fm.createFieldAnd(is_rv, is_exterior_face_xi3_0),
fm.createFieldNot(is_lv_endo)),
fm.createFieldAnd(vSeptumGroup.getFieldElementGroup(mesh2d), is_exterior_face_xi3_1))
is_epi = fm.createFieldAnd(is_exterior_face_xi3_1,
fm.createFieldNot(vSeptumGroup.getFieldElementGroup(mesh2d)))
lvEndoGroup = AnnotationGroup(region, "Endocardium of left ventricle", FMANumber = 9559, lyphID = 'Lyph ID unknown')
lvEndoGroup.getMeshGroup(mesh2d).addElementsConditional(is_lv_endo)
rvEndoGroup = AnnotationGroup(region, "Endocardium of right ventricle", FMANumber = 9536, lyphID = 'Lyph ID unknown')
rvEndoGroup.getMeshGroup(mesh2d).addElementsConditional(is_rv_endo)
vEpiGroup = AnnotationGroup(region, "Epicardium of ventricle", FMANumber = 12150, lyphID = 'Lyph ID unknown')
vEpiGroup.getMeshGroup(mesh2d).addElementsConditional(is_epi)
del is_exterior
del is_exterior_face_xi3_0
del is_exterior_face_xi3_1
del is_lv
del is_rv
del is_lv_endo
del is_rv_endo
del is_epi
annotationGroups += [ lvEndoGroup, rvEndoGroup, vEpiGroup ]

# apex annotation points
element1 = mesh.findElementByIdentifier(1)
datapoint = fiducialPoints.createNode(-1, datapointTemplateInternal)
Expand Down
6 changes: 3 additions & 3 deletions src/scaffoldmaker/meshtypes/meshtype_3d_heartventricles2.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ def generateBaseMesh(cls, region, options):
coordinates = findOrCreateFieldCoordinates(fm)
cache = fm.createFieldcache()

lvGroup = AnnotationGroup(region, 'left ventricle', FMANumber = 7101, lyphID = 'Lyph ID unknown')
rvGroup = AnnotationGroup(region, 'right ventricle', FMANumber = 7098, lyphID = 'Lyph ID unknown')
vSeptumGroup = AnnotationGroup(region, 'interventricular septum', FMANumber = 7133, lyphID = 'Lyph ID unknown')
lvGroup = AnnotationGroup(region, "left ventricle myocardium", FMANumber = 9558, lyphID = 'Lyph ID unknown')
rvGroup = AnnotationGroup(region, "right ventricle myocardium", FMANumber = 9535, lyphID = 'Lyph ID unknown')
vSeptumGroup = AnnotationGroup(region, "interventricular septum", FMANumber = 7133, lyphID = 'Lyph ID unknown')
annotationGroups = [ lvGroup, rvGroup, vSeptumGroup ]

#################
Expand Down
38 changes: 35 additions & 3 deletions src/scaffoldmaker/meshtypes/meshtype_3d_heartventriclesbase1.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ def generateBaseMesh(cls, region, options):
annotationGroups = MeshType_3d_heartventricles1.generateBaseMesh(region, options)

# find/add annotation groups
lvGroup = findAnnotationGroupByName(annotationGroups, 'left ventricle')
rvGroup = findAnnotationGroupByName(annotationGroups, 'right ventricle')
vSeptumGroup = findAnnotationGroupByName(annotationGroups, 'interventricular septum')
lvGroup = findAnnotationGroupByName(annotationGroups, "left ventricle myocardium")
rvGroup = findAnnotationGroupByName(annotationGroups, "right ventricle myocardium")
vSeptumGroup = findAnnotationGroupByName(annotationGroups, "interventricular septum")
conusArteriosusGroup = AnnotationGroup(region, 'conus arteriosus', FMANumber = 0, lyphID = 'Lyph ID unknown')
annotationGroups += [ conusArteriosusGroup ]
# av boundary nodes are put in left and right fibrous ring groups only so they can be found by heart1
Expand Down Expand Up @@ -1249,6 +1249,7 @@ def generateBaseMesh(cls, region, options):
scaleEftNodeValueLabels(eft1, [ 7, 8 ], [ Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS3 ], [ 1 ])
ln_map = [ 1, 2, 1, 2, 3, 4, 5, 6 ]
remapEftLocalNodes(eft1, 6, ln_map)
meshGroups += [ vSeptumMeshGroup ]
elif e == 1:
# 7-node collapsed rv crest inner 1, by RA-LV outlet junction
rvin1 = -elementsCountAroundAtrialSeptum - 1
Expand Down Expand Up @@ -1358,6 +1359,37 @@ def generateBaseMesh(cls, region, options):
for meshGroup in meshGroups:
meshGroup.addElement(element)

# create endocardium and epicardium groups
fm.defineAllFaces()
lvGroup.addSubelements()
rvGroup.addSubelements()
vSeptumGroup.addSubelements()
mesh2d = fm.findMeshByDimension(2)
is_exterior = fm.createFieldIsExterior()
is_exterior_face_xi3_0 = fm.createFieldAnd(is_exterior, fm.createFieldIsOnFace(Element.FACE_TYPE_XI3_0))
is_exterior_face_xi3_1 = fm.createFieldAnd(is_exterior, fm.createFieldIsOnFace(Element.FACE_TYPE_XI3_1))
is_lv = lvGroup.getFieldElementGroup(mesh2d)
is_rv = rvGroup.getFieldElementGroup(mesh2d)
is_lv_endo = fm.createFieldAnd(is_lv, is_exterior_face_xi3_0)
is_rv_endo = fm.createFieldOr(fm.createFieldAnd(fm.createFieldAnd(is_rv, is_exterior_face_xi3_0),
fm.createFieldNot(is_lv_endo)),
fm.createFieldAnd(vSeptumGroup.getFieldElementGroup(mesh2d), is_exterior_face_xi3_1))
is_epi = fm.createFieldAnd(is_exterior_face_xi3_1,
fm.createFieldNot(vSeptumGroup.getFieldElementGroup(mesh2d)))
lvEndoGroup = AnnotationGroup(region, "Endocardium of left ventricle", FMANumber = 9559, lyphID = 'Lyph ID unknown')
lvEndoGroup.getMeshGroup(mesh2d).addElementsConditional(is_lv_endo)
rvEndoGroup = AnnotationGroup(region, "Endocardium of right ventricle", FMANumber = 9536, lyphID = 'Lyph ID unknown')
rvEndoGroup.getMeshGroup(mesh2d).addElementsConditional(is_rv_endo)
vEpiGroup = AnnotationGroup(region, "Epicardium of ventricle", FMANumber = 12150, lyphID = 'Lyph ID unknown')
vEpiGroup.getMeshGroup(mesh2d).addElementsConditional(is_epi)
del is_exterior
del is_exterior_face_xi3_0
del is_exterior_face_xi3_1
del is_lv
del is_rv
del is_lv_endo
del is_rv_endo
del is_epi

fm.endChange()
return annotationGroups
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def generateBaseMesh(cls, region, options):

# generate heartventricles2 model to add base plane to
annotationGroups = MeshType_3d_heartventricles2.generateBaseMesh(region, options)
lvGroup = findAnnotationGroupByName(annotationGroups, 'left ventricle')
rvGroup = findAnnotationGroupByName(annotationGroups, 'right ventricle')
vSeptumGroup = findAnnotationGroupByName(annotationGroups, 'interventricular septum')
lvGroup = findAnnotationGroupByName(annotationGroups, "left ventricle myocardium")
rvGroup = findAnnotationGroupByName(annotationGroups, "right ventricle myocardium")
vSeptumGroup = findAnnotationGroupByName(annotationGroups, "interventricular septum")
conusArteriosusGroup = AnnotationGroup(region, 'conus arteriosus', FMANumber = 0, lyphID = 'Lyph ID unknown')
lFibrousRingGroup = AnnotationGroup(region, 'left fibrous ring', FMANumber = 77124, lyphID = 'Lyph ID unknown')
rFibrousRingGroup = AnnotationGroup(region, 'right fibrous ring', FMANumber = 77125, lyphID = 'Lyph ID unknown')
Expand Down