cytometer/data.py
def aida_colourmap():
    """
    Create a colourmap that replicates in plt.imshow() the colours that we obtain in AIDA. This colormap is called
    'quantiles_aida'.

    This colourmap is meant to map area quantiles [0.0, 1.0] to a pastel yellow-green-purple colour scale.

    This function can be combined with area2quantile() to map areas to colours:

        import cytometer

        # variables already assigned
        manual_areas # vector with a representative random sample of cell areas. The distribution will be computed from these values
        area_grid  # np.float32 2D array with area values interpolated onto a pixel grid
        area_mask # bool array of the same size that says where there's tissue and where not

        # compute function to map between cell areas and [0.0, 1.0]
        f_area2quantile = cytometer.data.area2quantile(manual_areas)

        # convert area values to quantiles
        quantiles_grid = f_area2quantile(quantiles_grid)

        # make background white in the plot
        quantiles_grid[~areas_mask] = np.nan

        # load AIDA's colourmap
        cm = cytometer.data.aida_colourmap()

        # plot
        plt.imshow(quantiles_grid, vmin=0.0, vmax=1.0, cmap=cm)

    :return:
    * cm: matplotlib.colors.ListedColormap with 101 colours.
    """

    # range of colours in HSL format
    hue = np.linspace(0, 315 / 360, 101)
    lightness = 0.69
    saturation = 0.44
    alpha = 1

    # the colourmap only changes the hue linearly, while keeping the saturation and lightness constant
    cm = [colorsys.hls_to_rgb(h=h, l=lightness, s=saturation) + (alpha,) for h in hue]

    return ListedColormap(cm, name='quantiles_aida')

    Create a colourmap that replicates in plt.imshow() the colours that we obtain in AIDA. This colormap is called
    'quantiles_aida'.

    This colourmap is meant to map area quantiles [0.0, 1.0] to a pastel yellow-green-purple colour scale.

    This function can be combined with area2quantile() to map areas to colours:

        import cytometer

        # variables already assigned
        manual_areas # vector with a representative random sample of cell areas. The distribution will be computed from these values
        area_grid  # np.float32 2D array with area values interpolated onto a pixel grid
        area_mask # bool array of the same size that says where there's tissue and where not

        # compute function to map between cell areas and [0.0, 1.0]
        f_area2quantile = cytometer.data.area2quantile(manual_areas)

        # convert area values to quantiles
        quantiles_grid = f_area2quantile(quantiles_grid)

        # make background white in the plot
        quantiles_grid[~areas_mask] = np.nan

        # load AIDA's colourmap
        cm = cytometer.data.aida_colourmap()

        # plot
        plt.imshow(quantiles_grid, vmin=0.0, vmax=1.0, cmap=cm)

    :return:
    * cm: matplotlib.colors.ListedColormap with 101 colours.
    
Create a colourmap that replicates in plt.imshow() the colours that we obtain in AIDA. This colormap is called
'quantiles_aida'.

This colourmap is meant to map area quantiles [0.0, 1.0] to a pastel yellow-green-purple colour scale.

This function can be combined with area2quantile() to map areas to colours.

import cytometer

variables already assigned
manual_areas # vector with a representative random sample of cell areas. The distribution will be computed from these values
area_grid  # np.float32 2D array with area values interpolated onto a pixel grid
area_mask # bool array of the same size that says where there's tissue and where not





make background white in the plot
quantiles_grid[~areas_mask] = np.nan

load AIDA's colourmap
cm = cytometer.data.aida_colourmap()


Create a colourmap that replicates in plt . imshow () the colours that we obtain in AIDA . This colormap is called ' quantiles_aida ' . This colourmap is meant to map area quantiles [ 0 . 0 1 . 0 ] to a pastel yellow - green - purple colour scale . This function can be combined with area2quantile () to map areas to colours . import cytometer variables already assigned manual_areas # vector with a representative random sample of cell areas . The distribution will be computed from these values area_grid # np . float32 2D array with area values interpolated onto a pixel grid area_mask # bool array of the same size that says where there ' s tissue and where not make background white in the plot quantiles_grid [ ~areas_mask ] = np . nan load AIDA ' s colourmap cm = cytometer . data . aida_colourmap ()
def aida_colourmap():
    hue = np.linspace(0, 315 / 360, 101)
    lightness = 0.69
    saturation = 0.44
    alpha = 1
    cm = [colorsys.hls_to_rgb(h=h, l=lightness, s=saturation) + (alpha,) for h in hue]
    return ListedColormap(cm, name='quantiles_aida')
def aida_colourmap ( ) : hue = np . linspace ( 0 , 315 / 360 , 101 ) lightness = 0.69 saturation = 0.44 alpha = 1 cm = [ colorsys . hls_to_rgb ( h = h , l = lightness , s = saturation ) + ( alpha , ) for h in hue ] return ListedColormap ( cm , name = 'quantiles_aida' )
Create a colourmap that replicates in plt.imshow() the colours that we obtain in AIDA.
Create a colourmap that replicates in plt . imshow () the colours that we obtain in AIDA .
"""
    Create a colourmap that replicates in plt.imshow() the colours that we obtain in AIDA. This colormap is called
    'quantiles_aida'.

    This colourmap is meant to map area quantiles [0.0, 1.0] to a pastel yellow-green-purple colour scale.

    This function can be combined with area2quantile() to map areas to colours:

        import cytometer

        # variables already assigned
        manual_areas # vector with a representative random sample of cell areas. The distribution will be computed from these values
        area_grid  # np.float32 2D array with area values interpolated onto a pixel grid
        area_mask # bool array of the same size that says where there's tissue and where not

        # compute function to map between cell areas and [0.0, 1.0]
        f_area2quantile = cytometer.data.area2quantile(manual_areas)

        # convert area values to quantiles
        quantiles_grid = f_area2quantile(quantiles_grid)

        # make background white in the plot
        quantiles_grid[~areas_mask] = np.nan

        # load AIDA's colourmap
        cm = cytometer.data.aida_colourmap()

        # plot
        plt.imshow(quantiles_grid, vmin=0.0, vmax=1.0, cmap=cm)

    :return:
    * cm: matplotlib.colors.ListedColormap with 101 colours.
    """ # range of colours in HSL format # the colourmap only changes the hue linearly, while keeping the saturation and lightness constant
matplotlib.colors.ListedColormap with 101 colours.
matplotlib . colors . ListedColormap with 101 colours .