Based on the this post, the tool is based on the formula derived in the Grossman et al., 2017 paper which is the following:

I applied this formula and the results I got were not correct when post-processing the two electric fields in Python, outside of Sim4Life. The above formula is for the |**E_1**| > |**E_2**| area. The code that I am using in Python is:

```
import numpy as np
import scipy.io as io
base_data = io.loadmat('Directory of extracted mat file for the simulation 1')
delta_data = io.loadmat('Directory of extracted mat file for the simulation 2')
e_field_1 = np.nan_to_num(base_data['EM_E_x_y_z_f0_Snapshot0'])
e_field_2 = np.nan_to_num(delta_data['EM_E_x_y_z_f0_Snapshot0'])
# Calculate the subtraction and addtion of the vectors
E_plus = np.add(e_field_1, e_field_2) # Create the sum of the E fields
E_minus = np.subtract(e_field_1, e_field_2) # Create the difference of the E fields
# Calculate the angles between the two fields for each vector
# Assuming that E_a is the difference of the vectors
dot_angle = np.einsum('ij,ij->i', e_field_1, E_minus)
cross_angle = np.linalg.norm(np.cross(e_field_1, E_minus), axis=1)
angles = np.arctan2(cross_angle, dot_angle)
# Condition to have two times the E2 field amplitude
max_condition = np.linalg.norm(e_field_2, axis=1) < np.linalg.norm(e_field_1, axis=1)*np.cos(angles)
e1_gr_e2 = np.where(np.linalg.norm(e_field_1, axis=1) > np.linalg.norm(e_field_2, axis=1), max_condition, False)
# Calculate the maximum envelope
envelope = np.where(e1_gr_e2, 2.0*np.linalg.norm(e_field_2, axis=1), envelope)
# Find the other points where the condition is not true
tmp = np.logical_xor(e1_gr_e2, np.linalg.norm(e_field_1, axis=1) > np.linalg.norm(e_field_2, axis=1))
envelope = np.where(tmp, 2.0*(np.linalg.norm(np.cross(e_field_2, E_minus), axis=1)/np.linalg.norm(E_minus, axis=1)), envelope)
np.nan_to_num(envelope)
```

The resulting graphs can be seen in the figure below, with the calculations from the above code shown on the left-most image, results from Sim4Life shown in the middle and the common points between Sim4Life and Python calculations shown in the right-most image.

I have tried many variations of the code, setting the amplitudes of electric field on and two to double the value for all points and trying to find the common points and also tried different variations with the indices in the cross product formula. Still with all the variations I could not get all the points filled in the common points plot. The image with all calculated common points is shown below. The correct simulation image is also shown below.

Thank you!

]]>The key ingredients are the "Far Field Sensor", the "Radiation Evaluator" and the "1D Filter" ]]>

How can I display the big green arrow that shows the max direction. There was an option "Show Max Direction" (see screenshot above). ]]>

It did actually speed the process up quite a bit.

Thanks a bunch. ]]>

these return the numpy array holding the raw data. Type dir(sensor_extractor["v"].Data) in the Console to get a list of available functions that can be useful for Data objects.

]]>Hi, the Workbench does not allow "dragging" input or output connections (yet). However, if you select an algorithm (which you can do in the Workbench), you can change its "Input Connection" in the "Properties" window:

]]>Thank you for your reply ! Indeed, it seems that one of my components was holding so much current at the end of the simulation. After I increased the number of periods, the results were more consistent. However, even before, the global convergence level was better than -25 dB. This is why I thought I could trust my results since the solver-log said that my results could be trusted in the frequency range of interest.

]]>This means you can use this approach if you could have used the Ohmic Quasi-Static solver instead of the Quasi-Static one (since the former neglects displacement currents, while the latter does not).

For currents flowing between electrodes placed on a human body, displacement currents are typically negligible. ]]>

First 2 pictures are of the 2 electrode model (working) and the last 2 of the 3 electrode model in which only the Electrode-Insulator pair is working and gives SAR values. I know that the settings aren't the same, but even if I set it up exactly the same way as the 2 electrode model, the same problem appears.

!

]]>Ohh that is maybe a better solution to the current problem, awesome:) ]]>

Thank you, I think that has solved my problem

]]>Why the dimension of the axis are different and so how to reshape the SAR with different dimension of axis vectors ? ]]>

I extract the max temperature at a point using a line passing through the point (I find lines of the intersection of the 3 slices xy-xz-yz at max). But the value is much smaller than the value which a point sensor gives and also the max value which the color scale bar shows. What is the reason?

]]>to have the temperature in different points in a plane wave simulation, once I used a point sensor and once I just drew (not used in the simulation) a line passing through that point. The temperature of a point using the line is very different (about 10 times smaller) from the value of point sensor at that point. What's the reason?

Thanks.

]]>Is that possible to save the values of different quantities like SAR, E-field or temperature in a text file or matlab file?

Thanks.

]]>What kind of interpolation is used to export data (for example SAR value) a long a line (which is not used in the simulation and just used to extract data)? I''m wondering if it is linear?

Thanks.

]]>Below is an example that does that for an anatomical model (or any other group of entities).

It uses a short helper function that returns the list of all model objects (aka entities) that are within a certain model folder (aka Entity Group). This list of objects is then passed to the MaskFilter.

```
import s4l_v1.analysis as analysis
import s4l_v1.document as document
import s4l_v1.model as model
import itertools
def all_entities_within_group(entity_group):
'''return a list of all model entities within a given group, including all subdirectories'''
if isinstance(entity_group, model.EntityGroup):
return list(itertools.chain.from_iterable(
all_entities_within_group(e) for e in entity_group.Entities))
else:
return [entity_group]
vip_group = model.AllEntities()['Duke']
entities_from_vip_model = all_entities_within_group(vip_group)
# Creating the analysis pipeline
# Adding a new SimulationExtractor
simulation = document.AllSimulations["EM"]
simulation_extractor = simulation.Results()
# Adding a new EmSensorExtractor
em_sensor_extractor = simulation_extractor["Overall Field"]
document.AllAlgorithms.Add(em_sensor_extractor)
# Adding a new FieldMaskingFilter
inputs = [em_sensor_extractor.Outputs["EM E(x,y,z,f0)"]]
field_masking_filter = analysis.core.FieldMaskingFilter(inputs=inputs)
field_masking_filter.SetAllMaterials(False)
field_masking_filter.SetEntities(entities_from_vip_model)
field_masking_filter.UpdateAttributes()
document.AllAlgorithms.Add(field_masking_filter)
```

]]>