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. The shape of the T1 image and the shape of the electric field are different

The shape of the T1 image and the shape of the electric field are different

Scheduled Pinned Locked Moved CAD Modeling
18 Posts 2 Posters 255 Views 2 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.
  • brynB Offline
    brynB Offline
    bryn
    ZMT
    wrote last edited by
    #7

    but are you using a slice field viewer to show the interpolated MRI slice? If not you basically are looking at the original MRI, with different grid and data ordering.

    L 1 Reply Last reply
    0
    • brynB bryn

      but are you using a slice field viewer to show the interpolated MRI slice? If not you basically are looking at the original MRI, with different grid and data ordering.

      L Offline
      L Offline
      lucky_lin
      wrote last edited by
      #8

      @bryn I don't know how to use the slice viewer to inspect the T1 image. I just want to export it.

      1 Reply Last reply
      0
      • brynB Offline
        brynB Offline
        bryn
        ZMT
        wrote last edited by bryn
        #9

        I sent you code (it can also be done in GUI) above to interpolate the T1w image onto the E-field/simulation grid. If you do that you can export it in the same format as you export the E-field (not as a nii.gz file, since the simulation grid is rectilinear which is not supported by nifti files).

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lucky_lin
          wrote last edited by lucky_lin
          #10

          @bryn Is the following code correct? I'm not sure if the input is correct.

          inputs1 = [model_to_grid_filter.Outputs[""]]
          field_data_text_exporter1 = analysis.exporters.FieldDataTextExporter(inputs=inputs1)
          field_data_text_exporter1.FileName = output_file1
          field_data_text_exporter1.UpdateAttributes()
          document.AllAlgorithms.Add(field_data_text_exporter1)
          field_data_text_exporter1.Update(overwrite=True)
          
          1 Reply Last reply
          0
          • brynB Offline
            brynB Offline
            bryn
            ZMT
            wrote last edited by
            #11

            this does not include the interpolation...

            to access an output of an analysis algorithm you can use named outputs or indexed outputs, in your snippet above it may be easier to use the index '0'.

            inputs1 = [model_to_grid_filter.Outputs[0]]
            
            L 1 Reply Last reply
            0
            • brynB bryn

              this does not include the interpolation...

              to access an output of an analysis algorithm you can use named outputs or indexed outputs, in your snippet above it may be easier to use the index '0'.

              inputs1 = [model_to_grid_filter.Outputs[0]]
              
              L Offline
              L Offline
              lucky_lin
              wrote last edited by
              #12

              @bryn Thank you!!! I'll give it a try!^^

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lucky_lin
                wrote last edited by lucky_lin
                #13

                @bryn After executing the code, an error occurred that prevented the export of the txt file.
                ae3e0fe4-e2a0-4c96-ba40-9524c85e6988-image.png

                1 Reply Last reply
                0
                • brynB Offline
                  brynB Offline
                  bryn
                  ZMT
                  wrote last edited by
                  #14

                  looking at the error 'Unable to create destination file', I would guess you are trying to write to a directory that does not exist (yet) or without write permissions

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    lucky_lin
                    wrote last edited by
                    #15

                    However, the electric field data can be exported.
                    image.png

                    1 Reply Last reply
                    0
                    • brynB Offline
                      brynB Offline
                      bryn
                      ZMT
                      wrote last edited by
                      #16

                      what does your code look like? I create the pipeline in the GUI and it seems to run fine for me (v9.0.0). The "To Python" function yields

                      # This script was auto-generated by Sim4Life version 9.0.1
                      
                      import numpy
                      import s4l_v1.analysis as analysis
                      import s4l_v1.document as document
                      import s4l_v1.model as model
                      import s4l_v1.units as units
                      from s4l_v1 import ReleaseVersion
                      from s4l_v1 import Unit
                      
                      try:
                          # Define the version to use for default values
                          ReleaseVersion.set_active(ReleaseVersion.version9_0)
                          
                          # Creating the analysis pipeline
                          # Adding a new ModelToGridFilter
                          inputs = []
                          model_to_grid_filter = analysis.core.ModelToGridFilter(inputs=inputs)
                          model_to_grid_filter.Name = "IXI025-Guys-0852-T1"
                          model_to_grid_filter.Entity = model.AllEntities()["IXI025-Guys-0852-T1"]
                          model_to_grid_filter.UpdateAttributes()
                          document.AllAlgorithms.Add(model_to_grid_filter)
                      
                          # Adding a new SimulationExtractor
                          simulation = document.AllSimulations["EM"]
                          simulation_extractor = simulation.Results()
                      
                          # Adding a new EmSensorExtractor
                          em_sensor_extractor = simulation_extractor["Overall Field"]
                          em_sensor_extractor.FrequencySettings.ExtractedFrequency = u"All"
                          document.AllAlgorithms.Add(em_sensor_extractor)
                      
                          # Adding a new FieldInterpolationFilter
                          inputs = [model_to_grid_filter.Outputs[0], em_sensor_extractor.Outputs["EM E(x,y,z,f0)"]]
                          field_interpolation_filter = analysis.core.FieldInterpolationFilter(inputs=inputs)
                          field_interpolation_filter.UpdateAttributes()
                          document.AllAlgorithms.Add(field_interpolation_filter)
                      
                          # Adding a new FieldDataTextExporter
                          inputs = [field_interpolation_filter.Outputs[""]]
                          field_data_text_exporter = analysis.exporters.FieldDataTextExporter(inputs=inputs)
                          field_data_text_exporter.FileName = u"D:\\temp\\ExportedFieldData-T1w.txt"
                          field_data_text_exporter.UpdateAttributes()
                          document.AllAlgorithms.Add(field_data_text_exporter)
                      
                      except Exception as exc:
                          import traceback
                          traceback.print_exc()
                          # Reset active version to default
                          ReleaseVersion.reset()
                          raise(exc)
                      
                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        lucky_lin
                        wrote last edited by lucky_lin
                        #17
                        This post is deleted!
                        1 Reply Last reply
                        0
                        • brynB Offline
                          brynB Offline
                          bryn
                          ZMT
                          wrote last edited by
                          #18

                          your code is still not using the FieldInterpolationFilter to interpolate the T1w image onto the same grid as the E-field. Note, the FieldDataTextExporter takes the output of the interpolator as input

                          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