@verbose
def _merge_info(infos, verbose=None):
    """Merge multiple measurement info dictionaries.

     - Fields that are present in only one info object will be used in the
       merged info.
     - Fields that are present in multiple info objects and are the same
       will be used in the merged info.
     - Fields that are present in multiple info objects and are different
       will result in a None value in the merged info.
     - Channels will be concatenated. If multiple info objects contain
       channels with the same name, an exception is raised.

    Parameters
    ----------
    infos | list of instance of Info
        Info objects to merge into one info object.
    verbose : bool, str, int, or NonIe
        If not None, override default verbose level (see mne.verbose).

    Returns
    -------
    info : instance of Info
        The merged info object.
    """
    for info in infos:
        info._check_consistency()
    info = Info()
    info['chs'] = []
    for this_info in infos:
        info['chs'].extend(this_info['chs'])
    info._update_redundant()
    duplicates = set([ch for ch in info['ch_names']
                      if info['ch_names'].count(ch) > 1])
    if len(duplicates) > 0:
        msg = ("The following channels are present in more than one input "
               "measurement info objects: %s" % list(duplicates))
        raise ValueError(msg)

    transforms = ['ctf_head_t', 'dev_head_t', 'dev_ctf_t']
    for trans_name in transforms:
        trans = [i[trans_name] for i in infos if i[trans_name]]
        if len(trans) == 0:
            info[trans_name] = None
        elif len(trans) == 1:
            info[trans_name] = trans[0]
        elif all(np.all(trans[0]['trans'] == x['trans']) and
                 trans[0]['from'] == x['from'] and
                 trans[0]['to'] == x['to']
                 for x in trans[1:]):
            info[trans_name] = trans[0]
        else:
            msg = ("Measurement infos provide mutually inconsistent %s" %
                   trans_name)
            raise ValueError(msg)
    other_fields = ['acq_pars', 'acq_stim', 'bads', 'buffer_size_sec',
                    'comps', 'custom_ref_applied', 'description', 'dig',
                    'experimenter', 'file_id', 'filename', 'highpass',
                    'hpi_results', 'hpi_meas', 'hpi_subsystem', 'events',
                    'line_freq', 'lowpass', 'meas_date', 'meas_id',
                    'proj_id', 'proj_name', 'projs', 'sfreq',
                    'subject_info', 'sfreq', 'xplotter_layout']

    for k in other_fields:
        info[k] = _merge_dict_values(infos, k)
    info._check_consistency()
    return info
dataset/ETHPy150Open mne-tools/mne-python/mne/io/meas_info.py/_merge_info/original