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. Python API
  4. Algorithm "Max Modulation" was not yet exposed in the Python API

Algorithm "Max Modulation" was not yet exposed in the Python API

Scheduled Pinned Locked Moved Python API
19 Posts 3 Posters 716 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.
  • L Offline
    L Offline
    lucky_lin
    wrote on last edited by
    #1

    Can the maximum value of the TI envelope currently only be calculated through the GUI interface?

    H 1 Reply Last reply
    0
    • L Offline
      L Offline
      lucky_lin
      wrote on last edited by
      #2

      Additionally, my boundary is set to 1V, and I want to normalize it to 1mA. In the GUI, I need to model a box to calculate the scale factor, but it is a bit cumbersome to create a box in the script to cover each electrode. Is there a better way to quickly normalize it?

      1 Reply Last reply
      0
      • H Offline
        H Offline
        halder
        ZMT
        wrote on last edited by
        #3

        @lucky_lin

        Regarding normalizing the field between the electrode, you could use the current extractor tool.

        1. After running your simulation in the Analysis Tab, select the simulation and extract the "Overall Field"
        2. Select the overall field, click on the "Field Data Tools" in the ribbon, and select "Current Extractor". This output gives the current in the system in units of Amps.
        3. Select the "Overall Field" and in the Controller select "EM E(x,y,z,f0)". Following this click on "Field Data Tools" in the ribbon again. Select "Field Scaling" now.
        4. Change the scale factor in the controller window based on the following formula (1/Flux*1000) since you want it to be normalized to 1mA. Use the current value you have extracted for the following calculation.
        5. Click Refresh.
        6. Then select the scaled electric field and use the slice viewer to plot it.

        Attached is the code below
        temp-35.py

        C L 2 Replies Last reply
        0
        • L lucky_lin

          Can the maximum value of the TI envelope currently only be calculated through the GUI interface?

          H Offline
          H Offline
          halder
          ZMT
          wrote on last edited by
          #4

          @lucky_lin

          With Sim4Life 8.2, which is the latest version available TI envelope can only be calculated with GUI interface. But this will soon be available with the next release.

          L 3 Replies Last reply
          0
          • H halder

            @lucky_lin

            With Sim4Life 8.2, which is the latest version available TI envelope can only be calculated with GUI interface. But this will soon be available with the next release.

            L Offline
            L Offline
            lucky_lin
            wrote on last edited by lucky_lin
            #5

            @halder Thank you very much! Looking forward to the next version! ^^

            1 Reply Last reply
            0
            • H halder

              @lucky_lin

              With Sim4Life 8.2, which is the latest version available TI envelope can only be calculated with GUI interface. But this will soon be available with the next release.

              L Offline
              L Offline
              lucky_lin
              wrote on last edited by
              #6

              @halder I ran your code and encountered the following error: Traceback (most recent call last):
              File "F:\Huilin\sim4life_pro\script\head_segment.py", line 826, in <module>
              comp1 = output1.Data.GetComponent(0)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              RuntimeError: Could not allocate memory for numpy array.
              Traceback (most recent call last):
              File "F:\Huilin\sim4life_pro\script\head_segment.py", line 875, in <module>
              raise(exc)
              File "F:\Huilin\sim4life_pro\script\head_segment.py", line 826, in <module>
              comp1 = output1.Data.GetComponent(0)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              RuntimeError: Could not allocate memory for numpy array.

              My memory is 256GB, and I checked the Task Manager and found that not much memory was being used. So I ran it two more times, and the third time it succeeded, but I received a warning:
              Analysis : [Warn] Found 451673 NaN (not a number) values (81.96 %)

              1 Reply Last reply
              0
              • H halder

                @lucky_lin

                With Sim4Life 8.2, which is the latest version available TI envelope can only be calculated with GUI interface. But this will soon be available with the next release.

                L Offline
                L Offline
                lucky_lin
                wrote on last edited by
                #7

                @halder Why is the file not in .smash format after I save it? How should I load the file again after closing the software?

                H 1 Reply Last reply
                0
                • H Offline
                  H Offline
                  halder
                  ZMT
                  wrote on last edited by halder
                  #8

                  @lucky_lin yes this RunTimeError is related a Update you have to do, notice line 32 in my code please keep that line.

                  Sim4Life_Oh5OfZrEqR.png

                  L 2 Replies Last reply
                  0
                  • H Offline
                    H Offline
                    halder
                    ZMT
                    wrote on last edited by
                    #9

                    The current extractor essentially calculates the current between two electrodes by integrating the current density field through a closed surface (defined as an isopotential surface surrounding one electrode -the user can use the default isopotential value or customize it, this will affect this number of NaNs). To access these parameters as part of your code use the following:
                    current_extractor.IsoSurfacePerCentThreshold = Enter Value
                    current_extractor.SurfaceRefinement = Enter Value

                    1 Reply Last reply
                    0
                    • L lucky_lin

                      @halder Why is the file not in .smash format after I save it? How should I load the file again after closing the software?

                      H Offline
                      H Offline
                      halder
                      ZMT
                      wrote on last edited by
                      #10

                      @lucky_lin I am a bit confused with what you mean by this, can you upload a screenshot?

                      L 2 Replies Last reply
                      0
                      • H halder

                        @lucky_lin

                        Regarding normalizing the field between the electrode, you could use the current extractor tool.

                        1. After running your simulation in the Analysis Tab, select the simulation and extract the "Overall Field"
                        2. Select the overall field, click on the "Field Data Tools" in the ribbon, and select "Current Extractor". This output gives the current in the system in units of Amps.
                        3. Select the "Overall Field" and in the Controller select "EM E(x,y,z,f0)". Following this click on "Field Data Tools" in the ribbon again. Select "Field Scaling" now.
                        4. Change the scale factor in the controller window based on the following formula (1/Flux*1000) since you want it to be normalized to 1mA. Use the current value you have extracted for the following calculation.
                        5. Click Refresh.
                        6. Then select the scaled electric field and use the slice viewer to plot it.

                        Attached is the code below
                        temp-35.py

                        C Offline
                        C Offline
                        cjanaya
                        wrote on last edited by
                        #11

                        @halder thank you for the explanation and laying out the steps for scaling the field. I'm also trying to normalize my current to 1mA in my simulations. However, I'm running an older version of sim4life, v6.2. Is this "Current Extractor" tool only available in newer versions of the software? Are there any concerns with backwards compatibility of previous models if I were to update to the current version of sim4life?

                        I was following the steps on an old post and using the "Total Flux" to evaluate my currents. Would an equivalent method to the "Current Extractor" tool be to evaluate "Total Flux" for the Absolute Value of J field on the surface of my boundary condition? Thanks in advance

                        1 Reply Last reply
                        0
                        • H halder

                          @lucky_lin I am a bit confused with what you mean by this, can you upload a screenshot?

                          L Offline
                          L Offline
                          lucky_lin
                          wrote on last edited by
                          #12
                          This post is deleted!
                          1 Reply Last reply
                          0
                          • H halder

                            @lucky_lin yes this RunTimeError is related a Update you have to do, notice line 32 in my code please keep that line.

                            Sim4Life_Oh5OfZrEqR.png

                            L Offline
                            L Offline
                            lucky_lin
                            wrote on last edited by lucky_lin
                            #13

                            @halder Does using the default equipotential value affect the accuracy of normalization? Can NaN be completely eliminated?

                            L 1 Reply Last reply
                            0
                            • H halder

                              @lucky_lin yes this RunTimeError is related a Update you have to do, notice line 32 in my code please keep that line.

                              Sim4Life_Oh5OfZrEqR.png

                              L Offline
                              L Offline
                              lucky_lin
                              wrote on last edited by
                              #14

                              @halder I have the line of code 'update', but it still reports an error.
                              f3172062-6b5d-42b4-8c21-38809fa2debd-image.png

                              1 Reply Last reply
                              0
                              • H halder

                                @lucky_lin I am a bit confused with what you mean by this, can you upload a screenshot?

                                L Offline
                                L Offline
                                lucky_lin
                                wrote on last edited by
                                #15
                                This post is deleted!
                                1 Reply Last reply
                                0
                                • L lucky_lin

                                  @halder Does using the default equipotential value affect the accuracy of normalization? Can NaN be completely eliminated?

                                  L Offline
                                  L Offline
                                  lucky_lin
                                  wrote on last edited by lucky_lin
                                  #16

                                  @halder This is the max modulation value I extracted, and the vast majority of the values are NaN. However, when I checked the slice viewer, I didn't notice any issues. Are these NaN values treated as 0 in the slice viewer? I extracted this value to create a 3D dataset, so I'm a bit confused about how to handle these NaN values.aaf9e88d-cb7e-4fb4-b7db-530bfcbc1b79-image.png

                                  1 Reply Last reply
                                  0
                                  • H Offline
                                    H Offline
                                    halder
                                    ZMT
                                    wrote on last edited by
                                    #17

                                    As mentioned changing IsoSurfacePerCentThreshold/SurfaceRefinement will effect the NaNs calculated. I would start with using the default, then before extracting the field quantities applying a NaN filter (which will replace it with 0s) and then exporting the data. Then go back and recalculate using the current extractor by refining these quantities and follow the same procedure and check what the difference is just to be sure.

                                    L 1 Reply Last reply
                                    0
                                    • H halder

                                      @lucky_lin

                                      Regarding normalizing the field between the electrode, you could use the current extractor tool.

                                      1. After running your simulation in the Analysis Tab, select the simulation and extract the "Overall Field"
                                      2. Select the overall field, click on the "Field Data Tools" in the ribbon, and select "Current Extractor". This output gives the current in the system in units of Amps.
                                      3. Select the "Overall Field" and in the Controller select "EM E(x,y,z,f0)". Following this click on "Field Data Tools" in the ribbon again. Select "Field Scaling" now.
                                      4. Change the scale factor in the controller window based on the following formula (1/Flux*1000) since you want it to be normalized to 1mA. Use the current value you have extracted for the following calculation.
                                      5. Click Refresh.
                                      6. Then select the scaled electric field and use the slice viewer to plot it.

                                      Attached is the code below
                                      temp-35.py

                                      L Offline
                                      L Offline
                                      lucky_lin
                                      wrote on last edited by
                                      #18

                                      @halder After normalizing both Overall Fields to 1mA and using Max Modulation, I see that there are two weights. What is the purpose of this? If I want to see the superimposed field of 1.8mA and 0.2mA, which corresponds to a 9:1 TI field, should I normalize the Overall Fields to 1.8mA and 0.2mA respectively and then calculate using Max Modulation with weight of 1 and 1 , or should I directly use the fields normalized to 1mA and then use weights of 9 and 1 for Max Modulation?8d2774ae-2e0a-4ec8-bb3d-dbc7f7f48365-{3608EF5C-84E6-4DFA-82AF-359527FA319D}.png

                                      1 Reply Last reply
                                      0
                                      • H halder

                                        As mentioned changing IsoSurfacePerCentThreshold/SurfaceRefinement will effect the NaNs calculated. I would start with using the default, then before extracting the field quantities applying a NaN filter (which will replace it with 0s) and then exporting the data. Then go back and recalculate using the current extractor by refining these quantities and follow the same procedure and check what the difference is just to be sure.

                                        L Offline
                                        L Offline
                                        lucky_lin
                                        wrote on last edited by
                                        #19

                                        @halder When I performed TI simulation using the spherical model, I found that if I changed the current direction of one pair of electrodes, the maximum value of the TI Max (x, y, z) slice remained unchanged. Changing the current of one pair of electrodes should have shifted from the original same-direction superposition to a reverse weakening, so why does it remain unchanged? Is it because Max Modulation only uses EM for calculations?

                                        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