Exemple #1
0
	def mirror_actor_hemisphere(self, actors):
		"""
			Mirrors actors from one hemisphere to the next
		"""
		if not isinstance(actors, list):
			actors = [actors]

		for actor in actors:
			mirror_coord = self.get_region_CenterOfMass('root', unilateral=False)[2]
			actors_funcs.mirror_actor_at_point(actor, mirror_coord, axis='x')
Exemple #2
0
    def get_region_unilateral(self, region, hemisphere="both", color=None, alpha=None):
        """
        Regions meshes are loaded with both hemispheres' meshes by default.
        This function splits them in two.

        :param region: str, actors of brain region
        :param hemisphere: str, which hemisphere to return ['left', 'right' or 'both'] (Default value = "both")
        :param color: color of each side's mesh. (Default value = None)
        :param alpha: transparency of each side's mesh.  (Default value = None)

        """
        if color is None: color = ROOT_COLOR
        if alpha is None: alpha = ROOT_ALPHA
        bilateralmesh = self._get_structure_mesh(region, c=color, alpha=alpha)

        if bilateralmesh is None:
            print(f'Failed to get mesh for {region}, returning None')
            return None

        com = bilateralmesh.centerOfMass()   # this will always give a point that is on the midline
        cut = bilateralmesh.cutWithPlane(origin=com, normal=(0, 0, 1))

        right = bilateralmesh.cutWithPlane( origin=com, normal=(0, 0, 1))
        
        # left is the mirror right # WIP
        com = self.get_region_CenterOfMass('root', unilateral=False)[2]
        left = actors_funcs.mirror_actor_at_point(right.clone(), com, axis='x')

        if hemisphere == "both":
            return left, right
        elif hemisphere == "left": 
            return left 
        else:
            return right
        def _mirror_neuron(neuron, mcoord):
            """
			Actually takes care of mirroring a neuron

			:param neuron: neuron's meshes
			:param mcoord: coordinates of the point to use for the mirroring

			"""
            # This function does the actual mirroring
            for name, actor in neuron.items():
                # get mesh points coords and shift them to other hemisphere
                if isinstance(actor, (list, tuple, str)) or actor is None:
                    continue
                neuron[name] = mirror_actor_at_point(actor, mcoord, axis='x')
            return neuron