Picks dimension mismatch

  • MNE-Python version: 0.22.1
  • operating system: Win 10

Using what they made available from Brainflow plus what I found on Kaggle I’m trying to perform ICA over my data. The following error is not allowing me to actually plot it:

Traceback (most recent call last):
File "C:\Users\atech\Documents\GitHub\SSVEP_EyeGaze-py\_testMNE.py", line 102, in <module>
ica.plot_components(custom_epochs)
File "C:\Users\atech\anaconda3\envs\mne\lib\site-packages\mne\preprocessing\ica.py", line 1804, in plot_components
return plot_ica_components(self, picks=picks, ch_type=ch_type,
File "<decorator-gen-137>", line 24, in plot_ica_components
File "C:\Users\atech\anaconda3\envs\mne\lib\site-packages\mne\viz\topomap.py", line 1159, in plot_ica_components
picks = _picks_to_idx(ica.info, picks)
File "C:\Users\atech\anaconda3\envs\mne\lib\site-packages\mne\io\pick.py", line 1039, in _picks_to_idx
raise ValueError('picks must be 1D, got %sD' % (picks.ndim,))
ValueError: picks must be 1D, got 3D

But when I print picks & its shape, it returns a unidimensional variable, for what I understand:

Values = [0 1 2 3 4 5]
Shape = (6,)

I assume picks comes from the info object the mne object. It is created like Brainflow suggested:

ch_types = ['eeg'] * len(eeg_channels)
ch_names = BoardShim.get_eeg_names(BoardIds.CYTON_BOARD.value)
#not using the last two channels, so:
ch_names.pop()
ch_names.pop()
sfreq = BoardShim.get_sampling_rate(BoardIds.CYTON_BOARD.value)
info = mne.create_info(ch_names = ch_names, sfreq = sfreq, ch_types = ch_types)

# Creating MNE Epochs Array
custom_epochs = mne.EpochsArray(eeg_data, info=info, events=events.astype('int'), tmin=0, event_id=event_id)

# Pick EEG signal
picks = mne.pick_types(custom_epochs.info, eeg=True) 

# ICA part
ica = ICA(n_components=2, method='fastica').fit(custom_epochs) #ICA.fit works fine
print(picks) 
print(picks.shape) 
ica.plot_components(custom_epochs) #Here it complains

Is there a second picks variable I’m not seeing? How can I fix this?

ValueError: picks must be 1D, got 3D

what is the value of picks you passed?

Alex

Do you mean on this part?

picks = mne.pick_types(custom_epochs.info, eeg=True)

For both picks and custom_epochs.picks (tested before and after ICA().fit()), the value and size are

Values = [0 1 2 3 4 5]
Shape = (6,)

If I didn’t understand your question tho, please let me know what you need to know. I’m new to MNE.

can you share a folder with me containing the file and a script that reproduces the crash? eg
using dropbox?

Alex

I found out that the problem was that I was trying to plot all the epochs at the same time.
The solution was to create a loop:

for epoch in custom_epochs:
    for channel in epoch:
         ica.plot_components(channel)