MetaStim: python package for DBS, enables to experimentation for various input parameters for DBS
Project description
MetaStim DBS in Python
How to use metastim python package
Install Instructions:
- create python3 virtual environment ( python version required 3.8 or higher)
mkdir -p ~/project/metastim # or any directory of your choice
cd project/metastim
python3 -m venv venv
- Activate the virtual environment
source venv/bin/activate
if above command is scuccess your terminal prompt will change to denote that you are in python virtual environment.
- Install metastim package
from being in python virtual environment type
pip install metastim
- start python interactive shell
python3
- Test if you can import metastim modules
try to import metastim modules filed_ann and axon_ann as shown below if you do not see any errors , you successfully installed metastim package
>>> from metastim import field_ann, axon_ann
How to Use MetaStim
Sample demo code is provided below, it shows usage of metastim copy this code into let say demo.py in ~/project/metastim folder and run within virtual environment created above
or
alternatively you can download demo.py avialable in this repositoty and run it in the virtual environment created above
python3 demo.py
Here is the complete code.
from metastim import field_ann, axon_ann
from metastim.utils import MetaStimUtil
from metastim import visualization as vis
import os
import numpy as np
if __name__ == "__main__":
lead_id = '6172'
electrode_list = [1, 0, 0, 0, -1, 0, 0, 0]
stimulation_amp = 3 # [V]
pulse_width = 90 #[us]
num_axons = 10
min_distance = 1
max_distance = 5
axon_diameter = 6 # [um]
lead_radius = MetaStimUtil.get_lead_radius(lead_id, electrode_list)
inl = 100 * axon_diameter / 1e3 # distance between nodes on an axon
z_base = np.arange(-5, 16, inl)
num_axon_nodes = z_base.shape[0]
x_axon = np.repeat(np.linspace(min_distance, max_distance, num=num_axons), num_axon_nodes).reshape(num_axon_nodes, num_axons, order='F') + lead_radius
y_axon = np.zeros(x_axon.shape)
z_axon = np.repeat(z_base, num_axons).reshape(num_axon_nodes, num_axons)
axon_ann_model = axon_ann.AxonANN(electrode_list, pulse_width, stimulation_amp, num_axons, axon_diameter)
field_ann_model = field_ann.FieldANN(electrode_list)
phi_axon = field_ann_model.field_ann(x_axon, y_axon, z_axon)
axon_act = axon_ann_model.axon_ann(x_axon, y_axon, z_axon, lead_radius)
visual_demo1 = vis.Visualization(lead_id, stimulation_amp, num_axons, x_axon, z_axon, phi_axon, axon_act)
visual_demo1.visualize1(electrode_list)
Sample Jupitor Notebook example
A Sample Jupitor note book file is aviable in this repository at demo.ipynb
-
donwload demo.ipynb and copy to ~/projects/metastim folder
-
activate python virtual environment if it is not activated already
cd ~/projects/metastim
source venv/bin/activate
- Open vscode
code .
- Run demo.ipynb jupitor notebook file
After vscode opens, open demo.ipynb file and click "Run All" button vscode suggests to install ipython server if ipython is not already installed install ipython by repsonding to vscode prompt.
If ipython server already present in vscode then vscode ask to select environment , select the virtual env
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file metastim-0.0.5.tar.gz.
File metadata
- Download URL: metastim-0.0.5.tar.gz
- Upload date:
- Size: 2.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93e8a6326acbe34508f6dfa224f781caafd9d18ee298706bf6f9009ee3107baf
|
|
| MD5 |
6674e92e9d4f5b1c4534f0bb21f8cb50
|
|
| BLAKE2b-256 |
81fa8cd01b8873d43c14235a450991d06203c090adc8e5fb1f60b10f80b4ec98
|
File details
Details for the file metastim-0.0.5-py3-none-any.whl.
File metadata
- Download URL: metastim-0.0.5-py3-none-any.whl
- Upload date:
- Size: 2.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1ecb9b9da170072b8b80ca4f700d8192e033e82d28bd68da8fb74dd94a152c9
|
|
| MD5 |
85f320852d69c5d96c25d753c692e27a
|
|
| BLAKE2b-256 |
560df50aae7439c8da440093f77ce3fbdc88dd52b3810b459676ac57351edcbc
|