pick
is a more general do-all function while:
-
pick_channels
only selects channels by name
-
pick_types
only selects channels by type
With pick
you can do either of the 2 above and you can also select by indices. However, the order has to be controlled and provided correctly by the user. Here is an example with different cases I could think of:
import numpy as np
from mne import create_info
from mne.channels import make_standard_montage
from mne.io import RawArray
montage = make_standard_montage("standard_1020")
ch_names = [ch for ch in montage.ch_names][:10]
info = create_info(ch_names, 512, "eeg")
data = np.random.randn(len(ch_names), 4096)
raw = RawArray(data, info)
# >>> raw.ch_names
# ['Fp1', 'Fpz', 'Fp2', 'AF9', 'AF7', 'AF5', 'AF3', 'AF1', 'AFz', 'AF2']
raw_ = raw.copy().pick_channels(["Fp1", "AF7", "Fpz"])
# >>> raw_.ch_names
# ['Fp1', 'Fpz', 'AF7'] -> initial order
raw_ = raw.copy().pick_channels([0, 4, 1])
# >>> raises ValueError -> does not work with indices
raw_ = raw.copy().pick([0, 4, 1])
# >>> raw_.ch_names
# ['Fp1', 'AF7', 'Fpz'] -> works with indices, ordered 0, 4, 1 as provided.
raw_ = raw.copy().pick(["Fp1", "AF7", "Fpz"])
# >>> raw_.ch_names
# ['Fp1', 'AF7', 'Fpz']
# pick also work with types.
raw.set_channel_types({"Fp1": "eog"})
raw_ = raw.copy().pick("eeg")
# >>> raw_.ch_names
# [Fpz', 'Fp2', 'AF9', 'AF7', 'AF5', 'AF3', 'AF1', 'AFz', 'AF2']
raw_ = raw.copy().pick_types(eeg=True)
# >>> raw_.ch_names
# [Fpz', 'Fp2', 'AF9', 'AF7', 'AF5', 'AF3', 'AF1', 'AFz', 'AF2']