-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotbesa.m
More file actions
69 lines (58 loc) · 3.68 KB
/
plotbesa.m
File metadata and controls
69 lines (58 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
userdirectory = uigetdir; %gets user's dir for samples to avg
%userdirectory = 'C:\Users\yatri\Desktop\testsamples'; %REMOVE HC LATER!
cd(userdirectory) %chngs directory to the user's specified directory
Files = dir('*.mul*'); %finds all files w/ .mul file extension
Sample = struct; %creates a struct that will hold all sample data
delimiterIn = ' '; %defines what character is b/w each element
headerlinesIn = 2; %defines # of headerlines (which are rows of the file)
for k = 1:length(Files) %go through all files in dir
AddFile = Files(k).name; %add a file to struct called "Files" holding all files
A = importdata(Files(k).name,delimiterIn,headerlinesIn); %create temporary struct to transfer data
Sample(k).data = A.data; %transfer data to the kth sample
Sample(k).textdata = A.textdata; %transfer textdata to kth sample
Sample(k).colheaders = A.colheaders; %transfer column headers to kth sample
end
fprintf('\t1: Average & plot F9\n\t2: Average & plot A1\n\t3: Average & plot P9\n\t4: Average & plot Fp1\n\t5: Average & plot F7\n\t6: Average & plot T7\n\t7: Average & plot P7\n\t8: Average & plot O1\n\t9: Average & plot F3\n\t10: Average & plot C3\n\t11: Average & plot P3\n\t12: Average & plot Fpz\n\t13: Average & plot Fz\n\t14: Average & plot Cz\n\t15: Average & plot Pz\n\t16: Average & plot Oz\n\t17: Average & plot F4\n\t18: Average & plot C4\n\t19: Average & plot P4\n\t20: Average & plot Fp2\n\t21: Average & plot F8\n\t22: Average & plot T8\n\t23: Average & plot P8\n\t24: Average & plot O2\n\t25: Average & plot F10\n\t26: Average & plot A2\n\t27: Average & plot P10\n\t28: Average & plot ALL data\n ');
UserChoose = input('What would you like to plot? Please type the number corressponding to your choice: ', 's')
X = str2double(UserChoose); %converts user's input into a number
if X ~= 28 %this loop will plot the specified channel in blue (channels are numbered 1-27)
for h = 1:length(Sample)-1 %go through all samples
ColumnSum = Sample(h).data(:,X) + Sample(h+1).data(:,X); %get the column sum matrix of all samples
end
AvgColumn = ColumnSum/length(Sample);2 %averages the columnsum data by the number of samples added together
t = size(A.data(:,1)); %gets the range of the data
t = t(1); %how many seconds elapse
time = 1:t; %x axis defined as time elapsed from 1-t seconds
plot(time, AvgColumn, 'b'); %plog the Averaged channel against time in blue
hold on %do not erase the plotted channel in case another is to be plotted on it
else end
if X == 28 %if X is 28
for j = 1:length(Sample)-1 %go through all samples
SampleSum = Sample(j).data + Sample(j+1).data;
end
Avgall = SampleSum/length(Sample);
t = size(A.data(:,1));
t = t(1);
time = 1:t;
plot(time,Avgall,'r');
hold on
else end
%fileA = input('What is the name of the file? :', 's'); %gets filename from
%user input
% fileA = '3005_av-export.mul'; %REMOVE THIS HARDCODE LATER!
%
% A = importdata(fileA,delimiterIn,headerlinesIn); %A is an array read in
% coldata = input('What channel would you like to plot?')
% coldataA1 = A.data(:,1); %assigns first column of array A's data
% t = size(A.data(:,1)); %gets size of A to determine time elapsed, returns array
% t = t(1); %assigns t to time elapsed (first element of t array above)
% time = 1:t; %creates instance of time from 1 second to time elapsed
% %plot (time,coldataA1,'r');
% %hold on;
% %fileB = input('What is the name of another file? :', 's');
% fileB = '3009_av-export.mul'; %REMOVE THIS HARDCODE LATER!
% B = importdata(fileB,delimiterIn,headerlinesIn);
% C = (A.data + B.data)/2;
% Avgcoldata = C(:,1);
% plot(time,Avgcoldata,'r');
%