Replicating the online charts
Posted: Thu Sep 26, 2019 8:08 am
by jeyem
Hi James,
I am trying to replicate the online charts using MATLAB. Would you mind sharing your processing pipeline? For example, I don't understand how you scale the brain waves from a range of [0, 2.x?] to your y-scale. Also I am not 100% sure, how you interpolate missing data.
Thanks for the app!
jeyem
Re: Replicating the online charts
Posted: Thu Sep 26, 2019 8:16 am
by James
The absolute scaling from ~{-1:+1} to ~{0:100} is (x+1)*50.
I'm not sure what you mean about missing data. For the X location, each bit of data has a timestamp and the timestamp is positioned correctly based on it's date and time.
Re: Replicating the online charts
Posted: Thu Sep 26, 2019 8:32 am
by jeyem
thanks for your reply about the scaling. this was helpful. missing data is meant where HeadBandOn = 0 (contact with the muse was lost). I just deleted these points and interpolated the data. looks like your online chart now. thank you. =)
% SELECT DATA
[FileName,PathName,FilterIndex] = uigetfile('.csv','Select an EEG Data File','C:\');
filename = horzcat(PathName,FileName);
[TimeStamp,Delta_TP9,Delta_AF7,Delta_AF8,Delta_TP10,Theta_TP9,Theta_AF7,Theta_AF8,Theta_TP10,Alpha_TP9,Alpha_AF7,Alpha_AF8,Alpha_TP10,Beta_TP9,Beta_AF7,Beta_AF8,Beta_TP10,Gamma_TP9,Gamma_AF7,Gamma_AF8,Gamma_TP10,RAW_TP9,RAW_AF7,RAW_AF8,RAW_TP10,AUX_RIGHT,Accelerometer_X,Accelerometer_Y,Accelerometer_Z,Gyro_X,Gyro_Y,Gyro_Z,HeadBandOn,HSI_TP9,HSI_AF7,HSI_AF8,HSI_TP10,Battery,Elements] = textread(filename,'%s%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%s','delimiter',',','headerlines',1);
time = datevec(TimeStamp); % make a double
time = (time(:,6) + time(:,5)*60 + time(:,4)*60*60)*1000; % convert to msec
time = time - time(1); % relative to the beginning of the recording
Delta = (Delta_TP9+Delta_AF7+Delta_AF8+Delta_TP10)/4;
Theta = (Theta_TP9+Theta_AF7+Theta_AF8+Theta_TP10)/4;
Alpha = (Alpha_TP9+Alpha_AF7+Alpha_AF8+Alpha_TP10)/4;
Beta = (Beta_TP9+Beta_AF7+Beta_AF8+Beta_TP10)/4;
Gamma = (Gamma_TP9+Gamma_AF7+Gamma_AF8+Gamma_TP10)/4;
AlphaH = Alpha(HeadBandOn~=0);
BetaH = Beta(HeadBandOn~=0);
GammaH = Gamma(HeadBandOn~=0);
DeltaH = Delta(HeadBandOn~=0);
ThetaH = Theta(HeadBandOn~=0);
timeH = time(HeadBandOn~=0);
AlphaI = interp1(timeH,AlphaH,1:timeH(end),'linear','extrap'); % interpolate to msecs
BetaI = interp1(timeH,BetaH,1:timeH(end),'linear','extrap'); % interpolate to msecs
GammaI = interp1(timeH,GammaH,1:timeH(end),'linear','extrap'); % interpolate to msecs
DeltaI = interp1(timeH,DeltaH,1:timeH(end),'linear','extrap'); % interpolate to msecs
ThetaI = interp1(timeH,ThetaH,1:timeH(end),'linear','extrap'); % interpolate to msecs
AlphaD = (AlphaI+1)/0.02;
BetaD = (BetaI+1)/0.02;
GammaD = (GammaI+1)/0.02;
DeltaD = (DeltaI+1)/0.02;
ThetaD = (ThetaI+1)/0.02;
% PLOT DATA
hold on;
plot(AlphaD,'c');
plot(BetaD,'g');
plot(GammaD,'y');
plot(DeltaD,'r');
plot(ThetaD,'b');
title('Muse Monitor - Absolute Brain Waves');
hold off;
Re: Replicating the online charts
Posted: Sun Oct 13, 2019 8:37 am
by benislocated
I wrote a Python version (not based on the above Matlab code) in Jupyter:
https://github.com/bhpayne/meditation_m ... ysis.ipynb