def tmask_blocks(tmask, min_block=0, sample_time=1):
    """
    Return a list containing the indices of each valid block of a temporal
    mask.

    Parameters
    ----------
    tmask
        The temporal mask, in which 1 denotes valid observations and 0
        denotes invalid or missing observations.
    min_block
        The minimum length of a block, in the same units as sample_time.
        If sample_time is not set explicitly, then this is measured in
        samples. If min_block is not set, then all blocks of valid data
        will be returned.
    sample_time
        The sampling interval of the temporal mask.

    Outputs
    -------
    blocks: list
        A list whose length equals the number of valid blocks in the
        temporal mask and whose entries are lists of the indices in each
        block.
    """
    def _check_block_length(block, blocks, min_block, sample_time):
        if len(block) * sample_time > min_block:
            blocks.append(block)

    blocks = []
    block = []
    for i, t in enumerate(tmask):
        if t:
            block.append(i)
        else:
            _check_block_length(block, blocks, min_block, sample_time)
            block = []
    _check_block_length(block, blocks, min_block, sample_time)
    return blocks