Esempio n. 1
0
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
Esempio n. 2
0
def sphereCount(ID, biniter):
  #find center of mass
  tree = Display.getFront().getLayerSet().findById(ID)
  coords = Matrix(getNodeCoordinates(tree))
  center = Matrix( [[0,0,0]] )
  m=coords.getRowDimension()


  for i in range(0, m):
    center += Matrix([coords.getRow( i )])
  center /= float(m)

  #calculate all distances of all points to center of mass and put them in a list
  xdist=[]
  ydist=[]
  zdist=[]
  for i in range(0, m):
    xdiff=[]
    if coords.get(i,0) > center.get(0,0):
      xdiff = coords.get(i,0) - center.get(0,0)
    else:
      xdiff = center.get(0,0) - coords.get(i,0)
    xdist.append(xdiff)

  for i in range(0, m):
    ydiff=[]
    if coords.get(i,1) > center.get(0,1):
      ydiff = coords.get(i,1) - center.get(0,1)
    else:
      ydiff = center.get(0,1) - coords.get(i,1)
    ydist.append(ydiff)

  for i in range(0, m):
    zdiff=[]
    if coords.get(i,2) > center.get(0,2):
      zdiff = coords.get(i,2) - center.get(0,2)
    else:
      zdiff = center.get(0,2) - coords.get(i,2)
    zdist.append(zdiff)

  nodeDist=[]
  dist=[]
  for i in range(0, m):
    dist=sqrt(xdist[i]**2 + ydist[i]**2 + zdist[i]**2)
    nodeDist.append(dist)

  iterations=biniter
  Ri=0 #inner radius
  """
  The maximum distance can only be achieved in the xy-plane
  With "fixed" coordinates this will approx. be 35000nm
  To make the scholl-profiles comparable this length has to be used.
  """ 
  scholl=[]
  xaxis=[]
  counter=0
  length= int(35000 / biniter + 0.5)
  Ra=length #outer radius

  for i in range(0, biniter):
    for i in range(0, len(nodeDist)):
      if nodeDist[i] <= Ra and nodeDist[i] >= Ri:  
        counter += 1   
    scholl.append(counter)
    counter=0
    xaxis.append(Ri) # adapt THIS position in all other scripts! Otherwise 1 datapoint is missing!!
    Ri += length
    Ra += length
    
  return scholl, xaxis