def color_mix(img_spec1=None,
              img_spec2=None,
              alpha_channels=None,
              color_space='rgb',
              view_set=(0, 1, 2),
              num_slices=(10,),
              num_rows=2,
              rescale_method='global',
              background_threshold=0.05,
              annot=None,
              padding=5,
              output_path=None,
              figsize=None, ):
    """
    Color mixer, where each image is represented with a different color (default: red and green) in color channels.

    Parameters
    ----------
    img_spec1 : str or nibabel image-like object
        MR image (or path to one) to be visualized

    img_spec2 : str or nibabel image-like object
        MR image (or path to one) to be visualized

    alpha_channels : (float, float)
        weights for red and green channels in the composite image.
        Default: [1, 1]

    color_space : str
        type of color space to mix the images in.
        Currently supports 'rgb' only.
        Support for 'hsv' coming later.

    view_set : iterable
        Integers specifying the dimensions to be visualized.
        Choices: one or more of (0, 1, 2) for a 3D image

    num_slices : int or iterable of size as view_set
        number of slices to be selected for each view
        Must be of the same length as view_set,
            each element specifying the number of slices for each dimension.
            If only one number is given, same number will be chosen for all dimensions.

    num_rows : int
        number of rows (top to bottom) per each of 3 dimensions

    rescale_method : bool or str or list or None
        Range to rescale the intensity values to
        Default: 'global', min and max values computed based on ranges from both images.
        If false or None, no rescaling is done (does not work yet).

    background_threshold : float or str
        A threshold value below which all the background voxels will be set to zero.
        Default : 0.05. Other option is a string specifying a percentile: '5%', '10%'.
        Specify None if you don't want any thresholding.

    annot : str
        Text to display to annotate the visualization

    padding : int
        number of voxels to pad around each panel.

    output_path : str
        path to save the generate collage to.

    figsize : list
        Size of figure in inches to be passed on to plt.figure() e.g. [12, 12] or [20, 20]

    Returns
    -------
    fig : figure handle
        handle to the collage figure generated.

    """

    if alpha_channels is None:
        alpha_channels = [1, 1]

    if not len(alpha_channels) == 2:
        # not sure if we should make them sum to 1:  or not np.isclose(sum(alpha_channels), 1.0)
        raise ValueError('Alpha must be two elements')

    mixer_params = dict(alpha_channels=alpha_channels,
                        color_space=color_space)
    fig = _compare(img_spec1,
                   img_spec2,
                   num_rows=num_rows,
                   num_cols=num_slices,
                   mixer='color_mix',
                   annot=annot,
                   padding=padding,
                   rescale_method=rescale_method,
                   bkground_thresh=background_threshold,
                   output_path=output_path,
                   figsize=figsize,
                   **mixer_params)

    return fig
def color_mix ( img_spec1 = None , img_spec2 = None , alpha_channels = None , color_space = 'rgb' , view_set = ( 0 , 1 , 2 ) , num_slices = ( 10 , ) , num_rows = 2 , rescale_method = 'global' , background_threshold = 0.05 , annot = None , padding = 5 , output_path = None , figsize = None , ) : if alpha_channels is None : alpha_channels = [ 1 , 1 ] if not len ( alpha_channels ) == 2 : raise ValueError ( 'Alpha must be two elements' ) mixer_params = dict ( alpha_channels = alpha_channels , color_space = color_space ) fig = _compare ( img_spec1 , img_spec2 , num_rows = num_rows , num_cols = num_slices , mixer = 'color_mix' , annot = annot , padding = padding , rescale_method = rescale_method , bkground_thresh = background_threshold , output_path = output_path , figsize = figsize , ** mixer_params ) return fig
Color mixer, where each image is represented with a different color (default: red and green) in color channels.

    Parameters
    ----------
    img_spec1 : str or nibabel image-like object
        MR image (or path to one) to be visualized

    img_spec2 : str or nibabel image-like object
        MR image (or path to one) to be visualized

    alpha_channels : (float, float)
        weights for red and green channels in the composite image.
        Default: [1, 1]

    color_space : str
        type of color space to mix the images in.
        Currently supports 'rgb' only.
        Support for 'hsv' coming later.

    view_set : iterable
        Integers specifying the dimensions to be visualized.
        Choices: one or more of (0, 1, 2) for a 3D image

    num_slices : int or iterable of size as view_set
        number of slices to be selected for each view
        Must be of the same length as view_set,
            each element specifying the number of slices for each dimension.
            If only one number is given, same number will be chosen for all dimensions.

    num_rows : int
        number of rows (top to bottom) per each of 3 dimensions

    rescale_method : bool or str or list or None
        Range to rescale the intensity values to
        Default: 'global', min and max values computed based on ranges from both images.
        If false or None, no rescaling is done (does not work yet).

    background_threshold : float or str
        A threshold value below which all the background voxels will be set to zero.
        Default : 0.05. Other option is a string specifying a percentile: '5%', '10%'.
        Specify None if you don't want any thresholding.

    annot : str
        Text to display to annotate the visualization

    padding : int
        number of voxels to pad around each panel.

    output_path : str
        path to save the generate collage to.

    figsize : list
        Size of figure in inches to be passed on to plt.figure() e.g. [12, 12] or [20, 20]

    Returns
    -------
    fig : figure handle
        handle to the collage figure generated.