def qci(mask, tfilter=None):
    """
    Compute the quality control index (QCI) for each column, defined as:
    
    :math:`QCI=\\dfrac{\\sum_{t\\in T}X_{dt}}{|T|}`
    
    where 
    :math:`T` is the set of timestamps in the analysis.  
    :math:`X_{dt}` is a data point for column :math:`d` time t` that passed 
    all quality control test.  
    :math:`|T|` is the number of data points in the analysis.
    
    Parameters
    ----------
    mask : pandas DataFrame
        Test results mask, returned from pm.mask
    
    tfilter : pandas Series (optional)
        Time filter containing boolean values for each time index
        
    Returns
    -------
    pandas Series
        Quality control index
    """
    if tfilter is not None:
        mask = mask[tfilter]
    qci = mask.sum() / mask.shape[0]
    return qci
