Skip to content

Commit

Permalink
fixing issue with init parameters axons + example of docstring for fa…
Browse files Browse the repository at this point in the history
…scicle attributes
  • Loading branch information
ThomasCouppey committed Nov 20, 2024
1 parent 2b7ee11 commit 2306867
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 43 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ All notable changes to NRV are sumed up in this file.
- progress bars are now handled with [rich.progress](https://rich.readthedocs.io/en/stable/progress.html)

### Fixed

- ``axon.__init__``'s ``kwargs``: all parameters can now be set at the instantiation of the axon


### Removed
Expand Down
8 changes: 7 additions & 1 deletion nrv/nmod/_axons.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ def __init__(
self.Nsec = 0
self.Nseg = 0
self.myelinated = ""
## stims

self.set_parameters(**kwargs)

## Contexts
# Intra stims
self.intra_current_stim = []
self.intra_current_stim_positions = []
self.intra_current_stim_starts = []
Expand All @@ -294,6 +298,8 @@ def __init__(
self.intra_voltage_stim = None
self.intra_voltage_stim_position = []
self.intra_voltage_stim_stimulus = None

# Extra stims
self.extra_stim = None
self.footprints = None
## recording mechanism
Expand Down
7 changes: 5 additions & 2 deletions nrv/nmod/_fascicles.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,11 @@ def __init__(self, diameter=None, ID=0, **kwargs):
super().__init__(**kwargs)

# to add to a fascicle/nerve common mother class
self.save_path = ""
self.verbose = False

#:str: path where the simulation results should be saved
self.save_path:str = ""
#:str: value: False: verbosity mainly for pbars. Tests more comment
self.verbose = False
self.return_parameters_only = False
self.loaded_footprints = False
self.save_results = False
Expand Down
71 changes: 32 additions & 39 deletions tests/unitary_tests/094_test_rec_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,38 @@
import matplotlib.pyplot as plt

if __name__ == "__main__":
gnafbar_mrg = 3.0 # S.cm-2
gnapbar_mrg = 0.01 # S.cm-2
gksbar_mrg = 0.08 # S.cm-2
gl_mrg = 0.007 # S.cm-2
cm=1 * 1e-6 # F

## Test1


y = 0
z = 0
d = 6
L = nrv.get_length_from_nodes(d, 15)

axon1 = nrv.myelinated(y,z,d,L,dt=0.001,rec='all')
#print(axon1.rec_position_list)
total = 0
for positions in axon1.rec_position_list:
total += len(positions)
#print(total)
print(total == len(axon1.x_rec))

t_start = 2
duration = 0.1
amplitude = 2
axon1.insert_I_Clamp_node(2, t_start, duration, amplitude)

t_sim=15
results = axon1.simulate(t_sim=t_sim, record_I_mem=True)
del axon1


plt.figure()
map = plt.pcolormesh(results['t'], results['x_rec'], results['V_mem'] ,shading='auto')
plt.xlabel('time (ms)')
plt.ylabel('position (µm)')
cbar = plt.colorbar(map)
cbar.set_label('membrane voltage (mV)')
plt.savefig('./unitary_tests/figures/94_A.png')

## Test1
y = 0
z = 0
d = 6
L = nrv.get_length_from_nodes(d, 15)

axon1 = nrv.myelinated(y,z,d,L,dt=0.001,rec='all')
#print(axon1.rec_position_list)
total = 0
for positions in axon1.rec_position_list:
total += len(positions)
#print(total)
print(total == len(axon1.x_rec))

t_start = 2
duration = 0.1
amplitude = 2
axon1.insert_I_Clamp_node(2, t_start, duration, amplitude)

t_sim=15
results = axon1.simulate(t_sim=t_sim, record_I_mem=True)
del axon1


plt.figure()
map = plt.pcolormesh(results['t'], results['x_rec'], results['V_mem'] ,shading='auto')
plt.xlabel('time (ms)')
plt.ylabel('position (µm)')
cbar = plt.colorbar(map)
cbar.set_label('membrane voltage (mV)')
plt.savefig('./unitary_tests/figures/94_A.png')



0 comments on commit 2306867

Please sign in to comment.