how can i split or divide a dataset into its different parts (an electroencephalogram [EEG] of 122880 samples into 16 pieces or channels)

5 vues (au cours des 30 derniers jours)
*edit, i corrected a wrong number i wrote*
i already got an answer for how to plot the eeg sample i got from
http://brain.bio.msu.ru/eeg_schizophrenia.htm which is basically 7680 samples for each channel and its 16 channels etc etc etc
but now i need to do a fourier transform and due to the fact that 122880 is not a power of base ^2 it means that doing a fourier transform would lead to the transform of the entire row of 122880 data samples turned into 131072 to be transformed, thus leading to me not being able to use the plotting the 16 channels code properly [i don't have access to the computer where i have the matlab code but instead of looking like the 16 channels one above the other, it looks like a snake line that goes up right up right up right etc etc etc]
sooooooo what i mean to ask is if there is a way to divide or split the data in 16 parts and do the fourier transform in those 16 parts and then plot those parts (in any way like via division or separation after a limit etc), i mainly need the divide and transforming, the plotting i will be able to manage if that isn't answered
thank you all in advance for reading my question

Réponses (1)

Kanishk
Kanishk le 7 Oct 2024
Modifié(e) : Kanishk le 8 Oct 2024
Hi @Ri go,
I understand you want to perform a Fourier transform on the EEG signal.
In MATLAB, the fft’ function do not require input to be a power of 2. So, you can directly use the function on 7680 samples.
To divide the signal into 16 channels, use the reshape function. 'reshape’ function is used to rearrange the elements of an array into a new array with a specified number of rows and columns.
dt = readmatrix('eeg_data.txt');
dt = reshape(dt, [], 16);
Now each column of ‘dt’ represents a channel. Perform the Fourier transform on the reshaped data to and plot the frequencies.
y = fft(dt)
for i=1:16
figure
plot(abs(y(:,i)));
end
To learn more about ‘reshape’ and ‘fft, please go through the following official MATLAB documentation:
Thanks
  3 commentaires
Kanishk
Kanishk le 8 Oct 2024
The 'plot' function is overwriting the previous plot. Use 'figure' to generate a new figure window at every loop iteration.
dt = readmatrix('eeg_data.txt');
dt = reshape(dt, [], 16);
y = fft(dt);
for i=1:16
figure
plot(abs(y(:,i)));
end
Ri go
Ri go le 9 Oct 2024
ohhhhh it does work, though the different windows would be troublesome since it would make it difficult to compare each one, though thank you so much so far for helping me with
another thing i continued to tinker around and see how to work with differen pieces of code
and then i found out how to make it work with the other code i was given before and it somehow worked and now i can compare it
but here is my last question, what does
data_plot = reshape (data, [], n_channels)./max(abs(data), [], 'all')+(1:n_channels);
do that makes it so that i can graph and make it look like multichannel graphic?
i can't find anywhere what does the "./max(abs(data), [], 'all')+(1:n_channels)" is for or how it modifies it
hope i am not being much of a bother, and still thank you so much for putting up with me

Connectez-vous pour commenter.

Catégories

En savoir plus sur EEG/MEG/ECoG dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by