def update_metadata(metadata, lost_cells, bad_pwfs=None):
    """Update metadata table with a new column indicating if a cell is considered as lost.
    Considers both direct lost cell list and an additional bad regions defined by 'find_bad_regions'.

    Parameters
    --------
    metadata : pandas.DataFrame
        table of metadata
    lost_cells : list
        list of indices of lost cells, must match those in metadata.
    bad_pwfs : None or list
        list of additional bad regions in the experiment. 

    Returns
    --------
    updated_metadata : pandas.DataFrame
        updated metadata with a new column 'labeled_as_lost' indicating if a cell is lost.
    """
    updated_metadata = metadata.copy()
    updated_metadata['pwf'] = [
        '_'.join(x.split('_')[:-1]) for x in updated_metadata.index]
    updated_metadata['labeled_as_lost'] = 'No'
    updated_metadata.loc[lost_cells, 'labeled_as_lost'] = 'Yes'
    if bad_pwfs is not None:
        updated_metadata.loc[updated_metadata.pwf.isin(
            bad_pwfs), 'labeled_as_lost'] = 'Yes'
    return updated_metadata