Пример #1
0
    def getStructureColor(self, structureName, rgb = False):
        """
        @param structureName: the name of the structure
        @type structureName: str

        @param rgb: True if requested colour format is 24-bit RGB (8 bits per
                    chanel), False otherwise.
        @type rgb: bool

        @return: the colour suitable for a model of requested structure
        @rtype: [int, int, int] | [float, float, float]
        """
        ct = HTMLColorToRGB(self.sh.ih.colorMapping[structureName])

        #TODO: Get rid of this after implementing automatic, hierarchy based
        # colour assignment.
        # Dummy patch: when colour is not provided (=structure has gray colour
        # defined) choose random one.
        if ct[0] == ct[1] == ct[2] == 119:
            random.seed(structureName)
            ct = map(lambda x: random.randint(0, 255), [0,0,0])

        if not rgb:
            ct = list(intColourToFloat(ct))

        return ct
Пример #2
0
    def getStructureColor(self, structureName, rgb=False):
        """
        @param structureName: the name of the structure
        @type structureName: str

        @param rgb: True if requested colour format is 24-bit RGB (8 bits per
                    chanel), False otherwise.
        @type rgb: bool

        @return: the colour suitable for a model of requested structure
        @rtype: [int, int, int] | [float, float, float]
        """
        ct = HTMLColorToRGB(self.sh.ih.colorMapping[structureName])

        #TODO: Get rid of this after implementing automatic, hierarchy based
        # colour assignment.
        # Dummy patch: when colour is not provided (=structure has gray colour
        # defined) choose random one.
        if ct[0] == ct[1] == ct[2] == 119:
            random.seed(structureName)
            ct = map(lambda x: random.randint(0, 255), [0, 0, 0])

        if not rgb:
            ct = list(intColourToFloat(ct))

        return ct
Пример #3
0
    def _basicSetup(self, vtkapp, options):
        """
        Constructor code common with derivative classes constructor.

        @param vtkapp: C{self.L{vtkapp}} value
        @type vtkapp: L{barReconstructionModule} object

        @param options: an object containing constructor options as its
                        attributes:
                          - C{cameraMovementAngles} - C{self.L{vtkapp}.L{cameraPosition<barReconstructionModule.cameraPosition>}}
                            and C{self.L{vtkapp}.L{cameraViewUp<barReconstructionModule.cameraViewUp>}}
                            values encoded as camera movement angles,
                          - C{parallel} - C{self.L{vtkapp}.L{parallelProjection<barReconstructionModule.parallelProjection>}} value,
                          - C{background} - C{self.L{vtkapp}.L{background<barReconstructionModule.background>}},
                          - C{voxelDimensions} - C{(self.L{xyres}, self.L{zres})} value,
                          - C{exportDir} - C{self.L{exportDir}} value,
                          - C{generateSubstructures} - C{self.L{depth}} value,
                          - C{format} - C{self.L{formats}} members list,
                          - C{show} - C{self.L{show}} value,
                          - C{brainoutline} - legacy option, indicates if the root
                                              structure of the hierarchy tree has
                                              to be appended to C{self.L{outline}},
                          - C{outline} - structures to be included in C{self.L{outline}},
                          - C{composite} - C{self.L{composite}} value; if True
                                           forces C{'exportToVTKPolydata' in self.L{formats}},
                          - C{ignoreBoundingBox} - C{self.L{ignoreBoundingBox}}.
                                                   Overrides bounding box
                                                   calculation - bounding box
                                                   will be always equal to
                                                   hierarchy root element bounding
                                                   box. Volumes for all structures
                                                   will always have the same size
                                                   and origin. This feature
                                                   increases memory usage and
                                                   reconstruction time.

        @type options: optparse.Values object
        """
        self.vtkapp = vtkapp

        # Process options
        self.vtkapp.background = intColourToFloat(options.background)
        self.cameraMovementAngles = options.cameraMovementAngles
        self.parallel = options.parallel

        if options.voxelDimensions != None:
            self.xyres, self.zres = options.voxelDimensions

        if options.exportDir != None:
            self.exportDir = options.exportDir

        if options.outline:
            # check whether every group requested as an outline exists
            self.outline = set(options.outline)
            invalidGroups = self.outline - set(self.sh.ih.groups)

            if len(invalidGroups) > 0:
                # if not - report it and try to fix
                for name in invalidGroups:
                    debugOutput("Structure %s not found." % name, error = True)

                self.outline -= validGroups

        else:
            self.outline = set()

        if options.brainoutline:
            self.outline.add(self.sh.ih.hierarchyRootElementName)

        self.depth = options.generateSubstructures

        self.formats = set()
        if options.format != None:
            self.formats = set(options.format)

        self.show = options.show
        self.composite = options.composite
        self.ignoreBoundingBox = options.ignoreBoundingBox

        #---------------------- done with options

        # Proceed with VTK setup
        # Create the RenderWindow and RenderWindowInteractor
        self.renWin = vtk.vtkRenderWindow()
        self.renWin.SetSize(800,600)
        self.vtkapp.addRenderWindow(self.renWin)

        self.iren = vtk.vtkRenderWindowInteractor()
        self.iren.SetRenderWindow(self.renWin)
        self.iren.Initialize()

        self._simpleQueue = []
        self._compositeQueue = []
