alexenge / intro-to-eeg

Introduction to EEG analysis course using MNE-Python
https://alexenge.github.io/intro-to-eeg/
Creative Commons Attribution 4.0 International
4 stars 0 forks source link

Issue on page /ipynb/6-statistics.html #1

Open jhidalgoch opened 4 weeks ago

jhidalgoch commented 4 weeks ago

I ran into some issues with this introduction to EEG analysis using Python. Please note that I am a beginner in programming. The most relevant issue I faced was the use of this commands in the sixth module.

**%%R -i trials_ave

t.test(N170 ~ condition, data = trials_ave, paired = TRUE)**

I repeatedly obtain the same attribute error warning: 'DataFrame' object has no attribute 'iteritems'. I already tried using both Gemini and ChatGPT to solve the problem, but I haven't been able yo solve or pinpoint the specific issue.

Another error that I could not solve happened in the fourth module, where I tried epoching the N400 database but I repeatedly obtain the same error: No matching events found for prime_related (event id 1) . The weird thing is that the event ID 1 was indeed present in my events array and data. I also tried using AI assistance, but the different solutions suggested did not work. At one point even Gemini wrote "I am sorry, I cannot help you with this issue".

alexenge commented 3 weeks ago

Thanks a lot for your interest in the course and for reporting these issues!

Regarding AttributeError: 'DataFrame' object has no attribute 'iteritems':

I can replicate this error on Google Colab. It seems to be a bug in the compatibility between the rpy2 package (allowing access to R from Python) and the pandas package (providing support for data frames in Python). I've noticed that Colab has a very old version of rpy2 installed and a relatively new version of pandas, causing the error. However, simply upgrading rpy2 (using %pip install --upgrade rpy2) doesn't seem to do the trick as it leads to a different error (``).

I'll let you know once I find a solution for this. Until then, it's probably best to simply save the data frame as a tabular file (.csv, Excel or the like) and import it manually into R to run the statistics. Alternatively, you could stay in Python and try the statsmodels, which provides all the statistical tests described in the notebook ($t$-tests, ANOVAs, and linear mixed models).

Regarding your problem in the epoching module:

Getting the events and event_id right is indeed the trickiest bit of the course and very particular to each dataset and ERP component. So it might not be super simple to use the N170 code for the N400 experiment. My first try would always be to run:

events, event_id = events_from_annotations(raw)

And then inspect the events and event_id objects. For most components, the event_id is already fine as there is already one unique event number for each condition of interest. For some components, you will need to merge multiple event numbers because they belong to the same condition (as is the case for the N170).

Do you maybe want to share what you've tried so far to construct your events and event_id? Then I could try to help you more specifically. Alternatively, I can also provide you a full solution for how I would construct the events for the N400.

Good luck and looking forward to your update!