Giter VIP home page Giter VIP logo

diamond's People

Watchers

 avatar

diamond's Issues

dataClean

%% Setup
% Standard housekeeping
clear ;
close all;
clc;
% variable defination
Im_time = 5;
Relax_time = 4.5;
Sample_Fq = 500;
% Load EEG data
addpath('D:\bci');
Data = load('20180711172122_20180703_MI Cui07.easy');
Data1 = load('20180712100507_20180703_MI Cui07.easy');
% Find all the flagged data ind
Flag1 = find(Data(:,9) == 1 );
Flag2 = find(Data(:,9) == 2 );
Flag3 = find(Data(:,9) == 3 );
Flag4 = find(Data(:,9) == 4 );

% Flag1 = find(Data(:,9) == 1 & Data(:,9) == 2 & Data(:,9) == 3 & Data(:,9) == 4 );
t1 = length(Flag1);
Data_all = [];
Data_IM_all =[];
Data_Rest_all =[];
for i= 1:t1
% data extraction according to the flag
% grasping1 and relax data
DataSegment1 = Data(Flag1(i) : Flag1(i) + Sample_Fq *Im_time - 1, 1:8);
Rest1 = Data(Flag1(i) + Sample_Fq *Im_time - 1: Flag1(i) + Sample_Fq *Im_time - 1+Sample_Fq *Relax_time, 1:8);

DataSegment2 = Data(Flag2(i) : Flag2(i) + Sample_Fq *Im_time, 1:8);
Rest2 = Data(Flag2(i) + Sample_Fq *Im_time - 1: Flag2(i) + Sample_Fq *Im_time - 1+Sample_Fq *Relax_time, 1:8);

DataSegment3 = Data(Flag3(i) : Flag3(i) + Sample_Fq *Im_time, 1:8);
Rest3 = Data(Flag3(i) + Sample_Fq *Im_time - 1: Flag3(i) + Sample_Fq *Im_time - 1+Sample_Fq *Relax_time, 1:8);

DataSegment4 = Data(Flag4(i) : Flag4(i) + Sample_Fq *Im_time, 1:8);
Rest4 = Data(Flag4(i) + Sample_Fq *Im_time - 1: Flag4(i) + Sample_Fq *Im_time - 1+Sample_Fq *Relax_time, 1:8);

Data_IM = [DataSegment1;DataSegment2;DataSegment3;DataSegment4];
Data_Rest = [Rest1;Rest2;Rest3;Rest4];

Data_IM_all = [Data_IM_all;Data_IM ];
Data_Rest_all =[Data_Rest_all;Data_Rest];
end
%% ClassLabel
% class0 = rest and class1 = motory imagination
class0 = 0;
class1 = 1;

add_0 = zeros(length(Data_IM_all),1);
add_1 = ones(length(Data_IM_all),1);

imLabel= [Data_IM_all,add_1];
reLabel= [Data_IM_all,add_0];

allLabel = [imLabel;reLabel];

%% remove first 0.5 sencond and last 0.5 second data of imaganery
re1 = Sample_Fq0.5;
re2 = Sample_Fq
0.5;
t2 = length(Flag1);
matrixRe0=[];
for i=1:t2
matrixRe= imLabel(i*(0.5Sample_Fq)+1:i(4*Sample_Fq),:);
matrixRe0=[matrixRe0;matrixRe];
end

%% plot(DataSegment);
% % Visualise data
% figure;
% plot(Data(:,1:8)); hold on
% xlabel('Time (unit samples)');
% title('All channels');
% legend("Fz","C3","Cz","C4","P3","Pz","P4","Oz");
% % ylim([-1 5]);
%
% % % class labels for all data
% % classLabels = [windowInfo(idx1,3); windowInfo(idx2,3); windowInfo(idx3,3)];
% %% Feature Extraction
% % obtain mean absolute value
% % number of data windows
% numWindows = size(Data, 1);
%
% % number of channels
% numChannels = size(Data,2);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.