Skip to content
  • Search
Skins
  • Light
  • Brite
  • 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. Python API
  4. Importing file as a Label Field

Importing file as a Label Field

Scheduled Pinned Locked Moved Python API
10 Posts 5 Posters 4.0k Views 5 Watching
  • 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.
  • S Offline
    S Offline
    Spuky
    wrote on last edited by
    #1

    Hello,

    Is there a way how to import file such as *.nrrd or *.nii as a Label Field via python? Such an option is possible to select when importing the file via the GUI, however I can't find a way to do it via the python interface.

    Regards,

    Spuky

    P 1 Reply Last reply
    0
    • A Offline
      A Offline
      aridam
      wrote on last edited by
      #2

      Hello,
      any solution on this?
      Thanks,
      Arianna

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fanruifu
        wrote on last edited by
        #3

        Is this what you need? I can import stl file in this way.

        import s4l_v1.model as model
        file=model.Import('file address')

        A 1 Reply Last reply
        0
        • F fanruifu

          Is this what you need? I can import stl file in this way.

          import s4l_v1.model as model
          file=model.Import('file address')

          A Offline
          A Offline
          aridam
          wrote on last edited by
          #4

          @fanruifu Thanks! Nop, these lines correspond in doing in thee GUI: import, select file, ok.
          I want to reproduce: import, select file, import file as a label field (pop up window that shows up when selecting the file), ok.
          I hope it is clear, thank you!

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fanruifu
            wrote on last edited by
            #5

            How about this one.
            https://forum.zmt.swiss/topic/71/introducing-the-image-modeling-module-image-and-labelfield

            1 Reply Last reply
            0
            • A Offline
              A Offline
              aridam
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • brynB Offline
                brynB Offline
                bryn
                ZMT
                wrote on last edited by
                #7

                Hi, not sure this api is already in the release version, but in the dev version there is

                ImageModeling.ImportImage(filepath, as_labelfield: bool = False, tissuelist_path: str = "")
                

                This would allow you to import as labelfield and pre-assign the tissue names and colors.

                If that doesn't work, you can access the options using following strategy:

                • create an importer for the file,
                • inspect the options.

                This is a (general) solution to Import with the options:

                imp = XCoreModeling.CreateImporterFromFile(file_path)
                imp.Options.ImportLabelField.Value = True
                imp.Import(file_path)
                

                To inspect the options, you can use the DumpTree method: imp.Options.DumpTree()

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  aridam
                  wrote on last edited by
                  #8

                  this is extremely useful! thanks a lot.

                  1 Reply Last reply
                  0
                  • S Spuky

                    Hello,

                    Is there a way how to import file such as *.nrrd or *.nii as a Label Field via python? Such an option is possible to select when importing the file via the GUI, however I can't find a way to do it via the python interface.

                    Regards,

                    Spuky

                    P Offline
                    P Offline
                    PiersPiper
                    Banned
                    wrote on last edited by PiersPiper
                    #9
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      PiersPiper
                      Banned
                      wrote on last edited by PiersPiper
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      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