def surface2Volume(vesselgroup): vessels = krebsutils.read_vesselgraph(vesselgroup, ['flags', 'radius', 'length']) flags = RemoveArteriovenousFlagsFromCapillaries(vessels['flags']) flags = flags[:,0] mask1 = myutils.bbitwise_and(flags, krebsutils.CIRCULATED) totalvol = totalLdVolume(vesselgroup) def compute(flagMask): if flagMask: mask = mask1 & myutils.bbitwise_and(flags, flagMask) else: mask = mask1 length = np.asarray(vessels['length'][mask], dtype = np.float64) radius = np.asarray(vessels['radius'][mask], dtype = np.float64) radius = radius[:,0] vol = math.pi * np.power(radius, 2.) * length surface = 2* math.pi* radius* length #surface = np.sum(surface) #vol = np.sum(vol) s2v = surface/vol mystd = np.std(s2v) myavg = np.average(s2v) myrel = mystd/myavg print("spread: %f" % myrel) return np.average(surface/vol) return compute(0), compute(krebsutils.ARTERY), compute(krebsutils.VEIN), compute(krebsutils.CAPILLARY)
def cylinderCollectionLineDensity(vesselgroup): vessels = krebsutils.read_vesselgraph(vesselgroup, ['flags', 'length']) flags = RemoveArteriovenousFlagsFromCapillaries(vessels['flags']) flags = flags[:,0] mask1 = myutils.bbitwise_and(flags, krebsutils.CIRCULATED) totalvol = totalLdVolume(vesselgroup) def compute(flagMask): if flagMask: mask = mask1 & myutils.bbitwise_and(flags, flagMask) else: mask = mask1 length = np.asarray(vessels['length'][mask], dtype = np.float64) total = np.sum(length) return total/totalvol return compute(0), compute(krebsutils.ARTERY), compute(krebsutils.VEIN), compute(krebsutils.CAPILLARY)