<jupyter_start><jupyter_text>Myelinated fiber model - assessment of responses to single-node sonication- SD curve myelinated for different frequencies at default diameter- SD curve myelinated for different diameters at default frequency- conclusion about influence of fiber diameter and US frequency and on excitability  Simulations Imports<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import logging
import pandas as pd
import os
import csv

from PySONIC.core import PulsedProtocol, AcousticDrive
from PySONIC.neurons import getPointNeuron
from PySONIC.utils import logger, si_format
from MorphoSONIC.core import SonicFiber, myelinatedFiberReilly, unmyelinatedFiberSundt, NodeAcousticSource, strengthDuration, SonicNode
from MorphoSONIC.plt import SectionCompTimeSeries, strengthDurationCurve
from MorphoSONIC.utils import chronaxie

#Folder used to store the strength duration data
outdir='strengthDurationData'
logger.setLevel(logging.WARNING)<jupyter_output><empty_output><jupyter_text>Single node acoustic (with node model)<jupyter_code># Stimulation parameters
toffset = 10e-3  # s
n_dur = 40
tstim_range = np.logspace(-5, 0, n_dur)  # s
freq = 500e3      #(Hz)
drive = AcousticDrive(f=freq)

Athr_dict = {}
# Myelinated fiber
#a = 32e-9         #(m)
node = SonicNode(getPointNeuron('FH'))
thr = np.zeros(n_dur)

# Loop through parameter sweep
for i, x in enumerate(tstim_range):
    pp = PulsedProtocol(x, toffset)
    thr[i] = node.titrate(drive, pp)   

Athr = np.absolute(thr) 
Athr_dict['Myelinated node'] = Athr
# Unmyelinated fiber
#a = 32e-9         #(m)
node = SonicNode(getPointNeuron('sundt'))
thr = np.zeros(n_dur)

# Loop through parameter sweep
for i, x in enumerate(tstim_range):
    pp = PulsedProtocol(x, toffset)
    thr[i] = node.titrate(drive, pp)   

Athr = np.absolute(thr) 
Athr_dict['Unmyelinated node'] = Athr
# Plot strength-duration curve
title = ' '
%matplotlib notebook
fig2 = strengthDurationCurve(
    title, tstim_range, Athr_dict,
    yname='threshold amplitude', yfactor=1e-3, yunit='Pa',
    scale='log', plot_chr=False)<jupyter_output><empty_output><jupyter_text>Single node acoustic stimulation of the fiber<jupyter_code># Stimulation parameters
fiberClass = 'acoustic_single_node'
toffset = 10e-3  # s
n_dur = 20
tstim_range = np.logspace(-5, 0, n_dur)  # s
freq = 500e3

Athr_dict = {}
logger.setLevel(logging.WARNING)

#Myelinated fiber
fiberType = 'reilly'
fiberD = 10e-6  #(m)
df = strengthDuration(fiberType, fiberClass, fiberD, tstim_range, toffset=toffset, outdir=outdir, Fdrive=freq)
Athr = np.absolute(df.values[:,1]) 
Athr_dict[f'freq={(freq*1e-3):.2f} kHz'] = Athr

#Unmyelinated fiber
fiberType = 'sundt'
fiberD = 10e-6  #(m)
df = strengthDuration(fiberType, fiberClass, fiberD, tstim_range, toffset=toffset, outdir=outdir, Fdrive=freq)
Athr = np.absolute(df.values[:,1]) 
Athr_dict[f'freq={(freq*1e-3):.2f} kHz'] = Athr

# Plot strength-duration curve
title = ' '
%matplotlib notebook
fig2 = strengthDurationCurve(
    title, tstim_range, Athr_dict,
    yname='threshold amplitude', yfactor=1e-3, yunit='Pa',
    scale='log', plot_chr=False, limits=[5e4, 1e6])<jupyter_output>senn_SONIC_FH_32nm_fs100%_500kHz_fiberD10.00um_tstim10.0us-1.0s_strengthduration_results.csv
senn_SONIC_sundt_32nm_fs100%_500kHz_fiberD10.00um_tstim10.0us-1.0s_strengthduration_results.csv<jupyter_text>The single node acoustic stimulation applied to the **myelinated fiber** gives the same strength-duration results obtained stimuling the myelinated node. The **unmyelinated fiber** instead behaves differently: we can obtained a clear SD curve stimuling the umyelinated node (curve similar to the ones obtained with the planar transducer stimulation), but the fiber cannot be excited by the single node acoustic stimulation.  SD curve varying the frequency<jupyter_code># Parameters fixed: fiber diameter 12.5 um, sonophore diameter 32 nm
# Frequency studied in the interval 100-1000 kHz
fiberType = 'reilly'
fiberD = 12.5e-6  #(m)
a = 32e-9         #(m)
freq_range = [20e3, 500e3, 1e6, 4e6]
logger.setLevel(logging.WARNING)
Athr_myel = {}

