From c6d72d02efa8f54c74c4a35659cf7beef4fd9efc Mon Sep 17 00:00:00 2001 From: arti-sukasem <51779010+arti-sukasem@users.noreply.github.com> Date: Wed, 5 May 2021 11:22:11 +1200 Subject: [PATCH 1/5] created lung fissure annotation --- src/scaffoldmaker/annotation/lung_terms.py | 3 ++ .../meshtypes/meshtype_3d_lung1.py | 45 ++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/scaffoldmaker/annotation/lung_terms.py b/src/scaffoldmaker/annotation/lung_terms.py index 9b8e7df3..07b318af 100644 --- a/src/scaffoldmaker/annotation/lung_terms.py +++ b/src/scaffoldmaker/annotation/lung_terms.py @@ -4,8 +4,11 @@ # convention: preferred name, preferred id, followed by any other ids and alternative names lung_terms = [ + ("horizontal fissure of right lung", "UBERON: None", "ILX: None"), ("lung", "UBERON:0002048", "ILX:0726937"), ("left lung", "UBERON:0002168", "ILX:0733450"), + ("oblique fissure of left lung", "UBERON: None", "ILX: None"), + ("oblique fissure of right lung", "UBERON: None", "ILX: None"), ("right lung", "UBERON:0002167", "ILX:0729582"), ("upper lobe of left lung", "UBERON:0008952", "ILX:0735339"), ("lower lobe of left lung", "UBERON:0008953", "ILX:0735534"), diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py index a669c5dc..7ed4c246 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py @@ -2,7 +2,7 @@ Generates 3D lung surface mesh. ''' -from scaffoldmaker.annotation.annotationgroup import AnnotationGroup +from scaffoldmaker.annotation.annotationgroup import AnnotationGroup, findOrCreateAnnotationGroupForTerm, getAnnotationGroupForTerm from scaffoldmaker.annotation.lung_terms import get_lung_term from scaffoldmaker.meshtypes.scaffold_base import Scaffold_base from scaffoldmaker.utils.eft_utils import remapEftLocalNodes, remapEftNodeValueLabel, setEftScaleFactorIds @@ -685,6 +685,49 @@ def refineMesh(cls, meshrefinement, options): refineElementsCount = options['Refine number of elements'] meshrefinement.refineAllElementsCubeStandard3d(refineElementsCount, refineElementsCount, refineElementsCount) + @classmethod + def defineFaceAnnotations(cls, region, options, annotationGroups): + """ + Add face annotation groups from the highest dimension mesh. + Must have defined faces and added subelements for highest dimension groups. + :param region: Zinc region containing model. + :param options: Dict containing options. See getDefaultOptions(). + :param annotationGroups: List of annotation groups for top-level elements. + New face annotation groups are appended to this list. + """ + try: + # create fissure groups + fm = region.getFieldmodule() + upperLeftGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("upper lobe of left lung")) + lowerLeftGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("lower lobe of left lung")) + + upperRightGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("upper lobe of right lung")) + middleRightGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("middle lobe of right lung")) + lowerRightGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("lower lobe of right lung")) + + mesh2d = fm.findMeshByDimension(2) + is_exterior = fm.createFieldIsExterior() + is_upperLeftGroup = upperLeftGroup.getFieldElementGroup(mesh2d) + is_lowerLeftGroup = lowerLeftGroup.getFieldElementGroup(mesh2d) + + is_upperRightGroup = upperRightGroup.getFieldElementGroup(mesh2d) + is_middleRightGroup = middleRightGroup.getFieldElementGroup(mesh2d) + is_lowerRightGroup = lowerRightGroup.getFieldElementGroup(mesh2d) + + is_obliqueLeftGroup = fm.createFieldAnd(is_upperLeftGroup, is_lowerLeftGroup) + is_obliqueRightGroup = fm.createFieldOr(fm.createFieldAnd(is_lowerRightGroup, is_upperRightGroup), + fm.createFieldAnd(is_lowerRightGroup, is_middleRightGroup)) + is_horizontalRightGroup = fm.createFieldAnd(is_upperRightGroup, is_middleRightGroup) + + obliqueLeftGroup = findOrCreateAnnotationGroupForTerm(annotationGroups, region, get_lung_term("oblique fissure of left lung")) + obliqueLeftGroup.getMeshGroup(mesh2d).addElementsConditional(is_obliqueLeftGroup) + obliqueRightGroup = findOrCreateAnnotationGroupForTerm(annotationGroups, region, get_lung_term("oblique fissure of right lung")) + obliqueRightGroup.getMeshGroup(mesh2d).addElementsConditional(is_obliqueRightGroup) + horizontalRightGroup = findOrCreateAnnotationGroupForTerm(annotationGroups, region, get_lung_term("horizontal fissure of right lung")) + horizontalRightGroup.getMeshGroup(mesh2d).addElementsConditional(is_horizontalRightGroup) + except: + pass + def getLungNodes(lungSide, cache, coordinates, generateParameters, nodes, nodetemplate, nodeFieldParameters, lElementsCount1, lElementsCount2, lElementsCount3, uElementsCount1, uElementsCount2, uElementsCount3, From f30c25aebf5466cad58dbd0d4b4477422e6418fd Mon Sep 17 00:00:00 2001 From: arti-sukasem <51779010+arti-sukasem@users.noreply.github.com> Date: Mon, 10 May 2021 11:50:25 +1200 Subject: [PATCH 2/5] Created test_lung.py This test_lung.py requires humanFiducialPoint branch to run a test for marker points --- tests/test_lung.py | 179 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 tests/test_lung.py diff --git a/tests/test_lung.py b/tests/test_lung.py new file mode 100644 index 00000000..0d903dc1 --- /dev/null +++ b/tests/test_lung.py @@ -0,0 +1,179 @@ +import unittest +import copy +from opencmiss.utils.zinc.finiteelement import evaluateFieldNodesetRange, findNodeWithName +from opencmiss.utils.zinc.general import ChangeManager +from opencmiss.zinc.context import Context +from opencmiss.zinc.field import Field +from opencmiss.zinc.result import RESULT_OK +from scaffoldmaker.annotation.annotationgroup import AnnotationGroup, getAnnotationGroupForTerm +from scaffoldmaker.annotation.lung_terms import get_lung_term +from scaffoldmaker.meshtypes.meshtype_3d_lung1 import MeshType_3d_lung1 +from scaffoldmaker.utils.meshrefinement import MeshRefinement +from testutils import assertAlmostEqualList + +class LungScaffoldTestCase(unittest.TestCase): + + def test_lung1(self): + """ + Test creation of heart scaffold. + """ + scaffold = MeshType_3d_lung1 + parameterSetNames = scaffold.getParameterSetNames() + self.assertEqual(parameterSetNames, [ "Default", "Human 1", "Mouse 1" ]) + options = scaffold.getDefaultOptions(["Human"]) + self.assertEqual(3, len(options)) + self.assertFalse(scaffold.checkOptions(options)) + + context = Context("Test") + region = context.getDefaultRegion() + self.assertTrue(region.isValid()) + annotationGroups = scaffold.generateMesh(region, options) + self.assertEqual(11, len(annotationGroups)) + fieldmodule = region.getFieldmodule() + mesh3d = fieldmodule.findMeshByDimension(3) + self.assertEqual(88, mesh3d.getSize()) + mesh2d = fieldmodule.findMeshByDimension(2) + self.assertEqual(292, mesh2d.getSize()) + mesh1d = fieldmodule.findMeshByDimension(1) + self.assertEqual(334, mesh1d.getSize()) + nodes = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + self.assertEqual(138, nodes.getSize()) + datapoints = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_DATAPOINTS) + self.assertEqual(0, datapoints.getSize()) + + # check coordinates range, epicardium surface area and volume + coordinates = fieldmodule.findFieldByName("coordinates").castFiniteElement() + self.assertTrue(coordinates.isValid()) + minimums, maximums = evaluateFieldNodesetRange(coordinates, nodes) + assertAlmostEqualList(self, minimums, [ 14.153, 62.444, -354.889 ], 1.0E-6) + assertAlmostEqualList(self, maximums, [ 297.502, 234.911, -23.486 ], 1.0E-6) + with ChangeManager(fieldmodule): + one = fieldmodule.createFieldConstant(1.0) + upperRightFissureGroup = fieldmodule.findFieldByName('upper lobe of right lung').castGroup() + self.assertTrue(upperRightFissureGroup.isValid()) + upperRightFissureMeshGroup = upperRightFissureGroup.getFieldElementGroup(mesh2d).getMeshGroup() + self.assertTrue(upperRightFissureMeshGroup.isValid()) + surfaceAreaField = fieldmodule.createFieldMeshIntegral(one, coordinates, upperRightFissureMeshGroup) + surfaceAreaField.setNumbersOfPoints(4) + volumeField = fieldmodule.createFieldMeshIntegral(one, coordinates, mesh3d) + volumeField.setNumbersOfPoints(3) + fieldcache = fieldmodule.createFieldcache() + result, surfaceArea = surfaceAreaField.evaluateReal(fieldcache, 1) + self.assertEqual(result, RESULT_OK) + self.assertAlmostEqual(surfaceArea, 139195.03021771502, delta=1.0E-2) + result, volume = volumeField.evaluateReal(fieldcache, 1) + self.assertEqual(result, RESULT_OK) + self.assertAlmostEqual(volume, 7169261.158690422, delta=1.0E-2) + + # check some annotationGroups: + expectedSizes3d = { + "lung": 88, + "left lung": 44, + "right lung": 44, + "upper lobe of left lung": 24, + "lower lobe of left lung": 20, + "upper lobe of right lung": 16, + "middle lobe of right lung": 8, + "lower lobe of right lung": 20, + # "right lung accessory lobe": 0 + } + for name in expectedSizes3d: + group = getAnnotationGroupForTerm(annotationGroups, get_lung_term(name)) + size = group.getMeshGroup(mesh3d).getSize() + self.assertEqual(expectedSizes3d[name], size, name) + expectedSizes2d = { + "horizontal fissure of right lung": 4, + "oblique fissure of left lung": 8, + "oblique fissure of right lung": 8 + } + for name in expectedSizes2d: + group = getAnnotationGroupForTerm(annotationGroups, get_lung_term(name)) + size = group.getMeshGroup(mesh2d).getSize() + self.assertEqual(expectedSizes2d[name], size, name) + + # test finding a marker in scaffold + markerGroup = fieldmodule.findFieldByName("marker").castGroup() + markerNodes = markerGroup.getFieldNodeGroup(nodes).getNodesetGroup() + self.assertEqual(6, markerNodes.getSize()) + markerName = fieldmodule.findFieldByName("marker_name") + self.assertTrue(markerName.isValid()) + markerLocation = fieldmodule.findFieldByName("marker_location") + self.assertTrue(markerLocation.isValid()) + # test apex marker point + cache = fieldmodule.createFieldcache() + node = findNodeWithName(markerNodes, markerName, "apex of left lung") + self.assertTrue(node.isValid()) + cache.setNode(node) + element, xi = markerLocation.evaluateMeshLocation(cache, 3) + self.assertEqual(37, element.getIdentifier()) + assertAlmostEqualList(self, xi, [ 0.0, 0.0, 1.0 ], 1.0E-10) + + # refine 4 and check result + # first remove any face (but not point) annotation groups as they are re-added by defineFaceAnnotations + removeAnnotationGroups = [] + for annotationGroup in annotationGroups: + if (not annotationGroup.hasMeshGroup(mesh3d)) and (annotationGroup.hasMeshGroup(mesh2d) or annotationGroup.hasMeshGroup(mesh1d)): + removeAnnotationGroups.append(annotationGroup) + for annotationGroup in removeAnnotationGroups: + annotationGroups.remove(annotationGroup) + self.assertEqual(8, len(annotationGroups)) + + refineRegion = region.createRegion() + refineFieldmodule = refineRegion.getFieldmodule() + options['Refine'] = True + options['Refine number of elements'] = 4 + meshrefinement = MeshRefinement(region, refineRegion, annotationGroups) + scaffold.refineMesh(meshrefinement, options) + annotationGroups = meshrefinement.getAnnotationGroups() + + refineFieldmodule.defineAllFaces() + oldAnnotationGroups = copy.copy(annotationGroups) + for annotationGroup in annotationGroups: + annotationGroup.addSubelements() + scaffold.defineFaceAnnotations(refineRegion, options, annotationGroups) + for annotation in annotationGroups: + if annotation not in oldAnnotationGroups: + annotationGroup.addSubelements() + self.assertEqual(11, len(annotationGroups)) + + mesh3d = refineFieldmodule.findMeshByDimension(3) + self.assertEqual(5632, mesh3d.getSize()) + mesh2d = refineFieldmodule.findMeshByDimension(2) + self.assertEqual(17344, mesh2d.getSize()) + mesh1d = refineFieldmodule.findMeshByDimension(1) + self.assertEqual(17848, mesh1d.getSize()) + nodes = refineFieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + self.assertEqual(6144, nodes.getSize()) + datapoints = refineFieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_DATAPOINTS) + self.assertEqual(0, datapoints.getSize()) + + # check some refined annotationGroups: + for name in expectedSizes3d: + group = getAnnotationGroupForTerm(annotationGroups, get_lung_term(name)) + size = group.getMeshGroup(mesh3d).getSize() + self.assertEqual(expectedSizes3d[name]*4**3, size, name) + for name in expectedSizes2d: + group = getAnnotationGroupForTerm(annotationGroups, get_lung_term(name)) + size = group.getMeshGroup(mesh2d).getSize() + self.assertEqual(expectedSizes2d[name]*16, size, name) + + # test finding a marker in refined scaffold + markerGroup = refineFieldmodule.findFieldByName("marker").castGroup() + refinedNodes = refineFieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) + markerNodes = markerGroup.getFieldNodeGroup(refinedNodes).getNodesetGroup() + self.assertEqual(6, markerNodes.getSize()) + markerName = refineFieldmodule.findFieldByName("marker_name") + self.assertTrue(markerName.isValid()) + markerLocation = refineFieldmodule.findFieldByName("marker_location") + self.assertTrue(markerLocation.isValid()) + # test apex marker point + cache = refineFieldmodule.createFieldcache() + node = findNodeWithName(markerNodes, markerName, "apex of left lung") + self.assertTrue(node.isValid()) + cache.setNode(node) + element, xi = markerLocation.evaluateMeshLocation(cache, 3) + self.assertEqual(2353, element.getIdentifier()) + assertAlmostEqualList(self, xi, [ 0.0, 0.0, 1.0 ], 1.0E-10) + +if __name__ == "__main__": + unittest.main() From 1afd3ddb9cd5ced3d83dafd6e27e5a54fe926b50 Mon Sep 17 00:00:00 2001 From: arti-sukasem <51779010+arti-sukasem@users.noreply.github.com> Date: Tue, 11 May 2021 13:55:03 +1200 Subject: [PATCH 3/5] reviewed changes --- src/scaffoldmaker/annotation/lung_terms.py | 6 ++--- .../meshtypes/meshtype_3d_lung1.py | 24 +++++++++++-------- tests/test_lung.py | 7 +++--- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/scaffoldmaker/annotation/lung_terms.py b/src/scaffoldmaker/annotation/lung_terms.py index 07b318af..ad502e17 100644 --- a/src/scaffoldmaker/annotation/lung_terms.py +++ b/src/scaffoldmaker/annotation/lung_terms.py @@ -4,11 +4,11 @@ # convention: preferred name, preferred id, followed by any other ids and alternative names lung_terms = [ - ("horizontal fissure of right lung", "UBERON: None", "ILX: None"), + ("horizontal fissure of right lung", "None"), ("lung", "UBERON:0002048", "ILX:0726937"), ("left lung", "UBERON:0002168", "ILX:0733450"), - ("oblique fissure of left lung", "UBERON: None", "ILX: None"), - ("oblique fissure of right lung", "UBERON: None", "ILX: None"), + ("oblique fissure of left lung", "None"), + ("oblique fissure of right lung", "None"), ("right lung", "UBERON:0002167", "ILX:0729582"), ("upper lobe of left lung", "UBERON:0008952", "ILX:0735339"), ("lower lobe of left lung", "UBERON:0008953", "ILX:0735534"), diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py index 7543e83b..faa5e20f 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py @@ -70,9 +70,9 @@ def generateBaseMesh(cls, region, options): :return: annotationGroups ''' parameterSetName = options['Base parameter set'] - isMouse = 'Mouse' in parameterSetName - isHuman = 'Human' in parameterSetName - + isMouse = 'Mouse 1' in parameterSetName + isHuman = 'Human 1' in parameterSetName + print(parameterSetName) fm = region.getFieldmodule() coordinates = findOrCreateFieldCoordinates(fm) @@ -695,9 +695,14 @@ def defineFaceAnnotations(cls, region, options, annotationGroups): :param annotationGroups: List of annotation groups for top-level elements. New face annotation groups are appended to this list. """ - try: - # create fissure groups - fm = region.getFieldmodule() + parameterSetName = options['Base parameter set'] + isMouse = 'Mouse 1' in parameterSetName + isHuman = 'Human 1' in parameterSetName + + # create fissure groups + fm = region.getFieldmodule() + + if isHuman: upperLeftGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("upper lobe of left lung")) lowerLeftGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("lower lobe of left lung")) @@ -715,8 +720,8 @@ def defineFaceAnnotations(cls, region, options, annotationGroups): is_lowerRightGroup = lowerRightGroup.getFieldElementGroup(mesh2d) is_obliqueLeftGroup = fm.createFieldAnd(is_upperLeftGroup, is_lowerLeftGroup) - is_obliqueRightGroup = fm.createFieldOr(fm.createFieldAnd(is_lowerRightGroup, is_upperRightGroup), - fm.createFieldAnd(is_lowerRightGroup, is_middleRightGroup)) + is_obliqueRightGroup = fm.createFieldAnd(fm.createFieldOr(is_middleRightGroup, is_upperRightGroup), + is_lowerRightGroup) is_horizontalRightGroup = fm.createFieldAnd(is_upperRightGroup, is_middleRightGroup) obliqueLeftGroup = findOrCreateAnnotationGroupForTerm(annotationGroups, region, get_lung_term("oblique fissure of left lung")) @@ -725,8 +730,7 @@ def defineFaceAnnotations(cls, region, options, annotationGroups): obliqueRightGroup.getMeshGroup(mesh2d).addElementsConditional(is_obliqueRightGroup) horizontalRightGroup = findOrCreateAnnotationGroupForTerm(annotationGroups, region, get_lung_term("horizontal fissure of right lung")) horizontalRightGroup.getMeshGroup(mesh2d).addElementsConditional(is_horizontalRightGroup) - except: - pass + def getLungNodes(lungSide, cache, coordinates, generateParameters, nodes, nodetemplate, nodeFieldParameters, lElementsCount1, lElementsCount2, lElementsCount3, diff --git a/tests/test_lung.py b/tests/test_lung.py index 0d903dc1..0c831a4c 100644 --- a/tests/test_lung.py +++ b/tests/test_lung.py @@ -41,7 +41,7 @@ def test_lung1(self): datapoints = fieldmodule.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_DATAPOINTS) self.assertEqual(0, datapoints.getSize()) - # check coordinates range, epicardium surface area and volume + # check coordinates range, outside surface area and volume coordinates = fieldmodule.findFieldByName("coordinates").castFiniteElement() self.assertTrue(coordinates.isValid()) minimums, maximums = evaluateFieldNodesetRange(coordinates, nodes) @@ -122,6 +122,7 @@ def test_lung1(self): refineFieldmodule = refineRegion.getFieldmodule() options['Refine'] = True options['Refine number of elements'] = 4 + refineNumberOfElements = options['Refine number of elements'] meshrefinement = MeshRefinement(region, refineRegion, annotationGroups) scaffold.refineMesh(meshrefinement, options) annotationGroups = meshrefinement.getAnnotationGroups() @@ -151,11 +152,11 @@ def test_lung1(self): for name in expectedSizes3d: group = getAnnotationGroupForTerm(annotationGroups, get_lung_term(name)) size = group.getMeshGroup(mesh3d).getSize() - self.assertEqual(expectedSizes3d[name]*4**3, size, name) + self.assertEqual(expectedSizes3d[name]*(refineNumberOfElements**3), size, name) for name in expectedSizes2d: group = getAnnotationGroupForTerm(annotationGroups, get_lung_term(name)) size = group.getMeshGroup(mesh2d).getSize() - self.assertEqual(expectedSizes2d[name]*16, size, name) + self.assertEqual(expectedSizes2d[name]*(refineNumberOfElements**2), size, name) # test finding a marker in refined scaffold markerGroup = refineFieldmodule.findFieldByName("marker").castGroup() From 929183cc756cf2d1bcbca4f59270625bafd55b53 Mon Sep 17 00:00:00 2001 From: arti-sukasem <51779010+arti-sukasem@users.noreply.github.com> Date: Tue, 11 May 2021 14:18:39 +1200 Subject: [PATCH 4/5] reviewed some small fixes --- .../meshtypes/meshtype_3d_lung1.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py index faa5e20f..18e81b3b 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py @@ -72,7 +72,7 @@ def generateBaseMesh(cls, region, options): parameterSetName = options['Base parameter set'] isMouse = 'Mouse 1' in parameterSetName isHuman = 'Human 1' in parameterSetName - print(parameterSetName) + fm = region.getFieldmodule() coordinates = findOrCreateFieldCoordinates(fm) @@ -706,26 +706,27 @@ def defineFaceAnnotations(cls, region, options, annotationGroups): upperLeftGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("upper lobe of left lung")) lowerLeftGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("lower lobe of left lung")) - upperRightGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("upper lobe of right lung")) - middleRightGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("middle lobe of right lung")) - lowerRightGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("lower lobe of right lung")) - mesh2d = fm.findMeshByDimension(2) - is_exterior = fm.createFieldIsExterior() is_upperLeftGroup = upperLeftGroup.getFieldElementGroup(mesh2d) is_lowerLeftGroup = lowerLeftGroup.getFieldElementGroup(mesh2d) + is_obliqueLeftGroup = fm.createFieldAnd(is_upperLeftGroup, is_lowerLeftGroup) + obliqueLeftGroup = findOrCreateAnnotationGroupForTerm(annotationGroups, region, get_lung_term("oblique fissure of left lung")) + obliqueLeftGroup.getMeshGroup(mesh2d).addElementsConditional(is_obliqueLeftGroup) + + if isHuman or isMouse: + upperRightGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("upper lobe of right lung")) + middleRightGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("middle lobe of right lung")) + lowerRightGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("lower lobe of right lung")) + is_upperRightGroup = upperRightGroup.getFieldElementGroup(mesh2d) is_middleRightGroup = middleRightGroup.getFieldElementGroup(mesh2d) is_lowerRightGroup = lowerRightGroup.getFieldElementGroup(mesh2d) - is_obliqueLeftGroup = fm.createFieldAnd(is_upperLeftGroup, is_lowerLeftGroup) is_obliqueRightGroup = fm.createFieldAnd(fm.createFieldOr(is_middleRightGroup, is_upperRightGroup), is_lowerRightGroup) is_horizontalRightGroup = fm.createFieldAnd(is_upperRightGroup, is_middleRightGroup) - obliqueLeftGroup = findOrCreateAnnotationGroupForTerm(annotationGroups, region, get_lung_term("oblique fissure of left lung")) - obliqueLeftGroup.getMeshGroup(mesh2d).addElementsConditional(is_obliqueLeftGroup) obliqueRightGroup = findOrCreateAnnotationGroupForTerm(annotationGroups, region, get_lung_term("oblique fissure of right lung")) obliqueRightGroup.getMeshGroup(mesh2d).addElementsConditional(is_obliqueRightGroup) horizontalRightGroup = findOrCreateAnnotationGroupForTerm(annotationGroups, region, get_lung_term("horizontal fissure of right lung")) From aee2738c0ea36e242ad8e15e839b6eef2c384895 Mon Sep 17 00:00:00 2001 From: arti-sukasem <51779010+arti-sukasem@users.noreply.github.com> Date: Tue, 11 May 2021 15:00:50 +1200 Subject: [PATCH 5/5] reviewed a tiny fix --- src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py index 18e81b3b..62ecc573 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py @@ -701,12 +701,12 @@ def defineFaceAnnotations(cls, region, options, annotationGroups): # create fissure groups fm = region.getFieldmodule() + mesh2d = fm.findMeshByDimension(2) if isHuman: upperLeftGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("upper lobe of left lung")) lowerLeftGroup = getAnnotationGroupForTerm(annotationGroups, get_lung_term("lower lobe of left lung")) - mesh2d = fm.findMeshByDimension(2) is_upperLeftGroup = upperLeftGroup.getFieldElementGroup(mesh2d) is_lowerLeftGroup = lowerLeftGroup.getFieldElementGroup(mesh2d)