Raw object interprets data incorrectly

Hello,
I have some text files with the EEG signal, let’s take two of them to start with. Inside of them signals stored as 2 columns with many rows. I want to create a raw object from them and when plotting them I want to get 2 EEG channels with the first signal in the first channel and the second signal in the second channel. However, I have encountered a problem that mne takes this data from two files and puts it into the second channel. I read them separately with np.loadtxt, which is supposed to create numpy arrays from them. Then I transposed them, because initially they were received with the form (32000, 2), and I understand that these two values should be put in reverse for mne to make the raw object correctly. So I concatenated them and wrote data.reshape(2, 32000).
To create the raw itself, I write sfreq = 250 based on the experiment data. I initialize ch_names with two values and the same with ch_types.
This method didn’t work, so I resorted to the second method, where I used a loop to read the two files and write them to the dictionary. I would then turn it into a numpy array, use np.stack and again transpose them. This too produced the same result.
I would be very grateful if anyone has any other ideas.

Can you show your code?

Of course, the first piece of code is:
data1 = np.loadtxt(“1_class_new_2.dat”)
data2 = np.loadtxt(“2_class_new_2.dat”)

data11 = data1.T
data22 = data2.T

datacomb = np.concatenate((data11, data22), axis=1)
datacomb1 = datacomb.reshape(2, 649984)

sfreq = 250
ch_names = [‘eeg1’, ‘eeg2’]

info = mne.create_info(ch_names, sfreq=sfreq, ch_types=[‘eeg’] * 2)
raw = mne.io.RawArray(datacomb1, info=info)
raw.plot(scalings={‘eeg’: 20e2}, duration = 2600)

The second one is:
data_list =
for i in range(2):
data_list.append(np.loadtxt(‘{0}_class_new_2.dat’.format(i+1)))

data_list = np.array(data_list)
datamain = np.stack(data_list, axis = 0)
datamain = np.transpose(datamain)
datamain = datamain.reshape(2, 649984)

sfreq = 250

ch_names = [‘eeg1’, ‘eeg2’]
ch_types=[‘eeg’] * 2
n_channels = 2

info = mne.create_info(n_channels, ch_types=ch_types, sfreq=sfreq)
raw = mne.io.RawArray(datamain, info=info)

raw.plot(scalings={‘eeg’: 20e2}, duration = 2600)

This looks alright, but why are you doing datacomb1 = datacomb.reshape(2, 649984)? The concatenated data should already have the correct shape, because you transposed in the previous lines.

Also, why do you think the data is put into the second channel? There is some signal in the first one, although this doesn’t look like EEG.

Can you try creating two separate raw objects just to see if they look correct?

I tried to create separate raws, first file worked, but with the second I got strange error
“TypeError: init() got an unexpected keyword argument ‘data1’”
The code I used:
data = np.loadtxt(“1_class_new_2.dat”)
data = data.T

times = data[0]
values = data[1]
sfreq = 250
info = mne.create_info([‘channel 1’], sfreq=sfreq, ch_types=[‘eeg’])
raw = mne.io.RawArray(data=np.atleast_2d(values), info=info)

raw.plot(scalings={‘eeg’: 20e2}, duration = 2120)


Code for the second one:
data1 = np.loadtxt(“2_class_new_2.dat”)
data1 = data.T

times1 = data1[0]
values1 = data1[1]
sfreq1 = 250

info1 = mne.create_info([‘channel 2’], sfreq=sfreq1, ch_types=[‘eeg’])
raw1 = mne.io.RawArray(data1=np.atleast_2d(values1), info=info1)
raw1.plot(scalings={‘eeg’: 20e2}, duration = 2120)

This must be data=, not data1=.

Hello,
It really worked. Can you tell me why data= should be substituted in raw1? I thought we are working with data1.
And also, I would like to know how to combine these two signals into a single raw, so that they are in different channels. I have other files that need to be used as well

The parameter name is data. Your variable name is data1. To pass your variable to the function, you need to write data=data1. The function doesn’t know any parameter with the name data1.

Thanks, but the last question remains the same: is there any way to somehow merge multiple raws into one, so that the first signal is in the first channel, etc. So that we can then place events and further process the whole data, rather than working with only one of the channels in the end.
The mne.io.concatenate_raws doesn’t work in the same sense I have in mind either.