Пример #4
0
    def _basicSetup(self, vtkapp, options):
        """
        Constructor code common with derivative classes constructor.

        @param vtkapp: C{self.L{vtkapp}} value
        @type vtkapp: L{barReconstructionModule} object

        @param options: an object containing constructor options as its
                        attributes:
                          - C{cameraMovementAngles} - C{self.L{vtkapp}.L{cameraPosition<barReconstructionModule.cameraPosition>}}
                            and C{self.L{vtkapp}.L{cameraViewUp<barReconstructionModule.cameraViewUp>}}
                            values encoded as camera movement angles,
                          - C{parallel} - C{self.L{vtkapp}.L{parallelProjection<barReconstructionModule.parallelProjection>}} value,
                          - C{background} - C{self.L{vtkapp}.L{background<barReconstructionModule.background>}},
                          - C{voxelDimensions} - C{(self.L{xyres}, self.L{zres})} value,
                          - C{exportDir} - C{self.L{exportDir}} value,
                          - C{generateSubstructures} - C{self.L{depth}} value,
                          - C{format} - C{self.L{formats}} members list,
                          - C{show} - C{self.L{show}} value,
                          - C{brainoutline} - legacy option, indicates if the root
                                              structure of the hierarchy tree has
                                              to be appended to C{self.L{outline}},
                          - C{outline} - structures to be included in C{self.L{outline}},
                          - C{composite} - C{self.L{composite}} value; if True
                                           forces C{'exportToVTKPolydata' in self.L{formats}},
                          - C{ignoreBoundingBox} - C{self.L{ignoreBoundingBox}}.
                                                   Overrides bounding box
                                                   calculation - bounding box
                                                   will be always equal to
                                                   hierarchy root element bounding
                                                   box. Volumes for all structures
                                                   will always have the same size
                                                   and origin. This feature
                                                   increases memory usage and
                                                   reconstruction time.

        @type options: optparse.Values object
        """
        self.vtkapp = vtkapp

        # Process options
        self.vtkapp.background = intColourToFloat(options.background)
        self.cameraMovementAngles = options.cameraMovementAngles
        self.parallel = options.parallel

        if options.voxelDimensions != None:
            self.xyres, self.zres = options.voxelDimensions

        if options.exportDir != None:
            self.exportDir = options.exportDir

        if options.outline:
            # check whether every group requested as an outline exists
            self.outline = set(options.outline)
            invalidGroups = self.outline - set(self.sh.ih.groups)

            if len(invalidGroups) > 0:
                # if not - report it and try to fix
                for name in invalidGroups:
                    debugOutput("Structure %s not found." % name, error=True)

                self.outline -= validGroups

        else:
            self.outline = set()

        if options.brainoutline:
            self.outline.add(self.sh.ih.hierarchyRootElementName)

        self.depth = options.generateSubstructures

        self.formats = set()
        if options.format != None:
            self.formats = set(options.format)

        self.show = options.show
        self.composite = options.composite
        self.ignoreBoundingBox = options.ignoreBoundingBox

        #---------------------- done with options

        # Proceed with VTK setup
        # Create the RenderWindow and RenderWindowInteractor
        self.renWin = vtk.vtkRenderWindow()
        self.renWin.SetSize(800, 600)
        self.vtkapp.addRenderWindow(self.renWin)

        self.iren = vtk.vtkRenderWindowInteractor()
        self.iren.SetRenderWindow(self.renWin)
        self.iren.Initialize()

        self._simpleQueue = []
        self._compositeQueue = []