CoperniFUS in interactive mode

For direct interaction with the data created and manipulated by CoperniFUS

Step 1. Install CoperniFUS

  1. Create a python environment to prevent package version conflicts. Although pyenv can be used, miniconda is recommanded.

    conda create -n coperniFUS_env python=3.12

  2. Make sure that your ipython notebook kernel runs in the coperniFUS_env environment.

  3. Install CoperniFUS

[ ]:
!pip install git+https://github.com/Tomaubier/CoperniFUS.git

Step 2. Launch CoperniFUS

(First launch after install might take some time)

Specify path where to search for assets.

Assets (such as .stl mesh files) loaded by armatures need to be located in a single directory. By default, data will be loaded from coperniFUS/examples/assets however this behaviour can be changed by providing an assets_dir_path argument.

[1]:
from coperniFUS.viewer import coperniFUSviewer
from coperniFUS import *

cfv = coperniFUSviewer() # Optional: Provide assets_dir_path='path/to/your/armature/assets'
Launching CoperniFUS v0.1.0

> Info: Like any text outputs, warnings and error messages will be outputed to the internal console, to change this behaviour, feel free to set disable_internal_console to True.

> Info: Referencing assets located in /Users/tomaubier/Documents/US_Neurostim/Analysis_scripts/CoperniFUS/coperniFUS/examples/assets directory.

> Info: Cached configuration file location: /Users/tomaubier/coperniFUSCache/Untitled Configuration.json

For the sake of this interactive demo, load the example configuration described in the tutorial.

[ ]:
cfv.load_example_configuration('Dual arms FUS + rec electrode rat tutorial config')
[3]:
# Modules objects can be grabbed using
cfv.get_module_object_from_name()

# Armatures objects can be grabbed using
stereotaxic_frame_handle = cfv.get_module_object_from_name('StereotaxicFrame')
stereotaxic_frame_handle.armatures_objects
[3]:
{'Bregma to Stereotaxic Frame Origin': <coperniFUS.modules.armatures.base_armature.Armature at 0x337cb74a0>,
 'Skull Mesh': <coperniFUS.modules.armatures.mesh_armatures.STLMeshArmature at 0x337cb7890>,
 'Brain Mesh': <coperniFUS.modules.armatures.mesh_armatures.STLMeshConvexHull at 0x337cb69c0>,
 'Coordinates Registration Probe Arm': <coperniFUS.modules.armatures.base_armature.Armature at 0x337ccb6e0>,
 'Coords Registration Probe Shaft': <coperniFUS.modules.armatures.base_armature.Armature at 0x337ccb620>,
 'Coords Registration Probe Tip': <coperniFUS.modules.armatures.base_armature.Armature at 0x337ccb5f0>,
 'FUS Transducer Arm': <coperniFUS.modules.armatures.base_armature.Armature at 0x337ccb590>,
 'FUS Transducer Shaft': <coperniFUS.modules.armatures.base_armature.Armature at 0x337ccb530>,
 'FUS Transducer Holder Mesh': <coperniFUS.modules.armatures.mesh_armatures.STLMeshArmature at 0x337ccb4d0>,
 'Theoretical FUS focal spot preview': <coperniFUS.modules.armatures.mesh_armatures.TrimeshScriptArmature at 0x337cca960>,
 'Stereotaxic Frame Rails Distance': <coperniFUS.modules.armatures.base_armature.Armature at 0x337cca930>,
 'Recording Electrode Arm': <coperniFUS.modules.armatures.base_armature.Armature at 0x337cca8a0>,
 'Electrode Electrode Shaft': <coperniFUS.modules.armatures.base_armature.Armature at 0x337cca840>,
 'Recording Electrode Body': <coperniFUS.modules.armatures.mesh_armatures.TrimeshScriptArmature at 0x337cca7b0>,
 'kWave 3D Simulation': <coperniFUS.modules.armatures.kwave_armatures.KWave3dSimulationArmature at 0x337cca720>}

Step 3. Running acoustic simulations

  1. Compute Brain Mesh (defined as the convex hull of the skull mesh)

  2. Compute the acoustic domain (apply boolean operation)

  3. Run the k-Wave 3D simulation

video_export_LUT_editor_screenshot.png

Step 4. Grab mesh & pressure simulation data

[4]:
acsim_armature = cfv.stereotaxic_frame.armatures_objects['kWave 3D Simulation']
acsim_armature
[4]:
<coperniFUS.modules.armatures.kwave_armatures.KWave3dSimulationArmature at 0x337cca720>
[5]:
acsim_armature.mesh_handler.stl_item_mesh[1].show()
[5]: