def create_bids_outputs_dictionary(cpac_output_bids_dictionary):
    """
    Creates a dictionary that maps cpac paths to bids paths

    :param cpac_output_bids_dictionary: mapping from original file name to bids dictionary, which will be converted into
        a filename

    :return: path mapping dictionary
    """

    cpac_bids_path_map = {}
    for (cpac_output_path, bids_dict) in cpac_output_bids_dictionary.items():

        if 'derivative' in bids_dict:
            bids_path = bids_dict["bids_derivative_path"] + '/' + '_'.join(
                [bids_dict['source']] +
                ['-'.join([key, bids_dict[key]]) for key in
                 ['target', 'space', 'res', 'variant', 'atlas', 'roi', 'label'] if
                 key in bids_dict and bids_dict[key]] +
                [bids_dict['derivative']]) + "." + bids_dict['bids_file_extension']

            cpac_bids_path_map[cpac_output_path] = bids_path

        else:
            print('{0} is missing {1}'.format(bids_dict, 'derivative'))

    return cpac_bids_path_map