-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3d cell set position #3
Comments
@alejoe91 Can you paste the code example as code? |
Sure! Sorry about it :) At the end of LFPy/examples/example1.py just add:
I have a working branch, I will try to send a pull request to LFPy/LFPy |
* square contact added * Cell.set_pos() fixed when cell has pt3d * cleaned _create_polygon * cell.py cleaned * recelec.py cleaned * Revert "recelec.py cleaned" This reverts commit e2bd431. * Revert "cell.py cleaned" This reverts commit 051c569. * cleaned * reinserted if-else, kept diffx, diffy, diffz * inserted somapos = (0,0,0) at beginning * removed extra print
This appear now to be fixed in PR #4 |
Bug in example cell model folder structure?
This fix introduced positioning errors when |
Closing issue, fixed by PR #17 |
in Cell.set_pos() the problem arises when pt3d = True:
--> when moving setting a cell multiple times to the same position, the 3d points keep drifting by the actual soma position
From LFPy/examples/example1
#!/usr/bin/env python
'''
Example plot for LFPy: Single-synapse contribution to the LFP
'''
import LFPy
import numpy as np
import os
import sys
if sys.version < '3':
from urllib2 import urlopen
else:
from urllib.request import urlopen
import zipfile
import matplotlib.pyplot as plt
from matplotlib.collections import PolyCollection
from os.path import join
plt.interactive(1)
plt.close('all')
#Fetch Mainen&Sejnowski 1996 model files
if not os.path.isfile(join('cells', 'cells', 'j4a.hoc')):
#get the model files:
u = urlopen('http://senselab.med.yale.edu/ModelDB/eavBinDown.asp?o=2488&a=23&mime=application/zip')
localFile = open('patdemo.zip', 'w')
localFile.write(u.read())
localFile.close()
#unzip:
myzip = zipfile.ZipFile('patdemo.zip', 'r')
myzip.extractall('.')
myzip.close()
################################################################################
Main script, set parameters and create cell, synapse and electrode objects
################################################################################
Define cell parameters
cell_parameters = { # various cell parameters,
'morphology' : join('cells', 'cells', 'j4a.hoc'), # Mainen&Sejnowski, 1996
'rm' : 30000., # membrane resistance
'cm' : 1.0, # membrane capacitance
'Ra' : 150, # axial resistance
'v_init' : -65., # initial crossmembrane potential
'e_pas' : -65., # reversal potential passive mechs
'passive' : True, # switch on passive mechs
'nsegs_method' : 'lambda_f',
'lambda_f' : 100.,
'timeres_NEURON' : 2.-3, # [ms] dt's should be in powers of 2 for both,
'timeres_python' : 2.-3, # need binary representation
'tstartms' : 0., # start time of simulation, recorders start at t=0
'tstopms' : 100., # stop simulation at 200 ms. These can be overridden
# by setting these arguments i cell.simulation()
'pt3d' : True
}
Create cell
cell = LFPy.Cell(**cell_parameters)
Align cell
cell.set_rotation(x=4.99, y=-4.33, z=3.14)
Define synapse parameters
synapse_parameters = {
'idx' : cell.get_closest_idx(x=-200., y=0., z=800.),
'e' : 0., # reversal potential
'syntype' : 'ExpSyn', # synapse type
'tau' : 5., # synaptic time constant
'weight' : .001, # synaptic weight
'record_current' : True, # record synapse current
}
Create synapse and set time of synaptic input
synapse = LFPy.Synapse(cell, **synapse_parameters)
synapse.set_spike_times(np.array([20.]))
Create a grid of measurement locations, in (mum)
X, Z = np.mgrid[-700:701:50, -400:1201:50]
Y = np.zeros(X.shape)
Define electrode parameters
grid_electrode_parameters = {
'sigma' : 0.3, # extracellular conductivity
'x' : X.flatten(), # electrode requires 1d vector of positions
'y' : Y.flatten(),
'z' : Z.flatten()
}
Define electrode parameters
point_electrode_parameters = {
'sigma' : 0.3, # extracellular conductivity
'x' : np.array([-130., -220.]),
'y' : np.array([ 0., 0.]),
'z' : np.array([ 0., 700.]),
}
Run simulation, electrode object argument in cell.simulate
print("running simulation...")
cell.simulate(rec_imem=True,rec_isyn=True)
Create electrode objects
grid_electrode = LFPy.RecExtElectrode(cell,**grid_electrode_parameters)
point_electrode = LFPy.RecExtElectrode(cell,**point_electrode_parameters)
Calculate LFPs
grid_electrode.calc_lfp()
point_electrode.calc_lfp()
print("done")
Issue (only when cell has pt3d = True)
print cell.somapos
print 'set soma position at: ', [50, 0, 0]
cell.set_pos(50, 0, 0)
print cell.somapos
print 'so far so good..'
print 'set soma position at: ', [50, 0, 0]
cell.set_pos(50, 0, 0)
print cell.somapos, ' drifting'
print 'set soma position at: ', [50, 0, 0]
cell.set_pos(50, 0, 0)
print cell.somapos, ' drifting'
The text was updated successfully, but these errors were encountered: