Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to visualize #104

Closed
andraderenew opened this issue May 21, 2021 · 12 comments
Closed

how to visualize #104

andraderenew opened this issue May 21, 2021 · 12 comments

Comments

@andraderenew
Copy link

andraderenew commented May 21, 2021

Dear community:
My question goes to how to run the code in eegnb examples with this command "python viz". When I run that I have to change certain things inside the code of course. So I change 'eegnb_examples' for 'local' and 'muse2016' for 'muse2'. Still that doesn't make the trick. What shall I do further on?

File "01r__n170_viz.py", line 63, in
data_dir = eegnb_data_path)
File "/Users/andraderenew/Downloads/eeg-notebooks-master/eegnb/analysis/utils.py", line 163, in load_data
verbose=verbose,
File "/Users/andraderenew/Downloads/eeg-notebooks-master/eegnb/analysis/utils.py", line 84, in load_csv_as_raw
raws = concatenate_raws(raw, verbose=verbose)
File "", line 22, in concatenate_raws
File "/Users/andraderenew/opt/anaconda3/envs/eeg-notebooks/lib/python3.7/site-packages/mne/io/base.py", line 2465, in concatenate_raws
raws[0].append(raws[1:], preload)
IndexError: list index out of range

@JohnGriffiths
Copy link
Collaborator

Hi there.

The problem seems to be that the script is not finding any recording files.

Are you wanting to run this on the eegnb example dataset or on your own recordings?

In either case, check that the file path being generated at the start of the script is indeed pointing to a folder with .csv files in on your Machine.

@andraderenew
Copy link
Author

I want to run this on a file being recorded with eegnb although I don't know how to check the path is the correct one. Shall I print?

@andraderenew
Copy link
Author

andraderenew commented May 22, 2021

the issue for me here is that I can check tht output of these two lines by printing

eegnb_data_path = os.path.join(os.path.expanduser('~/'),'.eegnb', 'data')
n170_data_path = os.path.join(eegnb_data_path, 'visual-N170', 'local')

but not of this line

raw = load_data(subject,session,
                experiment='visual-N170', site='eegnb_examples', device_name='muse2',
                data_dir = eegnb_data_path)

this is something I don't know how it reads inside.

I attach the code I changed

eegnb_data_path = os.path.join(os.path.expanduser('~/'),'.eegnb', 'data')
n170_data_path = os.path.join(eegnb_data_path, 'visual-N170', 'local')

# If dataset hasn't been downloaded yet, download it
if not os.path.isdir(n170_data_path):
    fetch_dataset(data_dir=eegnb_data_path, experiment='visual-N170', site='eegnb_examples');

subject = 1
session = 1
raw = load_data(subject,session,
                experiment='visual-N170', site='eegnb_examples', device_name='muse2',
                data_dir = eegnb_data_path)

I don't know if I have to change 'eegnb_examples' to 'local'

@andraderenew
Copy link
Author

andraderenew commented May 22, 2021

I have tried with python console and I used local as well and nothing seems to work. It says it expects 6 arguments and saw 6.

raw = load_data(subject, session, experiment='visual-N170',site='local',device_name='muse2', data_dir='~/.eegnb/data/')

raw = load_csv_as_raw('/Users/andraderenew/.eegnb/data/visual-N170/local/muse2/subject0001/session001/recording_2021-05-21-08.15.41.csv')
Traceback (most recent call last):
File "", line 1, in
NameError: name 'load_csv_as_raw' is not defined
raw = load_data(subject, session, experiment='visual-N170', site='local', device_name='muse2', data_dir='~/.eegnb/data/')
['TP9', 'AF7', 'AF8', 'TP10', 'Right AUX', 'stim']
['TP9', 'AF7', 'AF8', 'TP10', 'Right AUX', 'stim']
Creating RawArray with float64 data, n_channels=6, n_times=12
Range : 0 ... 11 = 0.000 ... 0.043 secs
Ready.
Traceback (most recent call last):
File "", line 1, in
File "/Users/andraderenew/Downloads/eeg-notebooks-master/eegnb/analysis/utils.py", line 163, in load_data
verbose=verbose,
File "/Users/andraderenew/Downloads/eeg-notebooks-master/eegnb/analysis/utils.py", line 62, in load_csv_as_raw
data = pd.read_csv(fn)
File "/Users/andraderenew/opt/anaconda3/envs/eeg-notebooks/lib/python3.7/site-packages/pandas/io/parsers.py", line 688, in read_csv
return _read(filepath_or_buffer, kwds)
File "/Users/andraderenew/opt/anaconda3/envs/eeg-notebooks/lib/python3.7/site-packages/pandas/io/parsers.py", line 460, in _read
data = parser.read(nrows)
File "/Users/andraderenew/opt/anaconda3/envs/eeg-notebooks/lib/python3.7/site-packages/pandas/io/parsers.py", line 1198, in read
ret = self._engine.read(nrows)
File "/Users/andraderenew/opt/anaconda3/envs/eeg-notebooks/lib/python3.7/site-packages/pandas/io/parsers.py", line 2157, in read
data = self._reader.read(nrows)
File "pandas/_libs/parsers.pyx", line 847, in pandas._libs.parsers.TextReader.read
File "pandas/_libs/parsers.pyx", line 862, in pandas._libs.parsers.TextReader._read_low_memory
File "pandas/_libs/parsers.pyx", line 918, in pandas._libs.parsers.TextReader._read_rows
File "pandas/_libs/parsers.pyx", line 905, in pandas._libs.parsers.TextReader._tokenize_rows
File "pandas/_libs/parsers.pyx", line 2042, in pandas._libs.parsers.raise_parser_error
pandas.errors.ParserError: Error tokenizing data. C error: Expected 6 fields in line 14, saw 7

