Beispiel #1
0
NeuroMorpho.Org ID : 		NMO_09365

'''

from netpyne.support import morphology
from netpyne import sim
from neuron import h
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
import platform
import neuron as nrn

#load cell as mycell
#def getmorph(self):
myCell = morphology.Cell()
morphology.load(filename=os.path.join(wdir, 'MN3_morphology.swc'), cell=myCell)

#plot loaded cell
fig = plt.figure()
ax = plt.axes(projection='3d')
morphology.shapeplot(h, ax, color='r')

#get the sections from the cell
secs = list(h.allsec())
secs_all = secs
soma = []
axon = []
dend = []

#get the sections fro soma, axon and dend
#def getset(self):
Beispiel #2
0
import matplotlib.pyplot as plt
from mpl_toolkits import mplot3d
import platform
import neuron as nrn
if platform.system() == 'Windows':
    nrn.load_mechanisms(os.path.join(wdir + 'Morph_practice', 'modfiles'))
    import sys
    sys.path.append('C:', 'nrn', 'lib', 'python')
    sys.path.append('D:', 'Okinawa', 'Python')
    sys.path.append(wdir + 'Morph_practice', 'modfiles')

#class TC_cell():

#load cell as mycell
myCell = morphology.Cell()
morphology.load(filename=os.path.join(wdir, 'SWC', 'AA_0266.swc'), cell=myCell)

#plot loaded cell
fig = plt.figure()
ax = plt.axes(projection='3d')
morphology.shapeplot(h, ax)

#get the sections from the cell
secs = list(h.allsec())
secs_all = secs
soma = []
axon = []
dend = []

#get the sections fro soma, axon and dend
for sec in secs:
Beispiel #3
0
import os
wdir = os.getcwd()

from netpyne.support import morphology
from netpyne import sim
from neuron import h
import matplotlib.pyplot as plt
import matplotlib.cm
from mpl_toolkits import mplot3d
import platform
import neuron as nrn

#load cell as mycell
#    def getmorph(self):
myCell_1 = morphology.Cell()
morphology.load(filename=os.path.join(wdir, 'MN1_morphology.swc'),
                cell=myCell_1)

cell1_secs = list(h.allsec())

lenght_1 = len(cell1_secs)

myCell_2 = morphology.Cell()
morphology.load(filename=os.path.join(wdir, 'MN2_morphology.swc'),
                cell=myCell_2)

cell2_secs = list(h.allsec())
del cell2_secs[0:lenght_1]

lenght_2 = len(cell2_secs)

myCell_3 = morphology.Cell()
Beispiel #4
0
def importCell(fileName, cellName, cellArgs = None, cellInstance = False):
    """
    Function for/to <short description of `netpyne.conversion.neuronPyHoc.importCell`>

    Parameters
    ----------
    fileName : <type>
        <Short description of fileName>
        **Default:** *required*

    cellName : <type>
        <Short description of cellName>
        **Default:** *required*

    cellArgs : <``None``?>
        <Short description of cellArgs>
        **Default:** ``None``
        **Options:** ``<option>`` <description of option>

    cellInstance : bool
        <Short description of cellInstance>
        **Default:** ``False``
        **Options:** ``<option>`` <description of option>

"""

    h.initnrn()

    varList = mechVarList()  # list of properties for all density mechanisms and point processes
    origGlob = getGlobals(list(varList['mechs'].keys())+list(varList['pointps'].keys()))
    origGlob['v_init'] = -65  # add by hand since won't be set unless load h.load_file('stdrun')

    if cellArgs is None: cellArgs = [] # Define as empty list if not otherwise defined

    if fileName.endswith('.hoc') or fileName.endswith('.tem'):
        h.load_file(fileName)
        if not cellInstance:
            if isinstance(cellArgs, dict):
                cell = getattr(h, cellName)(**cellArgs)  # create cell using template, passing dict with args
            else:
                cell = getattr(h, cellName)(*cellArgs) # create cell using template, passing list with args
        else:
            try:
                cell = getattr(h, cellName)
            except:
                cell = None
    elif fileName.endswith('.py'):
        filePath,fileNameOnly = os.path.split(fileName)  # split path from filename
        if filePath not in sys.path:  # add to path if not there (need to import module)
            sys.path.insert(0, filePath)
            removeFilePath = True
        else:
            removeFilePath = False
        moduleName = fileNameOnly.split('.py')[0]  # remove .py to obtain module name
        tempModule = importlib.import_module(moduleName)
        modulePointer = tempModule
        if isinstance(cellArgs, dict):
            cell = getattr(modulePointer, cellName)(**cellArgs) # create cell using template, passing dict with args
        else:
            cell = getattr(modulePointer, cellName)(*cellArgs)  # create cell using template, passing list with args
        if removeFilePath: sys.path.remove(filePath)
    elif fileName.endswith('.swc'):
        from netpyne.support.morphology import load
        cell = load(fileName)
    else:
        print("File name should end in '.hoc', '.py', or '.swc'")
        return

    secDic, secListDic, synMechs, globs = getCellParams(cell, varList, origGlob)

    if fileName.endswith('.py'):
        _delete_module(moduleName)
        _delete_module('tempModule')
        del modulePointer
    elif fileName.endswith('.hoc'):
        for sec in h.allsec():
            try:
                if h.cas()!=sec: sec.push()
                h.delete_section()
                h.pop_section()
            except:
                pass
    h.initnrn()

    setGlobals(origGlob)  # restore original globals

    return secDic, secListDic, synMechs, globs