Beispiel #1
0
 def CalculateOrientations(self):
     if NoBacteria(): return
     
     ds = communityOrientationStats()
     
     for s in ds:
         self.ao(str(s))
Beispiel #2
0
def exportOrientations(path):
    from calc.stat import communityOrientationStats
    _, _, bdots, _, _ = communityOrientationStats()
    # move data into [0...1] range
    bdots = [map(abs, bdots[i]) for i in range(3)]
    # bdots is 3 x n with X,Y,Z for each bacillus in one column, we want them as one row
    data = np.array(bdots).T
    writeCSV(data, ['x','y','z'], path)
Beispiel #3
0
    def ColorByOrientation(self, colorScheme=None):
        if NoBacteria(): return
        
        bacilli, filaments, bdots, fdots, sRes = communityOrientationStats()
        bdots = [map(abs, bdots[i]) for i in range(3)]
        fdots = [map(abs, fdots[i]) for i in range(3)]
        
        if colorScheme is None:
            colorScheme = Vec3f(2,1,0)
        
        for i, a in enumerate(bacilli):
            aColl = vtk.vtkPropCollection()
            a.GetActors(aColl)
            aColl.InitTraversal()
            actors = [aColl.GetNextProp() for _ in range(aColl.GetNumberOfItems())]
            
            for actor in actors:
                actor.GetProperty().SetDiffuseColor(bdots[colorScheme.x][i], 
                                                    bdots[colorScheme.y][i], 
                                                    bdots[colorScheme.z][i])
        for j, fID in enumerate(filaments):
            fColl = vtk.vtkPropCollection()
            DataStore.BacteriaActors()[fID].GetActors(fColl)
            fColl.InitTraversal()
            factors = [fColl.GetNextProp() for _ in range(fColl.GetNumberOfItems())]
            
            # Set color LUT for filament spline based on marker positions
            colorTransferFunction = vtk.vtkColorTransferFunction()
            
            fdotIdx = sum(sRes[:j])
            for k in range(0, sRes[j]):
                colorTransferFunction.AddRGBPoint(k,fdots[colorScheme.x][fdotIdx+k],
                                                    fdots[colorScheme.y][fdotIdx+k],
                                                    fdots[colorScheme.z][fdotIdx+k])
#                print 'RGB:',fdots[colorScheme.x][fdotIdx+k],fdots[colorScheme.y][fdotIdx+k],fdots[colorScheme.z][fdotIdx+k]
            # filament spline
            factors[1].GetMapper().SetLookupTable(colorTransferFunction)
            factors[1].GetMapper().ScalarVisibilityOn()
            factors[1].GetMapper().SetColorModeToMapScalars()
            factors[1].GetMapper().InterpolateScalarsBeforeMappingOff()
            
            # sphere caps
            self.setColor(factors[0], fdotIdx, fdots, colorScheme)
            self.setColor(factors[-1], fdotIdx+k, fdots, colorScheme)
            

        self.iren.Render()