Giter VIP home page Giter VIP logo

slicercbm / slicercbm Goto Github PK

View Code? Open in Web Editor NEW
13.0 1.0 2.0 5.02 MB

Computational Biophysics for Medicine in 3D Slicer

Home Page: https://slicercbm.org

License: BSD 3-Clause "New" or "Revised" License

CMake 5.16% Python 94.84%
biomechanics biophysics finite-element-method medical-image-computing mesh-generation scientific-computing 3d-slicer-extension grid-generation meshfree meshless mfem

slicercbm's Introduction

SlicerCBM

Computational Biophysics for Medicine in 3D Slicer

SlicerCBM is an extension for 3D Slicer that provides tools for creating and solving computational models of biophysical systems and processes with a focus on clinical and biomedical applications. Features include grid generation, assignment of material properties and boundary conditions, and solvers for biomechanical modeling and biomechanics-based non-rigid image registration.

SlicerCBM is under development at the Intelligent Systems for Medicine Lab at The University of Western Australia.

Modules

The SlicerCBM extension currently includes the following features implemented as 3D Slicer modules:

  • Segmentation

    • DTI Segmentation: Segment diffusion tensor image (DTI) into gray matter (GM), white matter (WM) and cerebrospinal fluid (CSF) tissue classes using fuzzy C-means clustering (FCM) algorithm.
    • Fusion: Create skull and scalp segments from brain segment
    • Fusion2
  • Geometry

    • Cran Creator
    • Fiducials To Surface
    • MeshNodes To Fiducials
    • Sheet From Points
    • Skull Generator
    • Surface Triangulation (deprecated): Create uniform triangulation of 3D surface model using PyACVD. This module is deprecated. Please use 3D Slicer's built-in Surface Toolbox instead.
  • Mesh/Grid

    • MVox Mesh Generator: Create structured hexahedral grid using MVox.
    • Tetrahedral Mesh Generator (deprecated): Create tetrahedral grid using Gmsh. This module is deprecated and will be removed. Please use the ComputationalGridGenerator module instead.
    • Computational Grid Generator (todo): Create tetrahedral grid using Gmsh.
    • Tumor Resection And BRain Remodelling: Create tetrahedral grid of brain with tumor cavity using Gmsh.
  • Property

    • Brain Material Properties
    • Electrical Conductivity: Assign electrical conductivity to an image volume.
    • Fuzzy Classification
  • BCs/Load

    • Brain Mesh Surface Cells Selection
    • Brain Surface Neighbouring Cells Selection
    • Electrodes To Markups
    • Fiducial To Model Distance
    • Node Selector
  • Solver

    • EEG Solver (todo)
    • MTLED Simulator
  • Visualization

    • Visualisation

Deprecated Modules

