Skip to content
  • Understand the h5 file structure

    Analysis & Postprocessing
    1
    0 Votes
    1 Posts
    16 Views
    No one has replied
  • 0 Votes
    4 Posts
    228 Views
    AntoninoMCA
    Dear @gotou, There is a fundamental misunderstanding here. The EM LF Electro Ohmic Quasi-Static solver, is frequency-independent. The complex part of the fundamental electro quasi-stati equation \nabla\cdot\tilde\epsilon\nabla\phi = 0 (see Sim4Life manual, "2.6.1.4 Choosing the Appropriate Low Frequency Solver") is not solved AT ALL, since it is assumed that you have chosen this solver after having evaluated that the condition $\sigma>>\omega \epsilon_r \epsilon_0$ is valid for all the tissues and materials in your simulation at the frequency of interest. How to quantify this condition is also explained in the manual. The frequency has not impact on your simulation at all when you choose this solver. If you are unsure whether the condition $$\sigma>>\omega \epsilon_r \epsilon_0$$ applies, then you should consider to use the QS solver (not Ohmic-Current dominated) solver that solves the full complex equation. This solver uses both the conductivity and the permittivity and is frequency dependent. Please read the manual before running any further simulation if you have not clear which limitations apply to each solver: this is very important to proceed further. However, as @bryn also pointed out, the problem is then to decide which dielectric properties should be used. I agree with his observation. If your application uses sufficiently small frequencies, i.e. up to several tents of kHz, we suggest that you use the Ohmic current dominated solver in combination with the LF-IT'IS tissue properties. If you want further help, you should mention the type of application (e.g. neurostimulation) and the frequencies of interest. We could suggest you further documentation and scientific literature.
  • 0 Votes
    4 Posts
    321 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
    368 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
    261 Views
    No one has replied
  • 0 Votes
    2 Posts
    388 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
    380 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
    398 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
    468 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
    308 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
    661 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
    641 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!
  • 0 Votes
    3 Posts
    722 Views
    I
    Hello, I have the same issue. Currently using Sim4Life 8.2.0.16876. I wonder if there is any new update on this. Many thanks, Ines
  • EM-LF Solver- Tutorials Not Running

    Simulations & Solvers
    5
    0 Votes
    5 Posts
    562 Views
    S
    OK, I will share it. Thanks
  • 0 Votes
    3 Posts
    396 Views
    D
    Thank you so much!
  • Simulation Combiner Channel Parameters

    Analysis & Postprocessing
    2
    0 Votes
    2 Posts
    517 Views
    C
    If I understand correctly, you would like to have one simulation with a total current of 2.47mA and another one with 1.98mA. Sim4Life EQS solvers use Dirichlet boundary conditions for the electrodes (fixed voltage) as they solve for electric potential and electrode surfaces are assumed to be equipotential, hence the flux should be able to vary to ensure an equipotential surface. Moreover, when you check “Treat as port” for the LF solvers, you should be able to see in the log that they run 1 simulation per port, by setting this port to 1V and all the rest to 0V. With only 2 electrodes, and assuming you have one anode and one cathode, I would suggest the following: Assign Dirichlet boundary conditions to the electrodes (one setting per electrode, for instance 0.5V and -0.5V). Run the simulation Extract the total current of the simulation (select the "Overall Field" and use the "Current Extractor" from the ribbon). Normalize your fields of interest by the scaling factor: desired current/total current. Visualize the output of your normalized field. I hope this helps!
  • 2 Votes
    2 Posts
    339 Views
    brynB
    Hi @Seifeldin_E I assume you’re referring to the second row, where the field is shown on the surface of the spinal cord and peripheral nerves. Here’s the simplest way to achieve this: In the Field Sensor, select Current Density. Add a Masking Filter: Set selection to None (deselect everything). Type Nerve in the search filter and activate all nerve structures. Search for the spinal cord and activate it as well. Add a Surface Viewer — this will extract the surface at the masked regions. How it works: The masking filter replaces all unselected field values with NaN (not-a-number). The surface viewer detects NaN values and extracts the surface surrounding the masked voxels. Alternative method (less robust): Drag a TriangleMesh entity (e.g., Spinal_cord) to the Analysis tab. Select Current Density and the spinal cord mesh (now in Analysis, apply the Model to Grid filter). Add the Interpolation filter. Add a Surface Viewer Be aware: if the field changes abruptly near the surface, this method may interpolate the field on the "wrong" side of the surface. That’s why the masking approach is usually more reliable and easier to use.
  • Extract EMLF Results via Jupyter

    Analysis & Postprocessing
    9
    0 Votes
    9 Posts
    818 Views
    brynB
    The RestoreCamera function has a second argument animate=True. Setting this to False should fix your issue. If you are using s4l_v1.renderer.SaveScreenCapture to save an image of the scene in your script, you might need to give the GUI a chance to refresh during script execution. On Windows, you can do this with win32gui.PumpWaitingMessages() I typically do something like this def refresh_gui() if sys.platform == "win32": import win32gui win32gui.PumpWaitingMessages() for config in all_configurations: # change the model, run a simulation, change camera settings, etc. do_something(config) refresh_gui() s4l_v1.renderer.SaveScreenCapture( width=1024, height=1024, multi_sample=True, transparent_background=True, output_folder="C\temp\screenshots" output_prefix=f"subcase_{config}" )
  • 0 Votes
    18 Posts
    1k Views
    brynB
    your code is still not using the FieldInterpolationFilter to interpolate the T1w image onto the same grid as the E-field. Note, the FieldDataTextExporter takes the output of the interpolator as input
  • 0 Votes
    9 Posts
    2k Views
    M
    Hi there, I hope you can help, and that my questions fits within this thread. I have simulated an overall field and I would like to export it to matlab. At first I can live with the UI way i.e. by the import/export menu, but later I'd like to script it too. Now selecting e.g. the E-field and clicking the Imp/Export menu gives me no options but Import. Can anyone show the workflow? And/Or can anyone post a snippet of python code that does the export? Does exporting require a certain license?