All picks must be < n_channels (14), got 14

  • MNE version: 1.2.2
  • operating system: Windows 10

Hello,

I want to do a ttest from 2 sessions of one sample, but I encounter an error. How can I solve All picks must be < n_channels (14), got 14 Error?
Thanks in advance.

:one: I read the data from BIDS as it is in below:

bids_root = pathlib.Path('out_data/sample_BIDS')

bids_path1 = mne_bids.BIDSPath(subject='01',
                              session='01',
                              task='audiovisual',
                              run='01',
                              datatype='eeg',
                              root=bids_root)
bids_path2 = mne_bids.BIDSPath(subject='01',
                              session='02',
                              task='audiovisual',
                              run='01',
                              datatype='eeg',
                              root=bids_root)

# read data for subject 01, session 01

raw1 = mne_bids.read_raw_bids(bids_path1)
raw1.load_data()
raw1.filter(l_freq=0.1, h_freq=40)

# read data for subject 01, session 02

raw2= mne_bids.read_raw_bids(bids_path2)
raw2.load_data()
raw2.filter(l_freq=0.1, h_freq=40)
tmin = -0.200
tmax = 0.500
baseline = (None, 0)

:two: and after that I run this cell:

raw1_downsampled = raw1.resample(sfreq=raw1.info['sfreq']/2)
raw2_downsampled = raw2.resample(sfreq=raw2.info['sfreq']/2)
print(raw1_downsampled)
print(raw2_downsampled)

mne.stats.ttest_ind_no_p(raw1_downsampled, raw2_downsampled, equal_var=True, sigma=0.0)

:warning: but the result is that Error:

<RawBrainVision | sub-01_ses-01_task-audiovisual_run-01_eeg.eeg, 14 x 8550 (228.0 s), ~962 kB, data loaded>
<RawBrainVision | sub-01_ses-02_task-audiovisual_run-01_eeg.eeg, 14 x 13425 (358.0 s), ~1.5 MB, data loaded>
   1034     if (picks >= n_chan).any():
   1035         raise ValueError('All picks must be < n_channels (%d), got %r'
-> 1036                          % (n_chan, orig_picks))
   1037     picks %= n_chan  # ensure positive
   1038     if return_kind:

ValueError: All picks must be < n_channels (14), got 14

ttest_ind_no_p takes array-like input for a and b. You are passing it Raw instances. That is the problem. At a minimum you will need to pass in raw1_downsampled.get_data() and raw2_downsampled.get_data() instead of the Raw objects.