예제 #1
0
    def display(self, workspace, figure):
        '''Show an informative display'''
        import matplotlib
        import cellprofiler.gui.figure

        figure.set_subplots((2, 1))
        assert isinstance(figure, cellprofiler.gui.figure.Figure)

        i = workspace.display_data.i
        j = workspace.display_data.j
        angles = workspace.display_data.angle
        mask = workspace.display_data.mask
        labels = workspace.display_data.labels
        count = workspace.display_data.count

        color_image = np.zeros((mask.shape[0], mask.shape[1], 4))
        #
        # We do the coloring using alpha values to let the different
        # things we draw meld together.
        #
        # The binary mask is white.
        #
        color_image[mask, :] = MASK_ALPHA
        if count > 0:
            mappable = matplotlib.cm.ScalarMappable(
                cmap=matplotlib.cm.get_cmap(cpprefs.get_default_colormap()))
            np.random.seed(0)
            colors = mappable.to_rgba(np.random.permutation(np.arange(count)))

            #
            # The labels
            #
            color_image[labels > 0, :] += colors[labels[labels > 0] -
                                                 1, :] * LABEL_ALPHA
            #
            # Do each diamond individually (because the angles are almost certainly
            # different for each
            #
            lcolors = colors * .5 + .5  # Wash the colors out a little
            for ii in range(count):
                diamond = self.get_diamond(angles[ii])
                hshape = ((np.array(diamond.shape) - 1) / 2).astype(int)
                iii = i[ii]
                jjj = j[ii]
                color_image[iii - hshape[0]:iii + hshape[0] + 1,
                jjj - hshape[1]:jjj + hshape[1] + 1, :][diamond, :] += \
                    lcolors[ii, :] * WORM_ALPHA
        #
        # Do our own alpha-normalization
        #
        color_image[:, :, -1][color_image[:, :, -1] == 0] = 1
        color_image[:, :, :-1] = (color_image[:, :, :-1] /
                                  color_image[:, :, -1][:, :, np.newaxis])
        plot00 = figure.subplot_imshow_bw(0, 0, mask, self.image_name.value)
        figure.subplot_imshow_color(1,
                                    0,
                                    color_image[:, :, :-1],
                                    title=self.object_name.value,
                                    normalize=False,
                                    sharexy=plot00)
예제 #2
0
    def display(self, workspace, figure):
        '''Show an informative display'''
        import matplotlib
        import cellprofiler.gui.figure

        figure.set_subplots((2, 1))
        assert isinstance(figure, cellprofiler.gui.figure.Figure)

        i = workspace.display_data.i
        j = workspace.display_data.j
        angles = workspace.display_data.angle
        mask = workspace.display_data.mask
        labels = workspace.display_data.labels
        count = workspace.display_data.count

        color_image = np.zeros((mask.shape[0], mask.shape[1], 4))
        #
        # We do the coloring using alpha values to let the different
        # things we draw meld together.
        #
        # The binary mask is white.
        #
        color_image[mask, :] = MASK_ALPHA
        if count > 0:
            mappable = matplotlib.cm.ScalarMappable(
                    cmap=matplotlib.cm.get_cmap(cpprefs.get_default_colormap()))
            np.random.seed(0)
            colors = mappable.to_rgba(np.random.permutation(np.arange(count)))

            #
            # The labels
            #
            color_image[labels > 0, :] += colors[labels[labels > 0] - 1, :] * LABEL_ALPHA
            #
            # Do each diamond individually (because the angles are almost certainly
            # different for each
            #
            lcolors = colors * .5 + .5  # Wash the colors out a little
            for ii in range(count):
                diamond = self.get_diamond(angles[ii])
                hshape = ((np.array(diamond.shape) - 1) / 2).astype(int)
                iii = i[ii]
                jjj = j[ii]
                color_image[iii - hshape[0]:iii + hshape[0] + 1,
                jjj - hshape[1]:jjj + hshape[1] + 1, :][diamond, :] += \
                    lcolors[ii, :] * WORM_ALPHA
        #
        # Do our own alpha-normalization
        #
        color_image[:, :, -1][color_image[:, :, -1] == 0] = 1
        color_image[:, :, :-1] = (color_image[:, :, :-1] /
                                  color_image[:, :, -1][:, :, np.newaxis])
        plot00 = figure.subplot_imshow_bw(0, 0, mask, self.image_name.value)
        figure.subplot_imshow_color(1, 0, color_image[:, :, :-1],
                                    title=self.object_name.value,
                                    normalize=False,
                                    sharexy=plot00)