@oreHGA
Copy link
Collaborator

oreHGA commented Jun 18, 2021

Error tokenizing data. C error: Expected 6 fields in line 14, saw 7

Hi @andraderenew, reading through the parser error, I think this may be from the recorded .csv file... can you check the content of the .csv file on like 14 and see how many entries you have?

@ErikBjare
Copy link
Collaborator

ErikBjare commented Jun 18, 2021

@oreHGA The reason is probably due to an unmarked Markers column which starts outputting data at the 15th sample, see: #108

@andraderenew
Copy link
Author

I added 14 zeros(which I figured is what could fix this correct me if I'm wrong) and now I have this error

Traceback (most recent call last):
File "01r__n170_viz.py", line 61, in
raw = load_data(subject,session,
File "/Users/andraderenew/eeg-notebooks/eegnb/analysis/utils.py", line 157, in load_data
return load_csv_as_raw(
File "/Users/andraderenew/eeg-notebooks/eegnb/analysis/utils.py", line 84, in load_csv_as_raw
raws = concatenate_raws(raw, verbose=verbose)
File "", line 22, in concatenate_raws
File "/Users/andraderenew/opt/anaconda3/lib/python3.8/site-packages/mne/io/base.py", line 2213, in concatenate_raws
raws[0].append(raws[1:], preload)
IndexError: list index out of range

@ErikBjare
Copy link
Collaborator

ErikBjare commented Jun 20, 2021 via email

@andraderenew
Copy link
Author

sorry I didn't know, so now I did add it but I still have this error.

(eeg-notebooks) andraderenew@Renes-MacBook-Air visual_n170 % python viz
Traceback (most recent call last):
File "01r__n170_viz.py", line 63, in
data_dir = eegnb_data_path)
File "/Users/andraderenew/eeg-notebooks/eegnb/analysis/utils.py", line 163, in load_data
verbose=verbose,
File "/Users/andraderenew/eeg-notebooks/eegnb/analysis/utils.py", line 84, in load_csv_as_raw
raws = concatenate_raws(raw, verbose=verbose)
File "", line 22, in concatenate_raws
File "/Users/andraderenew/opt/anaconda3/envs/eeg-notebooks/lib/python3.7/site-packages/mne/io/base.py", line 2465, in concatenate_raws
raws[0].append(raws[1:], preload)
IndexError: list index out of range

@oreHGA
Copy link
Collaborator

oreHGA commented Jul 2, 2021

Hi @andraderenew:

This error is pointing toward the file path not being specified correctly when load_data() is called.

Couple questions here:

  • What OS are you using?
  • Where does your recorded file live, by default it should be in the ~/.eegnb/ directory. Can you confirm you have recording files present in this directory?

image

Be sure that you have folders "subject0001" and "session001" in the data directory... this is what the subject and session value point to in the code below

  • Can you share a screenshot what your recording file looks like? (it helps if we're able to see the first 30 columns at least)

Finally in your code snippet for loading the data, can you ensure it looks like this & give it another run:

eegnb_data_path = os.path.join(os.path.expanduser('~/'),'.eegnb', 'data')
n170_data_path = os.path.join(eegnb_data_path, 'visual-N170', 'local')

# If dataset hasn't been downloaded yet, download it
if not os.path.isdir(n170_data_path):
    fetch_dataset(data_dir=eegnb_data_path, experiment='visual-N170', site='eegnb_examples');

subject = 1
session = 1
raw = load_data(subject,session,
                experiment='visual-N170', site='local', device_name='muse2',
                data_dir = eegnb_data_path)

@andraderenew
Copy link
Author

andraderenew commented Jul 24, 2021 via email

@oreHGA
Copy link
Collaborator

oreHGA commented May 4, 2023

Closing due to inactivity, let us know if you're still running into issues.

@oreHGA oreHGA closed this as completed May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants