Skip to content

Parameter 'rank' in CSP definition did not accept str in MNE 1.7.1  #12693

@Karia70

Description

@Karia70

Description of the problem

Hi guys,
After MNE upgraded from V1.5.1 to 1.7.1, I found the parameter ‘rank’ in decoding.CSP() no longer supports string value. Meanwhile, the API reference of CSP keeps same as before. api
Please update the API reference, so we can learn what’s new, thanks.
The original question in forum is forum

Here, I use random data to reproduce the issue.

Steps to reproduce

import numpy as np
from mne.decoding import CSP
# Assume data X is a 4D array with shape (n_trials, n_chs, n_times)
# labels y is a 1D array with shape ( n_trials,)
X = np.random.rand(20, 64, 128)  # Example data
y = np.random.randint(0, 3, 20)  # Example labels
# error case
csp = CSP(n_components=3, reg='empirical', log=True, 
          cov_est='concat', transform_into='average_power',
          norm_trace=False, rank='full', component_order='mutual_info')
csp.fit(X, y)
# #no error case
# csp = CSP(n_components=3, reg='empirical', log=True, 
#           cov_est='concat', transform_into='average_power',
#           norm_trace=False, rank=None, component_order='mutual_info')
# csp.fit(X, y)

Link to data

No response

Expected results

No error

Actual results

Traceback (most recent call last):

Cell In[4], line 10
csp.fit(X, y)

File E:\conda_env\mne\Lib\site-packages\mne\decoding\csp.py:196 in fit
_validate_type(self.rank, (dict, None), "rank")

File E:\conda_env\mne\Lib\site-packages\mne\utils\check.py:613 in _validate_type
raise TypeError(

TypeError: rank must be an instance of dict or None, got <class 'str'> instead.

Additional information

Platform Windows-10-10.0.19045-SP0
Python 3.11.6 | packaged by conda-forge | (main, Oct 3 2023, 10:29:11) [MSC v.1935 64 bit (AMD64)]
Executable E:\conda_env\mne\pythonw.exe
CPU Intel64 Family 6 Model 158 Stepping 10, GenuineIntel (12 cores)
Memory 31.8 GB

Core
├☑ mne 1.7.1 (latest release)
├☑ numpy 1.25.2 (MKL 2023.1-Product with 6 threads)
├☑ scipy 1.11.3
└☑ matplotlib 3.7.3 (backend=Qt5Agg)

Numerical (optional)
├☑ sklearn 1.2.2
├☑ numba 0.58.0
├☑ nibabel 5.1.0
├☑ nilearn 0.10.2
├☑ dipy 1.7.0
├☑ openmeeg 2.5.7
├☑ cupy 12.2.0
├☑ pandas 2.2.1
├☑ h5io 0.1.9
└☑ h5py 3.10.0

Visualization (optional)
├☑ pyvista 0.42.2 (OpenGL 4.5.0 - Build 27.20.100.9365 via Intel(R) UHD Graphics 630)
├☑ pyvistaqt 0.0.0
├☑ vtk 9.2.6
├☑ qtpy 2.2.0 (PyQt5=5.15.8)
├☑ pyqtgraph 0.13.1
├☑ mne-qt-browser 0.6.1
├☑ ipywidgets 8.0.4
├☑ trame_client 2.12.1
├☑ trame_server 2.12.0
├☑ trame_vtk 2.5.8
├☑ trame_vuetify 2.3.1
└☐ unavailable ipympl

Ecosystem (optional)
├☑ mne-icalabel 0.5.1
├☑ eeglabio 0.0.2-4
├☑ edfio 0.4.3
├☑ mffpy 0.8.0
├☑ pybv 0.7.5
└☐ unavailable mne-bids, mne-nirs, mne-features, mne-connectivity, mne-bids-pipeline, neo

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions