Skip to content
  • Thermal, unable to write input files.

    Simulations & Solvers
    7
    0 Votes
    7 Posts
    2k Views
    R
    Thank you. Uploaded.
  • Access data directly

    Python API
    2
    0 Votes
    2 Posts
    975 Views
    H
    Hi, you can try something like the following to extract the reflection coefficient. You can always try to build extraction manually once and select "To python" by right-clicking on the end of the tree (i.e. the component you extract from your pipeline) import numpy import s4l_v1.analysis as analysis import s4l_v1.document as document import s4l_v1.model as model import s4l_v1.units as units from s4l_v1 import ReleaseVersion from s4l_v1 import Unit sim_name = "MRI Volume Coil Cleg = 29.5 pF" ###### define the sim name in this case this is a multiport FDTD simulation Adding a new EmMultiPortSimulationExtractor simulation = document.AllSimulations[sim_name] em_multi_port_simulation_extractor = simulation.Results() this is extracting a port inputs = [em_multi_port_simulation_extractor.Outputs["MRI Volume Coil Cleg = 29.5 pF - Endring source 1 (Birdcage 1)"]] em_port_simulation_extractor = analysis.extractors.EmPortSimulationExtractor(inputs=inputs) em_port_simulation_extractor.Name = "MRI Volume Coil Cleg = 29.5 pF - Endring source 1 (Birdcage 1)" em_port_simulation_extractor.UpdateAttributes() document.AllAlgorithms.Add(em_port_simulation_extractor) em_sensor_extractor = em_port_simulation_extractor["Endring source 1 (Birdcage 1)"] document.AllAlgorithms.Add(em_sensor_extractor) ref_coef_data = em_sensor_extractor.Outputs["Reflection Coefficient(f)"] ref_coef_data.Update() freqlist = ref_coef_data.Data.Axis ref_coef = refCoeff.Data.GetComponent(0) ref_coef_magnitude = np.sqrt(np.real(ref_coef)**2 + np.imag(ref_coef)**2) import matplotlib.pyplot as plt plt.plot(freqlist,ref_coef_magnitude)
  • MQS solver errors

    Simulations & Solvers
    2
    0 Votes
    2 Posts
    780 Views
    H
    sending you an email via support
  • Normal vector to a tissue surface

    Analysis & Postprocessing
    2
    0 Votes
    2 Posts
    952 Views
    H
    [image: 1736961843959-327c9ace-0099-4e59-b102-4a34c31e609c-sim4life_fxfwepw8sg.gif] to extract the inner normal vector to the cortical surface mask the field (set NaN outside GM) using the Mask Filter available under "Field Data Tools" in the top ribbion. add the Grey Matter Surface in the post-pro interpolate the (masked) field to the grey matter surface using the "Interpolator" which is active when the masked field and surface is selected. get the normal component via the NormalFieldEvaluator under the "Field Data Tools"
  • Evaluation of head segmentation quality

    Anatomical Models
    7
    0 Votes
    7 Posts
    2k Views
    G
    Okay, I will take those considerations into account. Thanks for the fast reply!
  • 0 Votes
    1 Posts
    474 Views
    No one has replied
  • How to suppress messages in the Python console?

    Python API
    2
    0 Votes
    2 Posts
    1k Views
    L
    As far as I'm aware it is not possible to suppress those messages. Maybe try writing your customized messages into a log file instead?
  • How to create voxels using a script?

    Python API
    2
    0 Votes
    2 Posts
    1k Views
    L
    Hi! In all the tutorial python scripts this is shown. Within the python scripter you can click on the folder icon and choose "Open Example Script". There you will find lots of python scripts, that show how this is done. Here a small excerpt from the script "tutorial_emlf_parallel_plate.py": sim = CreateSimulation() s4l_v1.document.AllSimulations.Add(sim) sim.UpdateGrid() sim.CreateVoxels(path) sim.RunSimulation(wait=True) I suggest always creating a simulation, and an analysis function, that is then called in the RunTutorial function. It's best to then also create a main: def RunTutorial( path ): import s4l_v1.document s4l_v1.document.New() CreateModel() sim = CreateSimulation() s4l_v1.document.AllSimulations.Add(sim) sim.UpdateGrid() sim.CreateVoxels(path) sim.RunSimulation(wait=True) AnalyzeSimulation(sim) def main(data_path=None, project_dir=None): """ data_path = path to a folder that contains data for this simulation (e.g. model files) project_dir = path to a folder where this project and its results will be saved """ import sys import os print("Python ", sys.version) print("Running in ", os.getcwd(), "@", os.environ['COMPUTERNAME']) if project_dir is None: project_dir = os.path.expanduser(os.path.join('~', 'Documents', 's4l_python_tutorials') ) if not os.path.exists(project_dir): os.makedirs(project_dir) fname = os.path.splitext(os.path.basename(_CFILE))[0] + '.smash' project_path = os.path.join(project_dir, fname) RunTutorial( project_path ) if __name__ == '__main__': main()
  • import element inside a group using python

    Python API
    5
    0 Votes
    5 Posts
    2k Views
    M
    Thank you, I could obtain the same also using this: analysis.exporters.MatlabExporter.ExportTo(matlab_exporter,matlab_exporter.FileName) Do you think it is a good solution as well?
  • How to get inhomogeneous B0 maps

    Unsolved Simulations & Solvers
    1
    0 Votes
    1 Posts
    301 Views
    No one has replied
  • python script to run in the cloud

    Python API
    1
    0 Votes
    1 Posts
    431 Views
    No one has replied
  • 1 Votes
    30 Posts
    35k Views
    L
    @bryn Is the 6.8 displayed on the color bar the actual maximum field strength value? I exported the values and found that the maximum is around 5.9 instead. [image: 1735124755536-42fb974e-d830-42c2-8373-84c85ee63339-image.png]
  • How do we put electrodes on the skin surface?

    Analysis & Postprocessing
    16
    0 Votes
    16 Posts
    5k Views
    G
    @bryn @gc00 @halder Thank you so much, You've been very helpful !
  • 0 Votes
    1 Posts
    689 Views
    No one has replied
  • Is it possible to use Python API without opening Sim4Life?

    Python API
    4
    0 Votes
    4 Posts
    2k Views
    brynB
    You can open a smash file using import s4l_v1 as s4l s4l.document.Open(smash_file_path) You can save it using s4l.document.Save(smash_file_path) You can find a simulation using (assuming you have unique simulation names sim = [sim for sim in s4l.document.AllSimulations if sim.Name == "the name of your simulation"][0] If you want to load different models (from .sab file or .smash), but don't need to load e.g. simulations (in .smash file), you can import the file entities = s4l.model.Import(file_path) if you need to reset the document or model because you are accumulating too many entities and memory use is getting too high, you can use e.g. # reset the model sl4.model.Clear() # or keep entities, but discard model history import XCoreModeling as xcm xcm.GetActiveModel().ClearHistory() # or reset entire document (reset model, simulations, analysis) s4l.document.New()
  • Head tissue segmentation

    Anatomical Models
    1
    0 Votes
    1 Posts
    517 Views
    No one has replied
  • Brain atlas

    Anatomical Models
    1
    0 Votes
    1 Posts
    494 Views
    No one has replied
  • Location of Simulation Outputs and Voxel Coordinates?

    Python API
    1
    0 Votes
    1 Posts
    308 Views
    No one has replied
  • Export large files to matlab

    Analysis & Postprocessing
    3
    0 Votes
    3 Posts
    2k Views
    L
    @ofli Can the conductivity map after head segmentation be exported?
  • About TI Simulation

    Python API
    4
    0 Votes
    4 Posts
    1k Views
    L
    I want to see the impact of different grid sizes on the simulation, so I cloned a pair of simulations and modified the maximum step size of the grid. However, I found that if I create a new pair of simulations using the same settings, the grid sizes, simulation durations, and results of the new simulations and the cloned simulations are all different. Why does this happen?