Skip to content

Commit

Permalink
Added celsius parameter to cell class, and updated example2.py accord…
Browse files Browse the repository at this point in the history
…ingly.
  • Loading branch information
torbjone committed May 20, 2016
1 parent fad2bf2 commit 6aaaacb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
17 changes: 11 additions & 6 deletions LFPy/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Cell(object):
custom_fun: [None]: list of model-specific functions with args
custom_fun_args: [None]: list of args passed to custom_fun functions
pt3d: True/[False]: use pt3d-info of the cell geometries switch
celsius: [None]: Temperature in celsius. If nothing is specified here or in custom code it is 6.3 C
verbose: True/[False]: verbose output switch
Usage of cell class:
Expand Down Expand Up @@ -98,6 +99,7 @@ def __init__(self, morphology,
custom_fun=None,
custom_fun_args=None,
pt3d=False,
celsius=None,
verbose=False):
'''
Initialization of the Cell object.
Expand Down Expand Up @@ -196,7 +198,7 @@ def __init__(self, morphology,
self._set_nsegs(nsegs_method, lambda_f, d_lambda, max_nsegs_length)
self.totnsegs = self._calc_totnsegs()
if self.verbose:
print(("Total number of segments: %i" % self.totnsegs))
print("Total number of segments: %i" % self.totnsegs)

#extract pt3d info from NEURON, and set these with the same rotation
#and position in space as in our simulations, assuming RH rule, which
Expand All @@ -213,8 +215,11 @@ def __init__(self, morphology,
print('no soma, using the midpoint if initial segment.')
self.set_rotation(**self.default_rotation)



if celsius is not None:
if neuron.h.celsius != 6.3:
print("Overwriting custom temperature of %1.2f. New temperature is %1.2f"
% (neuron.h.celsius, celsius))
neuron.h.celsius = celsius


def _load_geometry(self):
Expand All @@ -234,14 +239,14 @@ def _load_geometry(self):
Import = neuron.h.Import3d_Neurolucida3()
if not self.verbose:
Import.quiet = 1
elif fileEnding == 'swc' or fileEnding == 'SWC':
elif fileEnding == 'swc' or fileEnding == 'SWC':
Import = neuron.h.Import3d_SWC_read()
elif fileEnding == 'xml' or fileEnding == 'XML':
elif fileEnding == 'xml' or fileEnding == 'XML':
Import = neuron.h.Import3d_MorphML()
else:
raise ValueError('%s is not a recognised morphology file format!'
).with_traceback(
'Should be either .hoc, .asc, .swc, .xml!' %self.morphology)
'Should be either .hoc, .asc, .swc, .xml!' % self.morphology)

#assuming now that morphologies file is the correct format
try:
Expand Down
5 changes: 3 additions & 2 deletions examples/example2.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'tstartms' : -159,
'tstopms' : 10,
'v_init' : -60,
'celsius': 34,
'pt3d' : True,
}

Expand Down Expand Up @@ -89,7 +90,7 @@
#Override passive reversal potential, AP is generated
for sec in cell.allseclist:
for seg in sec:
seg.e_pas = -59.7
seg.e_pas = -59.5

##perform NEURON simulation, results saved as attributes in the cell instance
cell.simulate(electrode=electrode)
Expand Down Expand Up @@ -167,7 +168,7 @@ def plotstuff(cell, electrode):

#plot extracellular spike in detail
ind = np.where(electrode.LFP == electrode.LFP.min())[0][0]
timeind = (cell.tvec >= 0) & (cell.tvec <= 4)
timeind = (cell.tvec >= 0) & (cell.tvec <= 10)
xticks = np.arange(10)
xticklabels = xticks
LFPtrace = electrode.LFP[ind, ]
Expand Down

0 comments on commit 6aaaacb

Please sign in to comment.