Error message for Beginning Tutorial

  • MNE-Python version: 3.7.2
  • operating system: Mac OS 11.2.2

I am a new user trying to learn MNE via the tutorials. On the beginning tutorial, “Overview of MEG/EEG Analysis with MNE-Python”, I am not able to make it very far by following the given instructions. The first line of code given executes well, but the second line of code given (“sample_data_raw_file = os.path.join(sample_data_folder, ‘MEG’, ‘sample’, ‘sample_audvis_filt-0-40_raw.fif’)” ) produces the error “TypeError: expected str, bytes or os.PathLike object, not module”.

Hello Thimo,
good that you ask directly, something like that shouldn’t prevent you from learning MNE-Python :slightly_smiling_face:. Do you use exactly the code provided?
Maybe you can try downloading the script at the bottom of the page and run it from the terminal with

python 10_overview.py

(being in the directory where you downloaded it and having activated your mne-conda-environment) just to see if it works then.
I could reproduce this error for example when I put

sample_data_folder = mne.datasets.sample

instead of

sample_data_folder = mne.datasets.sample.data_path()

Martin,

Thank you so much for your reply. Yes, I used the code exactly as provided. I tried both with “.sample” at the end as well as with “.sample.data_path()”. I also tried downloading the dataset directly from OpenNeuro using Node.js, putting the folder in the same directory I am using for MNE-Python, and naming the folder “sample”.

I will try downloading the script at the bottom of the page as you suggest.

Thank you again for your help!

Hey Thimo,
sure, you’re welcome:).
Leaving out .data_path() was just an example for trying to understand where your original Error-Message came from.
Going from the error-message you provided there was a module-object inside of os.path.join() where we would expect a string-object instead.
The sample-data is usually stored and loaded from a folder “mne_data” inside your home-directory. That is maybe not the same directory you use for MNE-Python.
You can check the location of your sample-data with

import mne
mne.get_config('MNE_DATASETS_SAMPLE_PATH')

The first time you run mne.datasets.sample.data_path() when there is no data at this location, the dataset should be downloaded automatically.
You can also insert a path into mne.datasets.sample.data_path() when you want your sample-data to be stored there.