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 bryn

    what do you mean by "The T1 and the electric field seem to be in opposite directions along the x-axis"?

    • the interpolated T1 image and the E-field?
    • is the interpolated T1 image NOT shown in the same position/orientation as the original T1 image from the modeler?
    • is the original T1 image (which you imported in the modeler) aligned/shown in the same position/orientation as the model?

    It would help if you would add screenshots to your question, with explanations of what each screenshot is trying to demonstrate.

    L Offline
    L Offline
    lucky_lin
    wrote last edited by
    #6

    @bryn What I mean is that the slice with index 0 in the T1 image and the slice with index 1 in the electric field are not on the same side of the head model along the x-axis. Additionally, I would like to know if it is possible to export the interpolated T1 image. I need the T1 structural image that corresponds to the simulated electric field to create a dataset.
    c2b26fe5-7cd7-465e-9e27-81b29b410516-image.png 8c9a6f68-03be-4d1c-8a88-8ce3eab8c903-image.png

    1 Reply Last reply
    0
    • 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