def profileDistances(ID, biniter): histo=getDendriticProfiles(ID, biniter) xhisto=histo[0] yhisto=histo[1] zhisto=histo[2] xdistance=[] ydistance=[] zdistance=[] tree = Display.getFront().getLayerSet().findById(ID) coords = Matrix(getNodeCoordinates(tree)) m=coords.getRowDimension() for i in range(0, m): xdist = coords.get(i, 1 ) if xdist > 0 : xdistance.append(xdist) else: xdistance.append((-1)*xdist) for i in range(0, m): ydist = coords.get(i, 0 ) if ydist > 0 : ydistance.append(ydist) else: ydistance.append((-1)*ydist) for i in range(0, m): zdist = sqrt(coords.get(i, 0)**2 + coords.get(i,1)**2) zdistance.append(zdist) return xdistance, ydistance, zdistance
from ini.trakem2.display import Display from jarray import array import sys sys.path.append("/Users/berthola/Desktop/Fiji Scripts") from matrixoperator import Matrix from javax.media.j3d import Transform3D from javax.vecmath import Point3d from ij.io import FileSaver from profilingFixedCoordinates import getDendriticProfiles from profilingFixedCoordinates import getNodeCoordinates #----------------PLOT histograms----------------------------------- ID=75408 tree = Display.getFront().getLayerSet().findById(ID) coords = Matrix(getNodeCoordinates(tree)) #Define axis vectors and origin xnorm = Matrix([[1,0,0]]) ynorm = Matrix([[0,1,0]]) znorm = Matrix([[0,0,1]]) center= Matrix([[0,0,0]]) #Project nodes onto axis dpx=[] dpy=[] dpz=[] m=coords.getRowDimension() for i in range(0, m): xstore = Matrix([coords.getRow( i )]) * xnorm.transpose() ystore = Matrix([coords.getRow( i )]) * ynorm.transpose()
def sumDist(id1, biniter): distance=profileDistances(id1, biniter) xdistance=distance[0] ydistance=distance[1] zdistance=distance[2] tree = Display.getFront().getLayerSet().findById(id1) coords = Matrix(getNodeCoordinates(tree)) m=coords.getRowDimension() xdist=[] ydist=[] zdist=[] #Initialize interval size and fix iterations to a specific coordinate position xbinleft = -34600.0 ybinleft = -24200.0 zbinleft = 0 #----------PARAMETER FOR MACHINE LEARNING----- iterations =biniter #--------------------------------------------- xlength = int((35600.0+34600.0)/iterations + 0.5) ylength = int((21300.0+24200.0)/iterations + 0.5) zlength = int((22500)/iterations + 0.5) xbinright = xbinleft + xlength ybinright = ybinleft + ylength zbinright = zbinleft + zlength sumdist=0.0 for i in range(0, iterations): for i in range(0, len(xdistance)): if xdistance[i] <= xbinright and xdistance[i] >= xbinleft: sumdist += xdistance[i] xdist.append(sumdist) sumdist=0.0 xbinleft += xlength xbinright += xlength for i in range(0, iterations): for i in range(0, len(ydistance)): if ydistance[i] <= ybinright and ydistance[i] >= ybinleft: sumdist += ydistance[i] ydist.append(sumdist) sumdist=0.0 ybinleft += ylength ybinright += ylength for i in range(0, iterations): for i in range(0, len(zdistance)): if zdistance[i] <= zbinright and zdistance[i] >= zbinleft: sumdist += zdistance[i] zdist.append(sumdist) sumdist=0.0 zbinleft += zlength zbinright += zlength sumdistance=[] sumdistance= [xdist, ydist, zdist] return sumdistance