def take_subsequences(dfs):
    """
    Make subsequences of the data that are completely valid.

    Parameters
    ----------
    dfs : dict
        dict holding all the merged dataframes (result from process_data)

    Returns
    -------
    dict holding all the subsequences

    """
    subsets = {}
    for key in list(dfs.keys()):
        dataset = dfs[key]
        invalids = [1] + list(dataset['invalid']) + [1]
        starts = [i for i in range(1, len(invalids) - 1) if invalids[i - 1] == 1 and invalids[i] == 0]
        ends = [i for i in range(1, len(invalids)) if invalids[i - 1] == 0 and invalids[i] == 1]
        dataset['subset'] = -1
        for i, (s, e) in enumerate(zip(starts, ends)):
            # Some minimum length
            if e - s > 300:
                dataset.loc[s - 1:e - 1, 'subset'] = i
                subsets[(key, i)] = (dataset[s - 1:e - 1].copy())
    return subsets