Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. CAD Modeling
  4. Introducing the Image Modeling module: Image and LabelField

Introducing the Image Modeling module: Image and LabelField

Scheduled Pinned Locked Moved CAD Modeling
1 Posts 1 Posters 563 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • brynB Offline
    brynB Offline
    bryn
    ZMT
    wrote on last edited by
    #1

    If you are working with medical image data, or some other form of 3D images, and image segmentations, the Sim4Life Python provides a set of tools which allow batch processing, and powerful custom operations based on Python scripts and thirdparty modules such as numpy, vtk, etc.

    The image model entity is defined in the ImageModeling module. The api includes the properties and methods:
    0_1539094204095_Image_API.PNG

    The interesting properties are Image, which returns a 3D numpy array that wraps the actual image data of the entity, and the Shape, Spacing and Transform. If you are missing the typical 'Origin' property, this information is stored in the Transform.

    ImageModeling.LabelField is a class which stores 3D segmentation data, i.e. it is an (16-bit unsigned integer) image with information about the labels (label index, name and color).

    The following simple script illustrates how to load an iSEG segmentation (LabelField) and generate a surface model using the Python API.

    import XCoreModeling
    import ImageModeling
    import ViP
    
    ents = XCoreModeling.Import(r"F:\Data\test_iseg.prj")
    
    label_fields = [e for e in ents if isinstance(e,ImageModeling.LabelField)]
    assert len(label_fields)==1, "expecting one LabelField"
    
    print "There are", len(label_fields[0].Labels), "labels"
    print "Label of Artery is", label_fields[0].Labels["Artery"]
    print "The segmentation has dimensions", label_fields[0].Shape
    print "The segmentation has spacing", label_fields[0].Spacing
    print "The segmentation has orientation/offset", label_fields[0].Transform
    
    ViP.ExtractSurface(label_fields[0], smooth=True, simplify=True)
    

    0_1539096410457_script_output.PNG

    Note about s4l_v1 API: Above classes and methods are partly already contained in the official Sim4Life Python API (s4l_v1), or will be added in the coming release within the s4l_v1.model.image scope.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Search