def normalize_qa(qa, max_qa=None):
    """ Normalize quantitative anisotropy. 

    Used mostly with GQI rather than GQI2.

    Parameters
    ----------
    qa : array, shape (X, Y, Z, N)
        where N is the maximum number of peaks stored
    max_qa : float,
        maximum qa value. Usually found in the CSF (corticospinal fluid).

    Returns
    -------
    nqa : array, shape (x, Y, Z, N)
        normalized quantitative anisotropy

    Notes
    -----
    Normalized quantitative anisotropy has the very useful property
    to be very small near gray matter and background areas. Therefore, 
    it can be used to mask out white matter areas. 

    """
    if max_qa is None:
        return qa / qa.max()
    return qa / max_qa