Skip to content
  • 0 Votes
    1 Posts
    5 Views
    No one has replied
  • How to sense values on head.

    Simulations & Solvers
    3
    0 Votes
    3 Posts
    56 Views
    R
    Solved it - Model the electrode as PEC and use the voltage reader
  • 0 Votes
    4 Posts
    48 Views
    brynB
    great. yes, it makes sense that you need to specify the Nerve and the nerve trajectories in the masking filter. Regarding the export to .mat file: I guess you could access the masked field as a numpy array in Sim4Life's Python and process/plot/export it from there, see e.g., this Python for MATLAB users cheatsheet https://numpy.org/doc/stable/user/numpy-for-matlab-users.html To access the masked field in Python you could use a script like this import numpy as np import s4l_v1.analysis as analysis import s4l_v1.document as document import s4l_v1.model as model import s4l_v1.units as units import XPostProcessor as xp from s4l_v1 import Unit try: # Select your simulation by name here simulation = document.AllSimulations["LF - Copy"] simulation_extractor = simulation.Results() em_sensor_extractor = simulation_extractor["Overall Field"] em_sensor_extractor.FrequencySettings.ExtractedFrequency = u"All" inputs = [em_sensor_extractor.Outputs["EM E(x,y,z,f0)"]] field_masking_filter = analysis.core.FieldMaskingFilter(inputs=inputs) field_masking_filter.UpdateAttributes() # note I used a dummy simulation with a Nerve entity and a CenterLine spline, which I voxeled with the Nerve material properties nerve_entities = [model.AllEntities()["Nerve"].Id, model.AllEntities()["CenterLine"].Id] for uid in field_masking_filter.MaterialIds(): select = uid in nerve_entities field_masking_filter.SetMaterial(uid, False) field_masking_filter.Update() masked_field = field_masking_filter.Outputs[0].Data assert isinstance(masked_field, xp.FieldData) masked_field_array = masked_field.Field(0) assert isinstance(masked_field_array, np.ndarray) masked_field_grid = masked_field.Grid assert isinstance(masked_field_grid, xp.RectilinearGrid) print(masked_field.Quantity.Name) print(masked_field.Quantity.Unit) print(masked_field_array.shape) except Exception as exc: import traceback traceback.print_exc() raise(exc)
  • Multiport Simulations Export Huygens Source

    Analysis & Postprocessing
    10
    0 Votes
    10 Posts
    379 Views
    SylvainS
    Hi Lisa, You are correct. It won't be possible to link a single multiport simulation with several individual single-port source simulations. However, you can have multiple single-port "exposure" simulations, each linking to a Huygens source file (the one you exported using the Huygens Exporter, for each port). The results can be combined "manually" at post-processing, using the Field Combiner. Note that this algorithm simply does a weighted sum of its inputs, so if you want to compute SAR you have to use it on the E fields, and compute SAR on the combined E field. I can explain in more detail if any of this is unclear, feel free to ask (in that case, please provide a more comprehensive overview of what you are trying to achieve). [image: 1760077688303-2504eb52-f6e1-46b3-b283-41dde348fd7a-image.png]
  • 0 Votes
    9 Posts
    3k Views
    M
    Hi everyone, I'm using Sim4Life and currently working with the Optimizer tool. I would like to run the optimization algorithm on a network server using ARES instead of executing it on my local machine. However, I can't seem to find an option in the simulation settings that allows me to select the server as the execution target — the optimizer always defaults to running locally. Is it now possible to run parameter sweeps and optimization tasks on a remote machine in the network (without using a remote desktop session)? If so, how can I configure this in Sim4Life? Thanks in advance!
  • 0 Votes
    1 Posts
    84 Views
    No one has replied
  • 0 Votes
    3 Posts
    651 Views
    brynB
    Btw, this topic is quite similar https://forum.zmt.swiss/topic/735/the-shape-of-the-t1-image-and-the-shape-of-the-electric-field-are-different
  • Understand the h5 file structure

    Analysis & Postprocessing
    3
    0 Votes
    3 Posts
    667 Views
    brynB
    to get the current density in Python you could use a script like import s4l_v1.document as document try: # add a SimulationExtractor for the simulation call "LF" simulation = document.AllSimulations["LF"] simulation_extractor = simulation.Results() # create an EmSensorExtractor em_sensor_extractor = simulation_extractor["Overall Field"] em_sensor_extractor.FrequencySettings.ExtractedFrequency = u"All" document.AllAlgorithms.Add(em_sensor_extractor) # update the pipeline, make sure current density is extracted em_sensor_extractor.Outputs["J(x,y,z,f0)"].Update() # get data current_density_field = em_sensor_extractor.Outputs["J(x,y,z,f0)"].Data except Exception as exc: import traceback traceback.print_exc()
  • 0 Votes
    5 Posts
    771 Views
    G
    Dear, @AntoninoMC Thank you very much for your detailed clarification. I now understand the fundamental difference between the Ohmic solver and the QS solver, and I have also tried some test runs with the QS solver, which helped me to grasp the impact of frequency dependence more clearly. In my current application, I am applying a voltage to the human body and measuring the potential difference between two points on the head. I am particularly interested in how the measured potential difference changes with the frequency of the applied current. The frequency range I am considering is typically from about 10 kHz up to 100 kHz, but I am also exploring much lower frequencies, down to around 100 Hz. If you could kindly point me to relevant references or scientific literature that discuss similar applications or provide guidance on which dielectric properties are most suitable in this frequency range, it would be extremely helpful. Thank you again for your support.
  • 0 Votes
    1 Posts
    353 Views
    No one has replied
  • 0 Votes
    4 Posts
    1k Views
    brynB
    preview (still working on the distance from e.g. F7 to F9) [image: 1757340222351-c2ee64b1-55df-41d6-9583-bd5832ceb962-image.png]
  • 0 Votes
    2 Posts
    729 Views
    brynB
    To get the bounding box of some tissues, say Large_intestine_lumen Large_intestine_wall and test if some points are inside these tissues you can use the GetEntityPointDistance API, e.g., something like this: import numpy as np import s4l_v1.model as s4l_model Vec3 = s4l_model.Vec3 def sample_box(p1: Vec3, p2: Vec3) -> list[Vec3]: xs = np.linspace(p1[0], p2[0], 10) ys = np.linspace(p1[1], p2[1], 10) zs = np.linspace(p1[2], p2[2], 10) X, Y, Z = np.meshgrid(xs, ys, zs, indexing="ij") points = np.vstack([X.ravel(), Y.ravel(), Z.ravel()]).T return [Vec3(p) for p in points] def find_entities(root_group: s4l_model.EntityGroup, names: list[str]): entities = s4l_model.CollectEntities([root_group]) entities = [e for e in entities if e.Name in names] return entities if __name__ == "__main__": model_group = s4l_model.AllEntities()["Thelonious_6y_m_v3.1b02_posable"] entities = find_entities(model_group, ["Large_intestine_lumen", "Large_intestine_wall"]) p1, p2 = s4l_model.GetBoundingBox(entities) points = sample_box(p1, p2) inside_gi_tract = np.zeros(len(points), dtype=np.uint8) for entity in entities: distance = s4l_model.GetEntityPointDistance(entity, points) for idx, dist in enumerate(distance): # note: negative distance means inside the closed surface if dist.Distance <= 0.0: inside_gi_tract[idx] = True
  • Current density to CSV

    Python API
    1
    0 Votes
    1 Posts
    554 Views
    No one has replied
  • 0 Votes
    2 Posts
    855 Views
    B
    If simulations are queued indefinitely, this could be an indication of a license issue. To run a simulation, the solver needs to 'check out' a license feature from the license server. When it completes, it marks that license feature as available again. Sometimes, if the application were to crash for some reason, the license feature is not correctly marked as available, preventing other simulations from proceeding because they think the feature isn't currently available to checkout. To resolve this, one thing to try would be to stop and restart license software, or to reinstall the license to ensure that all license features are reset.
  • 0 Votes
    2 Posts
    817 Views
    B
    After creating the voxels for a simulation, the input file can be created without submitting the simulation by right-clicking on 'Solver' in the simulation configuration and selecting 'Write Input File'.
  • 0 Votes
    2 Posts
    855 Views
    B
    The Thickness Factor defines the thickness of the Piezo element and the Reflector as a fraction of the acoustic wavelength (determined from frequency and Speed of Sound). By default, n=10, so the fraction is 1/10. This is a parameter which should help to nicely design the SEFT such that it gets correctly voxeled later on (so not too thin) but also doesn't cover too much space (not too thick). Theoretically, the reflector and the active element can be as thin as a single cell layer, but you don't know the computational cell size when drawing the model. Since the voxeler is set to have a max step size of lambda/10, due to stability considerations, the Piezo and reflector will always be nicely and continuously voxeled when using the default Thickness Factor of 1/10. You can find more information about the Acoustic Solver, including relevant equations, in a thesis titled "Multi-Physics Computational Modeling of Focused Ultrasound Therapies", upon which the Acoustic Solver in Sim4Life is based.
  • 0 Votes
    2 Posts
    879 Views
    AntoninoMCA
    Dear @lorenero_99, Thank you for contacting us! Please have a read to my recent comment to this post, where I tried to be very detail in explaining how the current flux normalization works and what are the limitations. https://forum.zmt.swiss/topic/733/normalization-for-precise-current-control-via-jupyter/5 For what concerns the impedance, if you use the Ohmic-Current Dominated solver, the Ohmic laws apply and you can extract the resistance (impedance) knowing the applied voltages at the electrodes and the current through them. If you need further explanations, please do not hesitate to contact us immediately! All the best, Antonino
  • Inquiry Regarding TI Simulation Setup in Sim4Life

    Python API
    2
    0 Votes
    2 Posts
    661 Views
    SylvainS
    Hi, I strongly recommend you have a look at the tutorial 3.2.12 called Temporal Interference with Complex Head Model. It should be of significant help for setting up a TI simulation correctly. As for your specific questions: yes, that's correct. You can actually get the full Python script that generates a given simulation from the GUI by right-clicking on the simulation in the Explorer tree and selecting "To Python". Very useful :) That will most likely not work. Instead, you should apply fixed voltage Dirichlet conditions (e.g. +/- 1V) and re-normalize your results at post-processing (see screenshot below) For most fields that you can see in the analysis, you can use the Imp/Export menu in the ribbon and find a format in which to export (e.g. Matlab, VTK, or even plain text). [image: 1756718002390-0c790cba-feab-4bf1-a1c2-c6c1b959649c-image.png] [image: 1756718129268-fdbe02f0-7b3a-4d2e-a68d-989752dd05a7-image.png]
  • 0 Votes
    6 Posts
    1k Views
    C
    Hi @AntoninoMC, I really appreciate this answer as it helped clear some things up for me. I understand the current extractor much better than I did before and I've realized why I may have been running into some issues. The method of using the analysis as a source also seems to be preferable. I am using the EMLF Electro Quasi-Static model for modelling transcutaneous spinal cord stim, for which precise control of the current is of absolute importance. The multiplier method seems to be the way to go for feeding into the NEURON simulation, as it means I don't have to rerun my EMLF sim. One thing I'm wondering, when I select the analysis/cache as a source, I lose the ability to use the contact impedance model in the NEURON setup. If I use a contact impedance model producer to modulate the resulting EM field from the multiplier, I lose the ability to set pulse parameters, which then seems to prevent NEURON from running a simulation. Do you know if there's a way to use the analysis connection with a multiplier AND a contact impedance model simultaneously for driving a NEURON simulation?
  • sim4life.lite Tutorial

    Sim4Life
    4
    1 Votes
    4 Posts
    1k Views
    SylvainS
    The guided tours within the tutorials are indeed not working as intended. Thanks for pointing this out! Instead, I would recommend following the instructions in the text documentation of the tutorials: https://manual.sim4life.io/manual/Tutorials/index.html Let me know if you run into issues with a specific tutorial!