Skip to main content

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:

  1. 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
  1. 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.

  1. Install metastim package

from being in python virtual environment type

pip install metastim
  1. start python interactive shell
python3  
  1. 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

  1. donwload demo.ipynb and copy to ~/projects/metastim folder

  2. activate python virtual environment if it is not activated already

cd ~/projects/metastim

source venv/bin/activate
  1. Open vscode
code .
  1. 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

metastim-0.0.4.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metastim-0.0.4-py3-none-any.whl (2.0 MB view details)

Uploaded Python 3

File details

Details for the file metastim-0.0.4.tar.gz.

File metadata

  • Download URL: metastim-0.0.4.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

Hashes for metastim-0.0.4.tar.gz
Algorithm Hash digest
SHA256 fffe4911edbdc52568ebf692c9faa4dd5e6a4cd803b7f756172ad77d0788e695
MD5 5e7094e277bb9c65828821978c96d681
BLAKE2b-256 ef57e887a3f337b1adb7a4de21d00bea4241869db15fe0c7bf030b052313bd3f

See more details on using hashes here.

File details

Details for the file metastim-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: metastim-0.0.4-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

Hashes for metastim-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ef492673597df578ad5cb14c958780b7b230ec585207b4f7c5c675afde53d5d7
MD5 185ae302495b2e69e8654b67523f8f3a
BLAKE2b-256 058044a2441435e34bba34d11c9137bdd596a38607eb1500fa3ddd7da12d1935

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page