'Get location and latency of peak amplitude.
Parameters
ch_type : \'mag\', \'grad\', \'eeg\', \'seeg\', \'ecog\', \'hbo\', hbr\', \'misc\', None  # noqa
The channel type to use. Defaults to None. If more than one sensor
Type is present in the data the channel type has to be explicitly
set.
tmin : float | None
The minimum point in time to be considered for peak getting.
If None (default), the beginning of the data is used.
tmax : float | None
The maximum point in time to be considered for peak getting.
If None (default), the end of the data is used.
mode : {\'pos\', \'neg\', \'abs\'}
How to deal with the sign of the data. If \'pos\' only positive
values will be considered. If \'neg\' only negative values will
be considered. If \'abs\' absolute values will be considered.
Defaults to \'abs\'.
time_as_index : bool
Whether to return the time index instead of the latency in seconds.
merge_grads : bool
If True, compute peak from merged gradiometer data.
Returns
ch_name : str
The channel exhibiting the maximum response.
latency : float | int
The time point of the maximum response, either latency in seconds
or index.'

def get_peak(self, ch_type=None, tmin=None, tmax=None, mode='abs', time_as_index=False, merge_grads=False):

    supported = ('mag', 'grad', 'eeg', 'seeg', 'ecog', 'misc', 'hbo', 'hbr', 'None')
    data_picks = _pick_data_channels(self.info, with_ref_meg=False)
    types_used = set([channel_type(self.info, idx) for idx in data_picks])
    if (str(ch_type) not in supported):
        raise ValueError('Channel    type    must    be    `{supported}`.    You    gave    me    `{ch_type}`    instead.'.format(ch_type=ch_type, supported='`    or    `'.join(supported)))
    elif ((ch_type is not None) and (ch_type not in types_used)):
        raise ValueError('Channel    type    `{ch_type}`    not    found    in    this    evoked    object.'.format(ch_type=ch_type))
    elif ((len(types_used) > 1) and (ch_type is None)):
        raise RuntimeError('More    than    one    sensor    type    found.    `ch_type`    must    not    be    `None`,    pass    a    sensor    type    value    instead')
    if merge_grads:
        if (ch_type != 'grad'):
            raise ValueError('Channel    type    must    be    grad    for    merge_grads')
        elif (mode == 'neg'):
            raise ValueError('Negative    mode    (mode=neg)    does    not    make    sense    with    merge_grads=True')
    meg = eeg = misc = seeg = ecog = fnirs = False
    picks = None
    if (ch_type in ('mag', 'grad')):
        meg = ch_type
    elif (ch_type == 'eeg'):
        eeg = True
    elif (ch_type == 'misc'):
        misc = True
    elif (ch_type == 'seeg'):
        seeg = True
    elif (ch_type == 'ecog'):
        ecog = True
    elif (ch_type in ('hbo', 'hbr')):
        fnirs = ch_type
    if (ch_type is not None):
        if merge_grads:
            picks = _pair_grad_sensors(self.info, topomap_coords=False)
        else:
            picks = pick_types(self.info, meg=meg, eeg=eeg, misc=misc, seeg=seeg, ecog=ecog, ref_meg=False, fnirs=fnirs)
    data = self.data
    ch_names = self.ch_names
    if (picks is not None):
        data = data[picks]
        ch_names = [ch_names[k] for k in picks]
    if merge_grads:
        data = _merge_grad_data(data)
        ch_names = [(ch_name[:(-1)] + 'X') for ch_name in ch_names[::2]]
    (ch_idx, time_idx) = _get_peak(data, self.times, tmin, tmax, mode)
    return (ch_names[ch_idx], (time_idx if time_as_index else self.times[time_idx]))
