cytometer/data.py
def aida_contour_item(contour, rgb_colour, cell_prob=None):
        """
        Create an object that describes a closed contour in AIDA. The user provides the coordinates of the contour
        points and the colour for the contour.

        :param contour: np.array or list of points of a contour: [[x0, y0], [x1, y1], ...]
        :param rgb_colour: (r, g, b) or (r, g, b, alpha). RGB colour for this contour.
        :param cell_prob: (def None) Scalar in [0.0, 1.0] with the probability of the contour being a cell.
        :return: item: dictionary with the structure of the contour object.
        """

        if type(contour) != 'numpy.ndarray':
            contour = list(contour)

        # convert RGB to HSL
        hls_colour = colorsys.rgb_to_hls(rgb_colour[0], rgb_colour[1], rgb_colour[2])

        # create the item object
        item = {
            'class': '',
            'type': 'path',
            'color': {
                'fill': {
                    'hue': hls_colour[0] * 360,
                    'saturation': hls_colour[2],
                    'lightness': hls_colour[1],
                    'alpha': 0.7
                },
                'stroke': {
                    'hue': hls_colour[0] * 360,
                    'saturation': hls_colour[2],
                    'lightness': hls_colour[1],
                    'alpha': 1.0
                }
            },
            'segments': [list(x) for x in contour],
            'closed': True
        }

        if cell_prob is not None:
            item['cell_prob'] = cell_prob

        return item

        Create an object that describes a closed contour in AIDA. The user provides the coordinates of the contour
        points and the colour for the contour.

        :param contour: np.array or list of points of a contour: [[x0, y0], [x1, y1], ...]
        :param rgb_colour: (r, g, b) or (r, g, b, alpha). RGB colour for this contour.
        :param cell_prob: (def None) Scalar in [0.0, 1.0] with the probability of the contour being a cell.
        :return: item: dictionary with the structure of the contour object.
        
Create an object that describes a closed contour in AIDA. The user provides the coordinates of the contour
points and the colour for the contour.
Create an object that describes a closed contour in AIDA . The user provides the coordinates of the contour points and the colour for the contour .
def aida_contour_item(contour, rgb_colour, cell_prob=None):
        if type(contour) != 'numpy.ndarray':
            contour = list(contour)
        hls_colour = colorsys.rgb_to_hls(rgb_colour[0], rgb_colour[1], rgb_colour[2])
        item = {
            'class': '',
            'type': 'path',
            'color': {
                'fill': {
                    'hue': hls_colour[0] * 360,
                    'saturation': hls_colour[2],
                    'lightness': hls_colour[1],
                    'alpha': 0.7
                },
                'stroke': {
                    'hue': hls_colour[0] * 360,
                    'saturation': hls_colour[2],
                    'lightness': hls_colour[1],
                    'alpha': 1.0
                }
            },
            'segments': [list(x) for x in contour],
            'closed': True
        }
        if cell_prob is not None:
            item['cell_prob'] = cell_prob
        return item
def aida_contour_item ( contour , rgb_colour , cell_prob = None ) : if type ( contour ) != 'numpy.ndarray' : contour = list ( contour ) hls_colour = colorsys . rgb_to_hls ( rgb_colour [ 0 ] , rgb_colour [ 1 ] , rgb_colour [ 2 ] ) item = { 'class' : '' , 'type' : 'path' , 'color' : { 'fill' : { 'hue' : hls_colour [ 0 ] * 360 , 'saturation' : hls_colour [ 2 ] , 'lightness' : hls_colour [ 1 ] , 'alpha' : 0.7 } , 'stroke' : { 'hue' : hls_colour [ 0 ] * 360 , 'saturation' : hls_colour [ 2 ] , 'lightness' : hls_colour [ 1 ] , 'alpha' : 1.0 } } , 'segments' : [ list ( x ) for x in contour ] , 'closed' : True } if cell_prob is not None : item [ 'cell_prob' ] = cell_prob return item
Create an object that describes a closed contour in AIDA.
Create an object that describes a closed contour in AIDA .
"""
        Create an object that describes a closed contour in AIDA. The user provides the coordinates of the contour
        points and the colour for the contour.

        :param contour: np.array or list of points of a contour: [[x0, y0], [x1, y1], ...]
        :param rgb_colour: (r, g, b) or (r, g, b, alpha). RGB colour for this contour.
        :param cell_prob: (def None) Scalar in [0.0, 1.0] with the probability of the contour being a cell.
        :return: item: dictionary with the structure of the contour object.
        """ # convert RGB to HSL # create the item object
dictionary with the structure of the contour object.
dictionary with the structure of the contour object .
contour
None
rgb_colour
None
cell_prob
(def None) Scalar in [0.0, 1.0] with the probability of the contour being a cell.
( def None ) Scalar in [ 0 . 0 1 . 0 ] with the probability of the contour being a cell .