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')
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)
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())
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)
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)
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)
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()))
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)
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()))
# 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
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()
'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
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')
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()))