Mean of varying range in a 604803x3 array

3 views (last 30 days)
Hi, I am trying to classify an EEG signal from Graz data set b, which consists of a 604803x3 array to define the data. Every row represents EEG signal along time, while every column represents a channel (three relevant channel in total). I've extracted the various features I need for classification, however, I am having trouble reorganizing the data.
One of the features I have extracted is the Bandpower Estimate for two frequency ranges, which gives me two 604803x3 matrices of the bandpower at each time point for all three channels. I have another column vector called HDR.TRIG that contains the relevant time points I needs (120 in total). What I want to do is calculate the mean of bandpower at each HDR.TRIG for a range defined by sampling rate*time, per channel, to produce a 120x3 matrix.
I've done the following to produce a 120x3 matrix, but I am absolutely positive that this is wrong since there is no separability for classification, when there should be.
%%Data Restructuring
StRate = HDR.SampleRate*0.5;
EnRate = HDR.SampleRate*2.5;
for i = 1:length(HDR.TRIG)
T = HDR.TRIG(i,1);
% BPE for 10-12 Hz for each channel
for ch = 1:3
BPE1(i,ch) = mean(BPEsensor((T+StRate):(T+EnRate),ch));
end
% BPE for 16-24 Hz for each channel
for ch = 4:6
BPE2(i,ch-3) = mean(BPEsensor((T+StRate):(T+EnRate),ch));
end
end
The parameters are as such:
  1. BPEsensor --> 604803x6 matrix containing BPE1 in columns 1:3 and BPE2 in columns 4:6
  2. BPE1 --> Contains bandpower from a certain frequency range
  3. BPE2 --> Contains bandpower from another range.
Essentially, I want BPE1 and BPE2 to be 120x3 matrices each containing data for each bandpower. I've been attempting this problem for a very long time and am on the verge of giving up. Any guidance to point me in the right direction would be very much appreciated.
  1 Comment
Siddhartha Dhiman
Siddhartha Dhiman on 28 Apr 2017
Edited: per isakson on 28 Apr 2017
The other method I've tried is:
for i = 1:length(HDR.TRIG)
T = HDR.TRIG(i,1);
% BPE for 10-12 Hz for each channel
for ch = 1:3
BPE1(i,ch) = mean2(reshape(BPEsensor((T+StRate):(T+EnRate),ch),3,[]));
end
%
% BPE for 16-24 Hz for each channel
for ch = 4:6
BPE2(i,ch-3) = mean2(reshape(BPEsensor((T+StRate):(T+EnRate),ch),3,[]));
end
end
This yield the same results as the previous one, so I am not really sure now if I have done the right thing previously, or whether both these methods are wrong.

Sign in to comment.

Accepted Answer

Will Nitsch
Will Nitsch on 3 May 2017
While I can't speak to the separability of your data, I can tell you that your first method for calculating the mean value over a range of data in your [604803 x 3] array is correct.
For example:
A = [1:1000; 1001:2000; 2001:3000];
all(A(1,:) == 1:1000)==1 % This is true
all(A(2,:) == 1001:2000)==1 % also true
all(A(3,:) == 2001:3000)==1 % also true
So, if we just calculate the means individually to prove:
mean(1:1000)
ans = 500.5
mean(1001:2000)
ans = 1.5005e+03
mean(2001:3000)
ans = 2.5005e+03
mean(A(1,:))
ans = 500.5
mean(A(2,:))
ans = 1.5005e+03
mean(A(3,:))
ans = 2.5005e+03
Or you could simply get all 3 by transposing A upon input like so:
mean(A')
ans =
1.0e+03 *
0.5005 1.5005 2.5005
  1 Comment
Siddhartha Dhiman
Siddhartha Dhiman on 3 May 2017
Thanks for the verification. I decided to use the second method involving reshape because I can visualize it better and know exactly what it's doing.
I reshaped my range of data into a row vector and took the mean. It eliminates the use of 'dim', which might confuse some.

Sign in to comment.

More Answers (0)

Categories

Find more on EEG/MEG/ECoG in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!