Advanced Masking of Fields
Analysis & Postprocessing
1
Posts
1
Posters
10
Views
1
Watching
-
A user recently asked me:
I have a field distribution from an EM solver in the brain. I would like to mask the field in the left amygdala, but I my model does not separate the left/right amygdala. How can this be done?
There are different approaches, but here are some suggestions:
-
Split the amygdala in the model BEFORE running the simulation. You can select the amygdala and use the Mesh Tools -> Separate Meshes. Assign the same material property to both (left/right) solid regions and then AFTER running the simulation mask e.g. just the left amygdala.
-
You already have run the simulation.
- Mask the field to remove everything outside the amygdala,
- Create a sphere around the left amygdala (e.g. called "Sphere Amygdala_left"
- Mask the masked field with only the sphere region (by dragging it onto the masking list). This will remove everything outside the sphere, i.e., the field in the right amygdala.
Here is the second option in code:
simulation_extractor = simulation.Results() # Add a EmSensorExtractor em_sensor_extractor = simulation_extractor["Overall Field"] em_sensor_extractor.FrequencySettings.ExtractedFrequency = u"All" document.AllAlgorithms.Add(em_sensor_extractor) # Add a FieldMaskingFilter inputs = [em_sensor_extractor.Outputs["EM E(x,y,z,f0)"]] field_masking_filter = analysis.core.FieldMaskingFilter(inputs=inputs) field_masking_filter.UpdateAttributes() for id, name in zip(field_masking_filter.MaterialIds(), field_masking_filter.MaterialNames()): field_masking_filter.SetMaterial(id, name == "Amygdala") field_masking_filter.UpdateAttributes() document.AllAlgorithms.Add(field_masking_filter) # Add a second FieldMaskingFilter inputs = [field_masking_filter.Outputs["EM E(x,y,z,f0)"]] field_masking_filter_2 = analysis.core.FieldMaskingFilter(inputs=inputs) field_masking_filter_2.UpdateAttributes() for mat in field_masking_filter_2.MaterialIds(): field_masking_filter_2.SetMaterial(mat, False) field_masking_filter_2.SetEntities([model.AllEntities()["Sphere Amygdala_left"]]) field_masking_filter_2.UpdateAttributes() document.AllAlgorithms.Add(field_masking_filter_2) # Add a SliceFieldViewer inputs = [field_masking_filter_2.Outputs["EM E(x,y,z,f0)"]] slice_field_viewer = analysis.viewers.SliceFieldViewer(inputs=inputs) slice_field_viewer.Data.Mode = slice_field_viewer.Data.Mode.enum.QuantityComplexModulus slice_field_viewer.Data.Component = slice_field_viewer.Data.Component.enum.ComponentsAll slice_field_viewer.Slice.Index = 23 slice_field_viewer.Update() document.AllAlgorithms.Add(slice_field_viewer)
-