Skip to content

Conversation

@MerlinK75
Copy link
Contributor

Just updated the requirements from pyriemann>=0.2.7 -> pyriemann=0.3

@codecov
Copy link

codecov bot commented Jan 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.86%. Comparing base (16e9f7e) to head (08247b5).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #85   +/-   ##
=======================================
  Coverage   82.86%   82.86%           
=======================================
  Files          25       25           
  Lines        2813     2813           
=======================================
  Hits         2331     2331           
  Misses        482      482           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nbara
Copy link
Owner

nbara commented Jan 4, 2025

Hey @MerlinK75 , upon closer inspection I am not finding any trace of _check_est anywhere in meegkit? Could you post the full error here please?

@nbara nbara linked an issue Jan 4, 2025 that may be closed by this pull request
@ohspc89
Copy link

ohspc89 commented Feb 7, 2025

Hello, may I chime in? First of all, thank you for preparing this wonderful package. I am just learning how to apply asr to my EEG data read by a mne.io.Raw object.

I set up a virtual environment (Python 3.11.11) and installed meegkit first. Currently it's meegkit==0.1.7 and pyriemann==0.7.

I am just replicating an example. So here's my code:

asr = ASR(method='euclid')
_, sample_mask = asr.fit(raw._data)

raw._data is just a NumPy array of shape (32, 14995); 32 channels, about 1 min recording.

Here's the error message I get.

ImportError  Traceback (most recent call last)
Cell In[9], line 1
----> 1 _, sample_mask = asr.fit(notch._data)

File ~/Documents/EEG_venv/lib/python3.11/site-
packages/meegkit/asr.py:182, in ASR.fit(self, 
X, y, **kwargs)
    172 clean, sample_mask = clean_windows(
    173     X,
    174     sfreq=self.sfreq,
   (...)
    178     min_clean_fraction=self.min_clean_
fraction,
    179     max_dropout_fraction=self.max_drop
out_fraction)
    181 # Perform calibration
--> 182 M, T = asr_calibrate(
    183     clean,
    184     sfreq=self.sfreq,
    185     cutoff=self.cutoff,
    186     blocksize=self.blocksize,
    187     win_len=self.win_len,
    188     win_overlap=self.win_overlap,
    189     max_dropout_fraction=self.max_drop
out_fraction,
    190     min_clean_fraction=self.min_clean_
fraction,
    191     method=self.method,
    192     estimator=self.estimator)
    194 self.state_ = dict(M=M, T=T, R=None)
    195 self._fitted = True

File ~/Documents/EEG_venv/lib/python3.11/site-
packages/meegkit/asr.py:491, in asr_calibrate(
X, sfreq, cutoff, blocksize, win_len, win_over
lap, max_dropout_fraction, min_clean_fraction,
 method, estimator)
    488 # window length for calculating thresh
olds
    489 N = int(np.round(win_len * sfreq))
--> 491 U = block_covariance(X, window=blocksi
ze, overlap=win_overlap,
    492                      estimator=estimat
or)
    493 if method == "euclid":
    494     Uavg = geometric_median(U.reshape(
(-1, nc * nc)))

File ~/Documents/EEG_venv/lib/python3.11/site-
packages/meegkit/utils/covariances.py:36, in b
lock_covariance(data, window, overlap, padding
, estimator)
     18 def block_covariance(data, window=128,
 overlap=0.5, padding=True, estimator="cov"):
     19     """Compute blockwise covariance.
     20 
     21     Parameters
   (...)
     34 
     35     """
---> 36     from pyriemann.utils.covariance im
port _check_est
     38     assert 0 <= overlap < 1, "overlap 
must be < 1"
     39     est = _check_est(estimator)

ImportError: cannot import name '_check_est' f
rom 'pyriemann.utils.covariance' (/Users/joh/D
ocuments/EEG_venv/lib/python3.11/site-packages
/pyriemann/utils/covariance.py)

Let me know if I need to clarify more. Sorry for my verbosity... just another noob here.

@nbara
Copy link
Owner

nbara commented Feb 10, 2025

@ohspc89 Thanks for flagging this. Please could you install the latest version from github and try again?

I think this should ought to do the trick:

pip install git+https://github.com/nbara/python-meegkit.git

If this works that means the problem is solved on main, and I just need to release a new version on PyPI

@ohspc89
Copy link

ohspc89 commented Feb 10, 2025

@nbara Will check this out tonight and share the result. Thank you!

@ohspc89
Copy link

ohspc89 commented Feb 11, 2025

@nbara Yes my code works without much problem. Just one question - right now your requirements.txt lists pyriemann>=0.2.7 to be installed. I initially tested my code with pyriemann==0.4 and meegkit==0.1.8. With that I get a different error:

Traceback (most recent call last):
  File "/home/jinseok/Documents/EEG_notebooks/EEG_Self_Study/testasr.py", line 40, in <module>
    out = asr_preserve_samples(origdata, freq_to_use)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jinseok/Documents/EEG_notebooks/EEG_Self_Study/testasr.py", line 28, in asr_preserve_samples
    _, sample_mask = asr.fit(data)
                     ^^^^^^^^^^^^^
  File "/home/jinseok/Documents/EEG/lib/python3.12/site-packages/meegkit/asr.py", line 182, in fit
    M, T = asr_calibrate(
           ^^^^^^^^^^^^^^
  File "/home/jinseok/Documents/EEG/lib/python3.12/site-packages/meegkit/asr.py", line 491, in asr_calibrate
    U = block_covariance(X, window=blocksize, overlap=win_overlap,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jinseok/Documents/EEG/lib/python3.12/site-packages/meegkit/utils/covariances.py", line 36, in block_covariance
    from pyriemann.utils.covariance import check_function, cov_est_functions
ImportError: cannot import name 'check_function' from 'pyriemann.utils.covariance' (/home/jinseok/Documents/EEG/lib/python3.12/site-packages/pyriemann/utils/covariance.py)

After updating pyriemann to the recent version (0.7), I did not see the error message. If so, I think it's a safer bet to set the requirement to be pyriemann>=0.7. Just a thought tho ;)

@nbara
Copy link
Owner

nbara commented Feb 11, 2025

Hi @ohspc89 indeed, I will force pyriemann>=0.7 with the next meegkit release

@nbara nbara self-assigned this Feb 11, 2025
@nbara nbara added the dependencies Pull requests that update a dependency file label Feb 11, 2025
@nbara nbara merged commit 6bc9edb into nbara:master Feb 11, 2025
7 checks passed
@nbara
Copy link
Owner

nbara commented Feb 13, 2025

Hi @ohspc89 @MerlinK75 the problem should be solved as part of release 0.1.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ASR.fit error for import '_check_est'

3 participants