Liver segmentectomy planning: tumor-driven cut selection - #5
Open
bouamarakamelia wants to merge 1 commit into
Open
Liver segmentectomy planning: tumor-driven cut selection #5bouamarakamelia wants to merge 1 commit into
bouamarakamelia wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Description
This PR adds the ability to determine, automatically, which liver segments and vessel-skeleton nodes would be affected by resecting the vessel near a tumor replacing manual, hand-picked cut node ids with a pipeline that goes straight from "where is the tumor" to "what would this resection devascularize."
It lets you answer: given a tumor's location, which vessel branch feeds it, and if I cut there, which Couinaud segment(s) lose blood supply? --> without ever typing a node number by hand.
2. Features
a. New component logic, class diagram, and how to use it
classDiagram class DataEngine { <<sofa>> } class MeshLoader { <<sofa>> } class SkeletonGraph { +buildTree(entryPoint) +buildTreeAutoRoot() +assignSegmentLabels(rawLabels) +simulateResection(cutIds) vector~int~ +affectedSegments(ids) vector~int~ } class ClosedMeshQuery { <<cgalutils, shared>> +buildFrom(vertices, triangles) } class SkeletonReader~DataTypes~ { +graph() SkeletonGraph } class SkeletonSegmentMapper~DataTypes~ { +l_segmentMeshes +segmentNames +graph() SkeletonGraph } class TumorCutPointSelector~DataTypes~ { +l_tumorMeshes +cutNodeIds +untouchedTumorIds } class SkeletonResectionSimulator~DataTypes~ { +cutNodeIds +affectedNodeIds +affectedSegmentNames +activationDelay } DataEngine <|-- SkeletonReader DataEngine <|-- SkeletonSegmentMapper DataEngine <|-- TumorCutPointSelector DataEngine <|-- SkeletonResectionSimulator SkeletonSegmentMapper --> SkeletonReader : reads SkeletonSegmentMapper --> MeshLoader : segment meshes SkeletonSegmentMapper ..> ClosedMeshQuery : point-in-mesh TumorCutPointSelector --> SkeletonSegmentMapper : reads TumorCutPointSelector --> MeshLoader : tumor meshes TumorCutPointSelector ..> ClosedMeshQuery : point-in-mesh SkeletonResectionSimulator --> SkeletonSegmentMapper : reads SkeletonResectionSimulator --> TumorCutPointSelector : cutNodeIdsFour components, each a single responsibility, chained together:
SkeletonReaderloads the vessel centerline and roots it as a tree (auto-picking a root from the largest connected component when no explicit entry point is known, rather than guessing).SkeletonSegmentMapperassigns every skeleton node its Couinaud segment, via point-in-mesh testing against the 8 segment volumes, smoothed by majority vote per branch so boundary noise doesn't fragment a branch across segments.TumorCutPointSelectorfor each tumor (one mesh per tumor), finds which skeleton node(s) it physically touches, using the same point-in-mesh approach (bounding-box pre-filter, then a real geometric test never the bbox alone, since a non-convex tumor's box overstates its volume). Outputs a ready-to-usecutNodeIdslist, plus which tumors touched nothing (flagging where a "nearest node in the tumor's segment" fallback would still be needed).SkeletonResectionSimulatorgiven cut node(s) from any source (manual orTumorCutPointSelector), computes which nodes and segments actually lose blood supply, via reachability from the root rather than a naive "everything downstream" count a collateral vessel elsewhere in the tree can rescue part of what a plain subtree walk would wrongly flag as devascularized.How to use it, end to end:
MeshSkeletonization, read it back withSkeletonReader.SkeletonSegmentMapper.TumorCutPointSelectoralong with the segment mapper.SkeletonResectionSimulator.cutNodeIdsto@tumorSelector.cutNodeIdsthe resection now follows tumor placement automatically.affectedNodeIds/affectedSegmentNamesfor the answer, or watch the live visualization (skeleton points and segment meshes color-switch from green to red/black after a configurable delay).untouchedTumorIdsany tumor listed there didn't touch the skeleton directly and has no cut point yet.b. SOFA scene structure
Three sibling
Nodes (Mesh,LiverSegments,Tumors) feed into oneresectionSimat the root each stage's output is the next stage's input, all the way from raw meshes to a final devascularization report.3. Results
Verified against real patient data at each stage: