示例#1
0
from GJEMS.morph.morph import BasicMorph
import sys
import numpy as np

assert len(
    sys.argv
) == 2, 'Only one argument, the path of the swcfile expected, ' + str(
    len(sys.argv)) + 'found'
swcfName = sys.argv[1]

testMorph = BasicMorph(swcfName)
azSecPtrs = testMorph.getActiveZoneSectionPtrs()
azSecPts, azDiam = testMorph.getActiveZonePoints(azSecPtrs)
toSave = np.zeros([np.shape(azSecPts)[0], 4])
toSave[:, :3] = azSecPts
toSave[:, 3] = azDiam
np.savetxt(swcfName.rstrip('.swc') + '.AZData', toSave, '%0.3f')
示例#2
0
from GJEMS.morph.morph import BasicMorph, plotPoints3D, addPoints3D
import matplotlib.pyplot as plt
from easygui import fileopenbox

testMorphFile = fileopenbox(msg='SWC file with three point soma',
                            filetypes=['*.swc'])
#testMorphFile = 'swcFiles/HB060602_3ptSoma.swc'
testMorph = BasicMorph(morphFile=testMorphFile)
azSecPtrs = testMorph.getActiveZoneSectionPtrs()
azSecPts, azDiam = testMorph.getActiveZonePoints(azSecPtrs)
azPointsInPlane, azPoints2D, evecs, svals = testMorph.project2plane(azSecPts)
fig = plt.figure()
plt.show(block=False)

ax = plotPoints3D(fig, azSecPts)
addPoints3D(ax, azPointsInPlane)
示例#3
0
文件: getAZ3D.py 项目: asobolev/GJEMS
import sys
import json

from GJEMS.morph.morph import BasicMorph


assert len(sys.argv) == 2, 'Only one argument, the path of the swcfile expected, ' + str(len(sys.argv)) + 'found'
swcfName = sys.argv[1]
testMorph = BasicMorph(swcfName)
azSecPtrs = testMorph.getActiveZoneSectionPtrs()
azSecPts, azDiam = testMorph.getActiveZonePoints(azSecPtrs)
print 'startJSON' + json.dumps(azSecPts.tolist())
示例#4
0
import shutil

assert len(sys.argv) == 2, 'Only one argument, the path of the swcfile expected, ' + str(len(sys.argv)) + 'found'
swcfName = sys.argv[1]

headr = ''
with open(swcfName, 'r') as fle:
    lne = fle.readline()
    while lne[0] == '#':
        headr = headr + lne[1:]
        lne = fle.readline()


headr = headr.rstrip('\n')

testMorph = BasicMorph(swcfName)
swcData = np.loadtxt(swcfName)

swcPts = swcData[:, 2:5]
# rotMatPCA = testMorph.getPCARotMatrix(swcPts)
# swcPts -= np.mean(swcPts, axis=0)
# swcData[:, 2:5] = rotatePts3D(swcPts, rotMatPCA)
standFunc = testMorph.getStdFunctionPCA()
swcData[:, 2:5] = standFunc(swcData[:, 2:5])

# evecs, evals, v = np.linalg.svd(swcData[:, 2:5].T, full_matrices=False)
#
# smallRot = getRotMatWithStartTargetVector(evecs[:, 0], [0, 1, 0])
#
# swcData[:, 2:5] = rotatePts3D(swcData[:, 2:5], smallRot)
示例#5
0
from GJEMS.morph.morphImport import SubTreeWriter
from GJEMS.morph.morph import BasicMorph
import sys
import os

assert len(
    sys.argv
) == 2, 'Only one argument, the path of the swcfile expected, ' + str(
    len(sys.argv)) + 'found'
testMorphFile = os.path.abspath(sys.argv[1])


def extraColFunc(secPtr):

    if secPtr.nchild():
        return [0]

    else:
        return [4 + secPtr.sec.nseg]


sswcFName = testMorphFile[:-4] + '_TipColoured.sswc'

NRN = BasicMorph(testMorphFile)
wri = SubTreeWriter(NRN.rootPtr, extraColFunc)
wri.write(sswcFName)
示例#6
0
assert len(
    sys.argv
) == 2, 'Only one argument, the path of the swcfile expected, ' + str(
    len(sys.argv)) + 'found'
swcfName = sys.argv[1]

headr = ''
with open(swcfName, 'r') as fle:
    lne = fle.readline()
    while lne[0] == '#':
        headr = headr + lne[1:]
        lne = fle.readline()

headr = headr.rstrip('\n')

testMorph = BasicMorph(swcfName)
swcData = np.loadtxt(swcfName)

swcPts = swcData[:, 2:5]
# rotMatPCA = testMorph.getPCARotMatrix(swcPts)
# swcPts -= np.mean(swcPts, axis=0)
# swcData[:, 2:5] = rotatePts3D(swcPts, rotMatPCA)
standFunc = testMorph.getStdFunctionUAlign()
swcData[:, 2:5] = standFunc(swcData[:, 2:5])

# evecs, evals, v = np.linalg.svd(swcData[:, 2:5].T, full_matrices=False)
#
# smallRot = getRotMatWithStartTargetVector(evecs[:, 0], [0, 1, 0])
#
# swcData[:, 2:5] = rotatePts3D(swcData[:, 2:5], smallRot)
示例#7
0
from GJEMS.morph.morph import BasicMorph, plotPoints3D, addPoints3D
import matplotlib.pyplot as plt
from easygui import fileopenbox

testMorphFile = fileopenbox(msg='SWC file with three point soma', filetypes=['*.swc'])
#testMorphFile = 'swcFiles/HB060602_3ptSoma.swc'
testMorph = BasicMorph(morphFile=testMorphFile)
azSecPtrs = testMorph.getActiveZoneSectionPtrs()
azSecPts, azDiam = testMorph.getActiveZonePoints(azSecPtrs)
azPointsInPlane, azPoints2D, evecs, svals = testMorph.project2plane(azSecPts)
fig = plt.figure()
plt.show(block=False)

ax = plotPoints3D(fig, azSecPts)
addPoints3D(ax, azPointsInPlane)
示例#8
0
import sys
import json


from GJEMS.morph.morph import BasicMorph


assert len(sys.argv) == 2, 'Only one argument, the path of the swcfile expected, ' + str(len(sys.argv)) + 'found'
swcfName = sys.argv[1]
testMorph = BasicMorph(swcfName)
print('startJSON' + json.dumps(testMorph.getTipUVOpenX()))
示例#9
0
assert len(
    sys.argv
) == 2, 'Only one argument, the path of the swcfile expected, ' + str(
    len(sys.argv)) + 'found'
swcfName = sys.argv[1]

headr = ''
with open(swcfName, 'r') as fle:
    lne = fle.readline()
    while lne[0] == '#':
        headr = headr + lne[1:]
        lne = fle.readline()

headr = headr.rstrip('\n')

testMorph = BasicMorph(swcfName)
swcData = np.loadtxt(swcfName)

swcPts = swcData[:, 2:5]
# rotMatPCA = testMorph.getPCARotMatrix(swcPts)
# swcPts -= np.mean(swcPts, axis=0)
# swcData[:, 2:5] = rotatePts3D(swcPts, rotMatPCA)
standFunc = testMorph.getStdFunctionPCA()
swcData[:, 2:5] = standFunc(swcData[:, 2:5])

# evecs, evals, v = np.linalg.svd(swcData[:, 2:5].T, full_matrices=False)
#
# smallRot = getRotMatWithStartTargetVector(evecs[:, 0], [0, 1, 0])
#
# swcData[:, 2:5] = rotatePts3D(swcData[:, 2:5], smallRot)
from GJEMS.morph.morph import BasicMorph, rotatePts2D
import matplotlib.pyplot as plt
# from easygui import fileopenbox
import sys

assert len(sys.argv) == 2, 'Only one argument, the path of the swcfile expected, ' + str(len(sys.argv)) + 'found'
testMorphFile = sys.argv[1]
# testMorphFile = fileopenbox(msg='SWC file with three point soma', filetypes=['*.swc'])
#testMorphFile = 'swcFiles/HB060602_3ptSoma.swc'



testMorph = BasicMorph(morphFile=testMorphFile)
azSecPtrs = testMorph.getActiveZoneSectionPtrs()
azSecPts, azDiam = testMorph.getActiveZonePoints(azSecPtrs)
azPointsInPlane, azPoints2D, evecs, svals = testMorph.project2plane(azSecPts)


# ax = testMorph.plotPoints3D(azSecPts, 'r-x')
# testMorph.addPoints3D(ax, azPointsInPlane, 'b-*')
# cols = ['r', 'b', 'g']
# mu = azSecPts.mean(axis=0)
# for evec, col in zip(evecs.T, cols):
#     vecPts = np.zeros([2, 3])
#     vecPts[0, :] = mu - 10 * evec / np.linalg.norm(evec)
#     vecPts[1, :] = mu + 10 * evec / np.linalg.norm(evec)
#     testMorph.addPoints3D(ax, vecPts, col + '-')

fig1 = plt.figure()
plt.show(block=False)
示例#11
0
import sys
import json

from GJEMS.morph.morph import BasicMorph

assert len(
    sys.argv
) == 2, 'Only one argument, the path of the swcfile expected, ' + str(
    len(sys.argv)) + 'found'
swcfName = sys.argv[1]
testMorph = BasicMorph(swcfName)
print('startJSON' + json.dumps(testMorph.getTipXYZ()))
示例#12
0
# from easygui import fileopenbox
import sys
from GJEMS.morph.morph import BasicMorph

assert len(
    sys.argv
) == 2, 'Only one argument, the path of the swcfile expected, ' + str(
    len(sys.argv)) + 'found'
swcFile = sys.argv[1]
# swcFile = fileopenbox(msg='SWC file with three point soma', filetypes=['*.swc'])
print 'Opening ', swcFile
testMorph = BasicMorph(swcFile)

#testMorph = BasicMorph('../swcFiles/HB130313-4NS_3ptSoma.swc')

from neuron import gui
示例#13
0
from neuronvisio.controls import Controls
import sys
from GJEMS.morph.morph import BasicMorph

assert len(
    sys.argv
) == 2, 'Only one argument, the path of the swcfile expected, ' + str(
    len(sys.argv)) + 'found'
swcfName = sys.argv[1]
testMorph = BasicMorph(swcfName)

#testMorph = BasicMorph('../swcFiles/HB130313-4NS_3ptSoma.swc')

contols = Controls()
示例#14
0
    'HB130313-4NS_3ptSoma_FSTD.swc',
    # 'HB130322-1NS_3ptSoma_FSTD.swc',
    # 'HB130408-1NS_3ptSoma_FSTD.swc',
    # 'HB130425-1NS_3ptSoma_FSTD.swc',
    # 'HB130501-2NS_3ptSoma_FSTD.swc'
]

foragerSWCFiles = [os.path.join(foragerSWCPath, x) for x in foragerSWCFNames]

# neSWCPath = 'swcFiles/GoodSamplesDLInt1_v2/newlyEmerged'
#
# neSWCFNames = [
#     'HB130523-3NS_3ptSoma_FSTD.swc',
#     'HB130605-1NS_3ptSoma_FSTD.swc',
#     'HB130605-2NS_3ptSoma_USTD.swc'
# ]

# neSWCFiles = [os.path.join(neSWCPath, x) for x in neSWCFNames]

swcFile = foragerSWCFiles[0]

# fig = plt.figure()
# plt.show(block=False)

NRN = BasicMorph(swcFile)

# NRN.initDistances()
tipNSegs = [x.sec.nseg for x in NRN.tipPtrs.values()]
hist, bins = np.histogram(tipNSegs, np.arange(10) + 0.5)
print hist / float(sum(hist)), bins
示例#15
0
from easygui import fileopenbox

import numpy as np

from GJEMS.morph.morph import BasicMorph, rotatePts3D, rotatePts2D, addPoints3D, plotPoints3D


defaultPath = '/home/ajay/PowerFolders/GinJangNDB_Upload/SigenSegmentations/Results/GoodSamplesDLInt1/forager/*.swc'
testMorphFile = fileopenbox(msg='SWC file with three point soma', default=defaultPath)
# testMorphFile = 'swcFiles/HB060602_3ptSoma.swc'



testMorph = BasicMorph(morphFile=testMorphFile)
swcData = np.loadtxt(testMorphFile)
swcXYZ = swcData[:, 2:5]
azSecPtrs = testMorph.getActiveZoneSectionPtrs()
azSecPts = testMorph.getActiveZonePoints(azSecPtrs)
stdFunc = testMorph.getStandardizationFunction()
swcSTD = stdFunc(swcXYZ)
ax = plotPoints3D(swcSTD, 'rx')




示例#16
0
import sys
import json


from GJEMS.morph.morph import BasicMorph


assert len(sys.argv) == 2, 'Only one argument, the path of the swcfile expected, ' + str(len(sys.argv)) + 'found'
swcfName = sys.argv[1]
testMorph = BasicMorph(swcfName)
print('startJSON' + json.dumps(testMorph.getTipXYZ()))