예제 #3
0
    def display(self, workspace, figure):
        dimensions = workspace.display_data.dimensions

        if self.blank_image.value:
            figure.set_subplots((1, 1), dimensions=dimensions)

            if self.wants_color.value == WANTS_COLOR:
                figure.subplot_imshow(
                    0,
                    0,
                    workspace.display_data.pixel_data,
                    self.output_image_name.value,
                    dimensions=dimensions
                )
            else:
                figure.subplot_imshow_bw(
                    0,
                    0,
                    workspace.display_data.pixel_data,
                    self.output_image_name.value,
                    dimensions=dimensions
                )
        else:
            figure.set_subplots((2, 1), dimensions=dimensions)

            figure.subplot_imshow_bw(
                0,
                0,
                workspace.display_data.image_pixel_data,
                self.image_name.value,
                dimensions=dimensions
            )

            if self.wants_color.value == WANTS_COLOR:
                figure.subplot_imshow(
                    1,
                    0,
                    workspace.display_data.pixel_data,
                    self.output_image_name.value,
                    dimensions=dimensions
                )
            else:
                figure.subplot_imshow_bw(
                    1,
                    0,
                    workspace.display_data.pixel_data,
                    self.output_image_name.value,
                    dimensions=dimensions
                )
 def display(self, workspace, figure):
     '''Show an informative display'''
     #import matplotlib
     import cellprofiler.gui.figure
     cplabels=[]
     figure.set_subplots((1, 1))
     assert isinstance(figure, cellprofiler.gui.figure.Figure)
     title = self.object_name.value
     cplabels.append(
         dict(name = self.object_name.value,
              labels = workspace.display_data.overlapping_labels,
              mode = CPLDM_ALPHA))
     mask = workspace.display_data.mask
     if mask.ndim == 2:
         figure.subplot_imshow_grayscale(
             0, 0, mask, title = title, cplabels = cplabels)
예제 #5
0
    def display(self, workspace, figure):
        dimensions = workspace.display_data.dimensions

        if self.blank_image.value:
            figure.set_subplots((1, 1), dimensions=dimensions)

            if self.wants_color.value == WANTS_COLOR:
                figure.subplot_imshow(0,
                                      0,
                                      workspace.display_data.pixel_data,
                                      self.output_image_name.value,
                                      dimensions=dimensions)
            else:
                figure.subplot_imshow_bw(0,
                                         0,
                                         workspace.display_data.pixel_data,
                                         self.output_image_name.value,
                                         dimensions=dimensions)
        else:
            figure.set_subplots((2, 1), dimensions=dimensions)

            figure.subplot_imshow_bw(0,
                                     0,
                                     workspace.display_data.image_pixel_data,
                                     self.output_image_name.value,
                                     dimensions=dimensions)

            if self.wants_color.value == WANTS_COLOR:
                figure.subplot_imshow(1,
                                      0,
                                      workspace.display_data.pixel_data,
                                      self.output_image_name.value,
                                      dimensions=dimensions)
            else:
                figure.subplot_imshow_bw(1,
                                         0,
                                         workspace.display_data.pixel_data,
                                         self.output_image_name.value,
                                         dimensions=dimensions)
예제 #6
0
    frame=frm,
    create_new_window=False)
frm.Show(False)
## generate identify primary objects' output
x.show_window = True
x.run(workspace)  #ON CHERCHE A RECUP NOYAUX SEGMENTÉS - COMMENT FAIRE ?

figure = cellprofiler.gui.figure.Figure(frm)
labeled_image = workspace.display_data.labeled_image
objects = object_set.get_objects(
    "nuclei"
)  #SET D'OBJETS CONTIENT JUSTE LE NOM "NUCLEI" MAIS PAS D'IMAGE, COMMENT OBTENIR L'IMAGE QUI VA AVEC L'OBJET ?

from matplotlib.figure import Figure
#x.display(workspace,figure)
figure.set_subplots((1, 1))

print("[EXTRACTING DATA]")

## ATTENTION : MODIFICATION DU CODE FIGURE.PY QUI RESORT L'IMAGE AVEC LES NOYAUX COLORÉS :
stuff = figure.subplot_imshow_labels(0,
                                     0,
                                     labeled_image,
                                     title=None,
                                     use_imshow=False)

print("[DEBUG] FLAG 2")
data_primary = stuff[1]  # = image avec noyaux colorés

## test - save data to txt files
#np.save("data_primary.npy", data_primary)