The following modules are no longer actively developed or automatically loaded when installing SlicerCBM, but may be useful for some applications:

  • Mesh Nodes To Fiducials (TODO) (see #51)
  • Tetrahedral Mesh Generator (TODO)

Installation

Please note that the SlicerCBM extension for 3D Slicer is currently supported on Linux and macOS operating systems only.

Some of the SlicerCBM modules require the following external dependencies to be installed.

Gmsh

Gmsh should be installed automatically when it is required by one of the SlicerCBM modules.

Due to GCC C++ ABI incompatibility between Gmsh and 3D Slicer, Gmsh cannot be installed automatically within 3D Slicer using the pip_install command (see #41). To install Gmsh on Linux please see this workaround.

MVox Mesh Voxelizer

To install MVox Mesh Voxelizer please refer to its Installation Guide.

ExplicitSim

To install ExplicitSim please refer to its Installation Guide.

External software

SlicerCBM depends on the following software:

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

ISML Logo

slicercbm's People

Contributors

andy9t7 avatar benzwick avatar saimasafdar2021 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

andy9t7 hasihays

slicercbm's Issues

Put modules in categories

List of possible categories:

  • Grids (new category): This can include meshes, grids, point clouds; e.g. UnstructuredGrid

  • Surface models (already exists in 3D Slicer)

  • Physics (new category)

    • Kinematics
    • Property
    • BCs, Load, Interaction???
    • Solution
  • Visualization (new category)

TODO:

  • Decide which categories to use.
  • Put the modules into one of the above categories.
  • Update README.md with modules listed in categories.
  • Update categories in the following locations:
    • Module documentation
    • README.md
    • Source code for each module

Fix BrainMaterialProperties module

  • Make Input Tumor Volume (fuzzy classified) optional
  • Remove nrrd, mvloader.nrrd and unused imports. See 2a5c393
  • Use slicer.util.arrayFromVolume instead of writing and reading temporary files. See 2a5c393
  • Check if this averaging is needed (why not use just the value from one voxel?):
    for i in range(iv-1, iv+1):
    for j in range(jv-1, jv+1):
    for k in range(kv-1, kv+1):
    material_props[idx, 1] += YM_parenchima *(1-brain_ventricle_membership[i, j, k])+YM_ventricles * brain_ventricle_membership[i, j, k]
    material_props[idx, 2] += PR_B * (1-brain_ventricle_membership[i, j, k])+PR_V * brain_ventricle_membership[i, j, k]
    material_props[idx, 1]/= 8
    material_props[idx, 2]/= 8
  • Use millimeters instead of meters for length. Also, convert related units (Pa to MPa, density, etc.). See 2a5c393

Add all modules

List of modules to add for EEG...

Module names are in bold font.

Image processing:

  • SkullStrippingUsingFreeSurfer (not yet implemented as a 3D Slicer module)
    • input: MRI???
    • output: brain mask??? MRI without skull???

Brain Model Generation:

  • TetrahedralMeshGenerator to generate both 2D and 3D brain models
    • input: brain surface model
    • output: 3D brain model (tetrahedral)
  • ComputationalGridGenerator supersedes TetrahedralMeshGenerator
  • FuzzyClassification Fuzzy tissue classification to classify tissue classes (ventricles, parenchyma and tumour (if present))
    • input: MRI, brain mask
    • output: fuzzy classified brain tissues (ventricles, brain parenchyma, tumor) as nrrd files
  • MTLEDSimulator to generate integration point file with respect to the input geometry.
  • BrainMaterialProperties Assign material properties to brain tissue using fuzzy tissue classification
    • input: ventricle, parenchyma and tumour classes (nrrd)
    • output: material properties files with each integration points assigned a material property (txt)

Electrode Sheet Generator:

  • ElectrodesToMarkups (rename as SegmentsToFiducials???) Identification of electrode locations on the intra-operative CT
    • input: segmented electrode image from CT (nrrd)
    • output: 3D fiducial points where there are electrodes
  • FiducialToModelDistance Projecting electrode locations onto brain surface model
    • input: 3D fiducials (original electrode locations identified from CT
    • output: 3D fiducials on the undeformed brain surface
  • FiducialsToSurface Create an electrode sheet model from a set of fiducial points (similar to SheetFromPoints below)
    • input: fiducials
    • output: 3D electrode sheet model
  • SheetFromPoints Create an electrode sheet model from a set of fiducial points (similar to FiducialsToSurface above).
    • input:
    • output:
  • BrainMeshSurfaceCellsSelection Select brain surface nodes when electrode sheet is not a single rectangular piece
    • input: brain surface model, projected electrode locations as 3D fiducials
    • output: selected brain triangles, loaded nodes on brain surface
  • BrainSurfaceNeighbouringCellsSelection Select neighbouring cells to fill in the gaps and select almost all the brain cells under different electrode sheet stripes ???strips???
    • input: selected brain triangles with respect to projected electrodes on brain surface
    • output: loaded nodes with respect to electrode stripes
  • SurfaceTriangulation to generate a uniform triangulation of the surface model (electrode sheet model or brain model or any other surface model)
    • input: brain surface model generated by model maker
    • output: uniformly triangulated brain surface model
  • NodeSelector Loaded node selection
    • input: electrode sheet triangulated 2D model, brain 2D model
    • output: 3D fiducial points on brain surface under electrode sheet representing selected brain nodes
  • Scattered Transform get the BSpline transform by using original electrode locations and projected electrode locations as input and apply the transform to get the deformed surface nodal positions for each of the loaded nodes selected on the brain surface.
  • MeshNodesToFiducials (need to change the name) Compute displacement loading based on loaded nodes selected on undeformed brain surface and corresponding node locations on the deformed brain geometry.
    • input: loaded node locations (undeformed brain geometry, deformed brain geometry)
    • output: displacement loading (load file)

Remaining steps for constructing brain biomechanical model

  • SkullGenerator to regenerate the skull surface using the triangulated brain surface model, defining contacts definition and combining skull and brain.
    • input: 2D brain model, 3D brain model
    • output: file containing skull nodes and elements

Solver for calculating brain deformations:

  • MTLEDSimulator
    • input: tetrahedral mesh; load file, material properties file
    • output: deformed model (.vtk file)
  • ExplicitSim MTLED C++ code which is a dependecy for MTLEDSimulator module (upload to separate bitbucket or github repository)

Image Warping:

  • ExplicitSimWarp Create image warping transform using ExplicitSim MLS shape functions (Ben to upload modifications)
    • input: output from MTLED simulation "brain7_LPS.vtu"???; image???; mask???
    • output: transform file "warp.nrrd"
  • ResampleDTIVolume (built-in Slicer module not part of SlicerCBM, in this list only as a reminder to include in documentation)
  • DTISegmentation Segment DTI using fuzzy c-means clustering
  • Fusion (rename as CreateSkullAndScalpSegments) Construct skull and scalp segments
    • input: MRI, skull stripped brain mask
    • output: skull and scalp layers
  • Fusion2 (rename as ???) Combine segments into a single label map (image fusion of tissue classes)
    • input: segmented tissues (wm, gm, csf, scalp, skull, electrode sheet model (can add or not))
    • output:
  • ElectricalConductivity Assign electrical conductivity to head model
    • input: complete segmentation labelmap; DTI (for Tuch's method)
    • output:
  • MVoxMeshGenerator Generate voxel-based mesh using MVox
    • input: attributes image (labelmap); conductivity tensors image
    • output: MFEM mesh; MFEM tensors grid function file
  • MVox which is a dependency for MVoxMeshGenerator module (requires MFEM), see separate repository at https://github.com/benzwick/mvox
  • EEGSolver Solve the EEG forward problem
    • input: mesh; conductivity tensors; dipole position; electrode positions
    • output:
  • Visualisation Visualize the deformation
  • EEGVisualization Visualize the electric potential

Other modules (not used for EEG)

  • TumorResectionAndBRainRemodelling

Miscellaneous

  • Check spelling and format of all module names (use US spelling and UpperCamelCase)
  • Add README.md for each module with short description (one sentence is enough) that is shown when browsing GitHub.

Use consistent units (mm) for length

Images use millimeters, whereas some meshes and MTLED integration point coordinates use meters. It would be better to use the same units everywhere.

Fix FuzzyClassification module

TODO list for submitting a new extension

https://github.com/Slicer/ExtensionsIndex/blob/master/.github/PULL_REQUEST_TEMPLATE.md#todo-list-for-submitting-a-new-extension

  • Extension has a reasonable name (not too general, not too narrow, suggests what the extension is for)
  • Repository name is Slicer+ExtensionName
  • Repository is associated with 3d-slicer-extension GitHub topic so that it is listed here. To edit topics, click the settings icon in the right side of "About" section header and enter 3d-slicer-extension in "Topics" and click "Save changes". To learn more about topics, read https://help.github.com/en/articles/about-topics
  • Extension description summarizes in 1-2 sentences what the extension is usable (should be understandable for non-experts)
  • Any known related patents must be mentioned in the extension description.
  • If source code license is more restrictive for users than BSD, MIT, Apache, or 3D Slicer license then the name of the used license must be mentioned in the extension description.
  • Extension URL and revision (scmurl, scmrevision) is correct, consider using a branch name (main, master, release, ...) instead of a specific git has to avoid re-submitting pull request whenever the extension is updated
  • Extension icon URL is correct (do not use the icon's webpage but the raw data download URL that you get from the download button - it should look something like this: https://raw.githubusercontent.com/user/repo/main/SomeIcon.png)
  • Screenshot URLs (screenshoturls) are correct, contains at least one
  • Homepage URL points to valid webpage containing the following:
    • Extension name
    • Short description: 1-2 sentences, which summarizes what the extension is usable for
    • At least one nice, informative image, that illustrates what the extension can do. It may be a screenshot.
    • Description of contained modules: at one sentence for each module
    • Tutorial: step-by-step description of at least the most typical use case, include a few screenshots, provide download links to sample input data set
    • Publication: link to publication and/or to PubMed reference (if available)
    • License: We suggest you use a permissive license that includes patent and contribution clauses. This will help protect developers and ensure the code remains freely available. We suggest you use the Slicer License or the Apache 2.0. Always mention in your README file the license you have chosen. If you choose a different license, explain why to the extension maintainers. Depending on the license we may not be able to host your work. Read here to learn more about licenses.
    • Content of submitted s4ext file is consistent with the top-level CMakeLists.txt file in the repository (description, URLs, dependencies, etc. are the same)

See also

Cannot import gmsh Python package

Cannot import gmsh Python package in ComputationalGridGenerator or TetrahedralMeshGenerator

This is happening with the 5.2.2 stable version of Slicer:

Python console user input: import gmsh
Python console user input: gmsh.initialize()
error: [/opt/slicer/Slicer-5.2.2-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.

See this discussion: https://discourse.slicer.org/t/cannot-import-gmsh-python-package/29344

See also this discussion on Gmsh: https://gitlab.onelab.info/gmsh/gmsh/-/issues/2474

Fix MTLEDSimulator

  • Remove unused variables and UI elements: inputSelector, outputSelector, imageThresholdSliderWidget, enableScreenshotsFlagCheckBox. See bb71f6a in #66
  • Remove hardcoded path for ExplicitSim command:
    command_line = ["/home/saima/explicitsim/build-bucketsearch/ExplicitSimRun", dir_path+"/demo.ini"]
  • Change the the dir_path working directory to not use the source code directory:
    dir_path = os.path.dirname(os.path.realpath(__file__))
  • Fix GUI to get ctkCollapsibleButtons working properly.

Fix MVoxMeshGenerator module's handling of arguments

Currently files that start with two hyphens -- will have the first hyphen removed:

# FIXME: This workaround to use hyphens in arguments should not be required
# see: https://github.com/Slicer/SlicerExecutionModel/issues/17
for i in range(len(mvox_args)):
if mvox_args[i].startswith('--'):
# Replace _ with - in long flags
# mvox_args[i].replace('_', '-')
# Remove one - from long flags to convert to short flags
mvox_args[i] = mvox_args[i].replace('--', '-')

Convert ComputationalGridGenerator from extension to module

Fix Fusion/CreateSkullAndScalpSegments module

  • Rename Fusion as CreateSkullAndScalpSegments or CreateSkullAndScalpFromBrainSegment
  • Fix interface (rename labels etc.)
  • Allow loading labelmap to be used as the input volume (instead of a scalar image volume)
  • Allow user to create or rename the segmentations node before it is created automatically
  • Check if we need to output both the segments and the labelmap (otherwise delete the temporary nodes when they are no longer required)

Keep data in MRML nodes in Slicer

Currently, there are a few files (e.g., Abaqus .inp, Gmsh .msh, ExplicitSim .txt and .ini) that are loaded and saved by specifying the filename in the module. It would be better to store this data in MRML nodes so it does not need to be saved and loaded when switching between modules. The vtkMRMLTextNode might be suitable for some data, but it currently works only with file extensions txt, xml or json. See also this discussion:
https://discourse.slicer.org/t/loading-vtkmrmltextnode-with-arbitrary-file-name-extension/29747

Fix SkullGenerator module

  • Do not save files to the source code directory (create new nodes in Slicer instead and allow user to save them).

Fix ComputationalGridGenerator

  • Remove unused gmsh_api:

  • Mesh 3D not 2D by uncommenting some code as described in the comment below:

  • Change "Input Folder" to "Output Folder" and move to "Outputs" in GUI.

  • Remove unused invert threshold option.

  • Check if "Wrap Solidify" effect has been installed before running this code, and prompt user to install SurfaceWrapSolidify extension:

        #use shrink wrapping to wrap the bone and get the full surface
        segmentEditorWidget.setActiveEffectByName("Wrap Solidify")
        effect = segmentEditorWidget.activeEffect()
        segmentEditorWidget.setCurrentSegmentID(segmentationNode.GetSegmentation().GetSegmentIdBySegmentName("cran"))
        effect.setParameter("region", "outerSurface")
    

    to avoid this error:

    Traceback (most recent call last):
      File "/home/ben/projects/SlicerCBM/SlicerCBM/ComputationalGridGenerator/ComputationalGridGenerator/ComputationalGridGenerator.py", line 273, in onApplyButton
        self.logic.process(self.ui.inputSelector.currentNode(), self.ui.fold_save.currentPath)
      File "/home/ben/projects/SlicerCBM/SlicerCBM/ComputationalGridGenerator/ComputationalGridGenerator/ComputationalGridGenerator.py", line 365, in process
        effect.setParameter("region", "outerSurface")
    AttributeError: 'NoneType' object has no attribute 'setParameter'
    
  • Add SurfaceWrapSolidify extension as a dependency CMakeLists.txt Remove SurfaceWrapSolidify effect instead. It is not needed if thresholding is done correctly. See #59

  • Fix error: "Failed to compute results: File (/home/ben/scratch/ComputationalGridGenerator/Segmentation_1_cran.stl) not found"

Module 'Fusion2' and 'FiducialsToSurface' failing to instantiate.

Module 'Fusion2' fail to instantiate due to missing python library 'pynrrd':

import nrrd

Implement try/except to fix.

Module 'FiducialsToSurface' fail to instantiate due to missing indentation in try/except block:

logic.run(self.ui.inputSelector.currentNode(), self.ui.outputSelector.currentNode(), enableScreenshotsFlag)

Indent line to fix.

Add new Gmsh Grid Generator module

Run Gmsh using external process instead of using Python interface to Gmsh to resolve #41 and to address licensing concerns around Gmsh and GPL inside 3D Slicer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.