#Strength-duration results
for i, freq in enumerate(freq_range): 
    df = strengthDuration(fiberType, fiberClass, fiberD, tstim_range, toffset=toffset, outdir=outdir, Fdrive=freq, a=a)
    Athr = np.absolute(df.values[:,1]) 
    Athr_myel[f'freq={(freq*1e-3):.2f} kHz'] = Athr

# Plot strength-duration curve, zsource=5mm
title = 'SD curve Iextra myelinated fiber (z=5mm)'
%matplotlib notebook
fig2 = strengthDurationCurve(
    title, tstim_range, Athr_myel,
    yname='threshold amplitude', yfactor=1e-3, yunit='Pa',
    scale='log', plot_chr=False, limits=[5e4, 1e6])<jupyter_output><empty_output><jupyter_text>SD curve varying the diameter<jupyter_code># Parameters fixed: stimulation frequency 500 kHz, sonophore diameter 32 nm
# Fiber diameter studied in the interval 5-20 um
freq = 500e3      #(Hz)
a = 32e-9         #(m)
diam_range = np.linspace(5e-6, 20e-6, 3)
logger.setLevel(logging.WARNING)
Athr_myel = {}

#Strength-duration results
for i, fiberD in enumerate(diam_range): 
    df = strengthDuration(fiberType, fiberClass, fiberD, tstim_range, toffset=toffset, outdir=outdir, Fdrive=freq, a=a)
    Athr = np.absolute(df.values[:,1])      
    Athr_myel[f'd={(fiberD*1e6):.2f} um'] = Athr

# Plot strength-duration curve, zsource=5mm
title = 'SD curve Iextra myelinated fiber'
%matplotlib notebook
fig2 = strengthDurationCurve(
    title, tstim_range, Athr_myel,
    yname='threshold amplitude', yfactor=1e-3, yunit='Pa',
    scale='log', plot_chr=False, limits=[5e4, 1e6])<jupyter_output><empty_output><jupyter_text>SD curve varying the sonophore diameter<jupyter_code># Parameters fixed: stimulation frequency 500 kHz, fiber diameter 12.5 um
# Sonophore diameter studied in the interval   nm 
fiberD = 12.5e-6  #(m)
freq = 500e3      #(Hz)
a_range = [16e-9, 32e-9, 64e-9]
logger.setLevel(logging.WARNING)
Athr_myel = {}

#Strength-duration results
for i, a in enumerate(a_range): 
    df = strengthDuration(fiberType, fiberClass, fiberD, tstim_range, toffset=toffset, outdir=outdir, Fdrive=freq, a=a)
    Athr = np.absolute(df.values[:,1])      
    Athr_myel[f'a={(a*1e9):.2f} nm'] = Athr

# Plot strength-duration curve, zsource=5mm
title = 'SD curve Iextra myelinated fiber (z=5mm)'
%matplotlib notebook
fig2 = strengthDurationCurve(
    title, tstim_range, Athr_myel,
    yname='threshold amplitude', yfactor=1e-3, yunit='Pa',
    scale='log', plot_chr=False, limits=[5e4, 1e6])<jupyter_output><empty_output><jupyter_text>Simulations  Fiber model<jupyter_code>a = 32e-9                       # sonophore diameter (m)
Fdrive = 500e3                  # US frequency (Hz)
fs = 1                          # sonophore membrane coverage (-)
fiber = myelinatedFiberReilly(SonicFiber, 10e-6, a=a, Fdrive=Fdrive, fs=fs)<jupyter_output><empty_output><jupyter_text>Stimulation parameters<jupyter_code>pp = PulsedProtocol(3e-3, 3e-3)
psource = NodeAcousticSource(0, Fdrive)<jupyter_output><empty_output><jupyter_text>Simulation<jupyter_code>Athr = fiber.titrate(psource, pp)  # Pa
data, meta = fiber.simulate(psource, 1.5 * Athr, pp)
fig1 = SectionCompTimeSeries([(data, meta)], 'Qm', fiber.ids).render()
fig2 = SectionCompTimeSeries([(data, meta)], 'Vm', fiber.ids).render()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11279945242984257, 'fraction_numerical': 0.029842573579739903, 'mean_word_length': 5.442680776014109, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '420112', 'license': 'MIT', 'n_tokens_mistral': 2830, 'n_tokens_neox': 2617, 'n_words': 634, 'path': 'notebooks/fiber models - single node sonication.ipynb', 'repo_name': 'tjjlemaire/MorphoSONIC', 'size': '7305'}