Hi, I am new to the forums and am looking for help importing a single-channel CSV file. I am attaching my code below for reference.
import pandas as pd
import json
import numpy as np
import os
import csv
import mne
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
from bs4 import BeautifulSoup
from urllib.request import urlopen
path="/Users/enthusiastprogrammer/Desktop/Datasets"
os.chdir(path)
data = np.genfromtxt('mydata.csv',delimiter=',')
ch_names = ['CH 1']
sfreq = 300 #Hz
#info = mne.create_info(ch_names=["2"], sfreq=300)
info = mne.create_info(ch_names=ch_names, sfreq=sfreq)
mne.io.RawArray(data, info)
And here’s my error:
ValueError Traceback (most recent call last)
<ipython-input-4-cd2014e5f50c> in <module>
9 #info = mne.create_info(ch_names=["2"], sfreq=300)
10 info = mne.create_info(ch_names=ch_names, sfreq=sfreq)
---> 11 mne.io.RawArray(data, info)
<decorator-gen-192> in __init__(self, data, info, first_samp, copy, verbose)
~/opt/anaconda3/lib/python3.8/site-packages/mne/io/array/array.py in __init__(self, data, info, first_samp, copy, verbose)
60 data = np.asanyarray(orig_data, dtype=dtype)
61 if data.ndim != 2:
---> 62 raise ValueError('Data must be a 2D array of shape (n_channels, '
63 'n_samples), got shape %s' % (data.shape,))
64 if len(data) != len(info['ch_names']):
ValueError: Data must be a 2D array of shape (n_channels, n_samples), got shape (9595,)
Would appreciate if any of you could help ASAP - I scoured the internet and couldn’t find an answer. Thanks so much!
- MNE-Python version: 0.23.4
- operating system: MacOS Big Sur Version 11.6