コード例 #1
0
    def export_single_node(self, treenode):
        """ Exports a treenode and expects the output path to be existing
        and writable.
        """
        # Calculate bounding box for current connector
        x_min = treenode.location_x - self.job.x_radius
        x_max = treenode.location_x + self.job.x_radius
        y_min = treenode.location_y - self.job.y_radius
        y_max = treenode.location_y + self.job.y_radius
        z_min = treenode.location_z - self.job.z_radius
        z_max = treenode.location_z + self.job.z_radius
        rotation_cw = 0
        zoom_level = 0

        # Create a single file for each section (instead of a mulipage TIFF)
        crop_self = CropJob(self.job.user,
                            self.job.project_id,
                            self.job.stack_id,
                            x_min,
                            x_max,
                            y_min,
                            y_max,
                            z_min,
                            z_max,
                            rotation_cw,
                            zoom_level,
                            single_channel=True)
        cropped_stack = extract_substack(crop_self)
        # Save each file in output path
        output_path = self.create_path(treenode)
        for i, img in enumerate(cropped_stack):
            # Save image in output path, named <treenode-id>.tiff
            image_name = "%s.tiff" % treenode.id
            treenode_image_path = os.path.join(output_path, image_name)
            img.write(treenode_image_path)
コード例 #2
0
    def export_single_node(self, connector_link):
        """ Exports a single connector and expects the output path to be existing
        and writable.
        """
        connector = connector_link.connector

        # Calculate bounding box for current connector
        x_min = connector.location_x - self.job.x_radius
        x_max = connector.location_x + self.job.x_radius
        y_min = connector.location_y - self.job.y_radius
        y_max = connector.location_y + self.job.y_radius
        z_min = connector.location_z - self.job.z_radius
        z_max = connector.location_z + self.job.z_radius
        rotation_cw = 0
        zoom_level = 0

        # Create a single file for each section (instead of a mulipage TIFF)
        crop_self = CropJob(self.job.user, self.job.project_id,
                self.job.stack_id, x_min, x_max, y_min, y_max, z_min, z_max,
                rotation_cw, zoom_level, single_channel=True)
        cropped_stack = extract_substack(crop_self)
        # Save each file in output path
        connector_path = self.create_path(connector_link)
        for i, img in enumerate(cropped_stack):
            # Save image in output path, named after the image center's coordinates,
            # rounded to full integers.
            x = int(connector.location_x + 0.5)
            y = int(connector.location_y + 0.5)
            z = int(z_min + i * crop_self.stacks[0].resolution.z  + 0.5)
            image_name = "%s_%s_%s.tiff" % (x, y, z)
            connector_image_path = os.path.join(connector_path, image_name)
            img.write(connector_image_path)