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. Analysis & Postprocessing
  4. Advanced Masking of Fields

Advanced Masking of Fields

Scheduled Pinned Locked Moved Analysis & Postprocessing
1 Posts 1 Posters 8 Views 1 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
    #1

    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:

    1. 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.

    2. 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)
    

    Youtube Video

    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