-
Notifications
You must be signed in to change notification settings - Fork 0
/
spm_acfjc_spectral_entropy_spectrum_day.m
846 lines (602 loc) · 21.3 KB
/
spm_acfjc_spectral_entropy_spectrum_day.m
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
function spm_acfjc_spectral_entropy_spectrum_day
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Author: %%
%%% Aldo Camargo %%
%%% University of Liege (Belgium) %%
%%% [email protected] %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Paper: "Actigraphy assessments of circardian sleep-wake
%% cycles in the Vegetative and Minimally Conscious States"
%%
close all, clear all, clc
% Step 1: Reading and loading the file
file = spm_select(Inf, '.+\.AWD$', 'Select files ',...
[], [], '.AWD'); %Show all .AWD files in the directory datadir
[pathstr_ses,name_ses,ext_ses] = fileparts(file);
resolution = 1; % resolution of the epocs is one minute
% Step 1.1: Setting init values for the computation
graph_mean_day_spectral_entropy = true;
graph_mean_day_spectral_entropy_morning = true;
% Step 2: Setting the number of days of analysis
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Number of days to analysis %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nday_analysis = 5;
isub = 1;
%---------------------------------------------
% Step 2: Loading the data into the variable acti
disp([' Reading file : ' num2str(file)]);
eval(['logfile = readcoglog(file);']);% uses 'readcoglog' to transfrom raw data in a usable format
acti = [];
for hh = 8:size(logfile,1)%the 8 first lines are not data movement data
acti(hh,1) = str2num(strvcat(cellstr(logfile{hh}(1))));%to chane cell array into number
end
start_date =strvcat(cellstr(logfile{2}(1)));
start_hour =strvcat(cellstr(logfile{3}(1)));
temp_start_hour = strsplit(start_hour,':');
int_start_hour = str2num(strvcat(temp_start_hour(1)));
int_start_min = str2num(strvcat(temp_start_hour(2)));
factor = 1440/resolution;
nbj = floor(size(acti,1)/factor); %to count the total number of full days (24h) of recording
disp([num2str(nbj) ' x 24h enregistr�es']);
timestart = strvcat(cellstr(logfile{3}(1)));% heure du d�but de l'enregistrement
heure= str2num(timestart(1:2));
min = str2num(timestart(4:5));
[n_days_recorded, nnn] = size(acti);
factor_conv_time = resolution/(60*24);
n_days_recorded = n_days_recorded*factor_conv_time
if(n_days_recorded < 5)
fprintf(1,'\n The number of days is less than 5 days ... Sorry... :( ... \n',n_days_recorded )
return;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% %%
%%% Step 3: Removing the first 2 hours of data of the first day %%
%%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tf_delete = 2*60/resolution;
acti_days{1}(1:tf_delete) = 0;
acti(1:tf_delete) = 0;
%%%
% Step 4: Computing the Mesor, ampitudem and Acrophase of the first 4 days
%fprintf(1,'\n Computing the Messor, Amplitude and Acrophase of the %g days: ... \n', nday_analysis);
%
nday_analysis
size_tt = 24*60*nday_analysis/resolution;
y_tt = acti(1:resolution:size_tt);
t_tt = 1:resolution:size_tt;
t_tt = t_tt';
t_tt = t_tt./max(t_tt);
w = 2*pi;
alpha = .05; % 5%
factor_angle = 180/pi; % to convert radians to degrees
%[M_tt,Amp_tt,phi_tt,p_value_tt] = cosinor(t_tt,y_tt,w,alpha,false);
% disp('-------------------------------------------');
% fprintf(1,'\n Results for the first %g days \n', nday_analysis);
% disp('-------------------------------------------');
%
%
% fprintf(1,'Messor: = %g \n', M_tt);
% fprintf(1,'Amplitude: = %g \n', Amp_tt);
% fprintf(1,'Acrophase (degrees): = %g \n', (factor_angle)*phi_tt);
% fprintf(1,'p-value: = %g \n', p_value_tt);
% disp('-------------------------------------------');
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Step 4: Graphics of the data (first 4 days) %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
init_data_time = int_start_hour*60 + int_start_min;
day_t4 = 24*60*4;
tt_4 = 1:resolution:day_t4;
yy_4 = acti(1:resolution:day_t4);
% figure,
% subplot(1,2,1); plot(tt_4, yy_4); title('Day 1 to Day 4');
% day 1%
% considering that all the values start on different hours and mins
day_1 = (24*60*1 - init_data_time ) + 1;
t_1 = 1:resolution:day_1;
y_1 = acti(1:resolution:day_1);
y_1_median = medfilt1(y_1);
%figure,
%subplot(3,2,2); plot(t_1, y_1); title('Day 1');
% Finding morning and night information
init_day = 8;
end_day = 20;
if (int_start_hour > init_day && int_start_hour < end_day )
day_1_morning = end_day*60 - init_data_time;
day_1_night = day_1 - day_1_morning;
else
day_1_morning = 0;
day_1_night = day_1 - day_1_morning;
end
if ( day_1_morning > 0 )
t1_morning = 1:resolution:day_1_morning;
t1_night = day_1_morning+1:resolution:day_1;
y1_morning = acti(1:resolution:day_1_morning);
y1_night = acti(day_1_morning + 1:resolution:day_1);
% figure,
% subplot(2,1,1); plot(t1_morning, y1_morning);
% subplot(2,1,2); plot(t1_night, y1_night);
else
t1_morning = 0;
y1_morning = [];
y1_night = acti(day_1_morning + 1:resolution:day_1);
% figure,
t1_night = day_1_morning+1:resolution:day_1;
% subplot(2,1,2); plot(t1_night, y1_night);
end
if(t1_morning > 0 )
y1_morning_mean = (sum(y1_morning))/(length(t1_morning));
y1_night_mean = (sum(y1_night))/(length(t1_night));
else
y1_morning_mean = [];
y1_night_mean = [];
end
% day 2 %
day_2 = (24*60*2 - init_data_time ) + 1;
t_2 = (day_1 + 1):resolution:day_2;
y_2 = acti(day_1 + 1:resolution:day_2);
%figure,
%subplot(3,2,3); plot(t_2, y_2); title('Day 2');
% day and night
t2_morning = [];
y2_morning = [];
t2_night = [];
y2_morning = [];
count_morning_2 = 0;
y2_morning_mean = 0;
count_night_2 = 0;
y2_night_mean = 0;
for tt=(day_1 + 1):day_2
if((tt >= day_1 + 8*60) && (tt < day_1 + 20*60))
t2_morning(tt) = tt;
y2_morning(tt) = acti(tt);
t2_night(tt) = tt;
y2_night(tt) = 0;
count_morning_2 = count_morning_2 + 1;
y2_morning_mean = y2_morning_mean + y2_morning(tt);
else
t2_morning(tt) = tt;
y2_morning(tt) = 0;
t2_night(tt) = tt;
y2_night(tt) = acti(tt);
count_night_2 = count_night_2 + 1;
y2_night_mean = y2_night_mean + y2_night(tt);
end
end
y2_morning_mean = y2_morning_mean/count_morning_2;
y2_night_mean = y2_night_mean/count_night_2;
% plotting the day and night information
% t2_morning = (day_1 + 1):resolution:(day_2 - 12*60);
% t2_night = t2_morning:resolution:day_2;
% day 3 %
day_3 = (24*60*3 - init_data_time ) + 1;
t_3 = (day_2 + 1):resolution:day_3;
y_3 = acti(day_2 + 1:resolution:day_3);
% figure,
%subplot(3,2,4); plot(t_3, y_3); title('Day 3');
% day and night
t3_morning = [];
y3_morning = [];
t3_night = [];
y3_morning = [];
count_morning_3 = 0;
y3_morning_mean = 0;
count_night_3 = 0;
y3_night_mean = 0;
for tt=(day_2 + 1):day_3
if((tt >= day_2 + 8*60) && (tt < day_2 + 20*60))
t3_morning(tt) = tt;
y3_morning(tt) = acti(tt);
t3_night(tt) = tt;
y3_night(tt) = 0;
count_morning_3 = count_morning_3 + 1;
y3_morning_mean = y3_morning_mean + y3_morning(tt);
else
t3_morning(tt) = tt;
y3_morning(tt) = 0;
t3_night(tt) = tt;
y3_night(tt) = acti(tt);
count_night_3 = count_night_3 + 1;
y3_night_mean = y3_night_mean + y3_night(tt);
end
end
y3_morning_mean = y3_morning_mean/count_morning_3;
y3_night_mean = y3_night_mean/count_night_3;
% plotting the day and night information
%
% t2_morning =
% day 4 %
day_4 = (24*60*4 - init_data_time ) + 1;
t_4 = (day_3 + 1):resolution:day_4;
y_4 = acti(day_3 + 1:resolution:day_4);
% day 5 %
day_5 = (24*60*5 - init_data_time ) + 1;
t_5 = (day_4 + 1):resolution:day_5;
y_5 = acti(day_4 + 1:resolution:day_5);
%figure,
%subplot(3,2,5); plot(t_4, y_4); title('Day 4');
% day and night
t4_morning = [];
y4_morning = [];
t4_night = [];
y4_morning = [];
count_morning_4 = 0;
y4_morning_mean = 0;
count_night_4 = 0;
y4_night_mean = 0;
for tt4=(day_3 + 1):day_4
if((tt4 >= day_3 + 8*60) && (tt4 < day_3 + 20*60))
t4_morning(tt4) = tt4;
y4_morning(tt4) = acti(tt4);
t4_night(tt4) = tt4;
y4_night(tt4) = 0;
count_morning_4 = count_morning_4 + 1;
y4_morning_mean = y4_morning_mean + y4_morning(tt4);
else
t4_morning(tt4) = tt4;
y4_morning(tt4) = 0;
t4_night(tt4) = tt4;
y4_night(tt4) = acti(tt4);
count_night_4 = count_night_4 + 1;
y4_night_mean = y4_night_mean + y4_night(tt4);
end
end
y4_morning_mean = y4_morning_mean/count_morning_4;
y4_night_mean = y4_night_mean/count_night_4;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% A more practical way to get the day and night information %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We will take only information since day 2 %
% init_day
% end_day
% resolution
factor_day = 60/resolution;
% y_2_day = y_2(init_day*factor_day:end_day*factor_day-1);
% y_3_day = y_3(init_day*factor_day:end_day*factor_day-1);
% y_4_day = y_4(init_day*factor_day:end_day*factor_day-1);
% y_5_day = y_5(init_day*factor_day:end_day*factor_day-1);
% y_5_night =[ y_5(1:init_day*factor_day-1); y_5(end_day*factor_day:1440)];
time_index = [1:1440]; % because the resolution is 1 min
indx_time_day = find((time_index >= init_day*factor_day) & (time_index < end_day*factor_day));
indx_time_night = find((time_index < init_day*factor_day) | (time_index >= end_day*factor_day));
y_2_day_find = zeros(1,1440);% because the resolution is 1 min
y_2_day_find(indx_time_day) = y_2(indx_time_day);
y_2_night_find = zeros(1,1440);
y_2_night_find(indx_time_night) = y_2(indx_time_night);
y_3_day_find = zeros(1,1440);% because the resolution is 1 min
y_3_day_find(indx_time_day) = y_3(indx_time_day);
y_3_night_find = zeros(1,1440);
y_3_night_find(indx_time_night) = y_3(indx_time_night);
y_4_day_find = zeros(1,1440);% because the resolution is 1 min
y_4_day_find(indx_time_day) = y_4(indx_time_day);
y_4_night_find = zeros(1,1440);
y_4_night_find(indx_time_night) = y_4(indx_time_night);
y_5_day_find = zeros(1,1440);% because the resolution is 1 min
y_5_day_find(indx_time_day) = y_5(indx_time_day);
y_5_night_find = zeros(1,1440);
y_5_night_find(indx_time_night) = y_5(indx_time_night);
%%%%
% This code test if the code is correct to get the day and night
% information
% mean(y_3_day)
% mean(y_3(indx_time_day))
% mean(y_5_day)
% mean(y_5(indx_time_day))
% mean(y_5_night)
% mean(y_5(indx_time_night))
% figure
% subplot(3,1,1), plot(time_index, y_5);
% subplot(3,1,2), plot(time_index, y_5_day_find);
% subplot(3,1,3), plot(time_index, y_5_night_find);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% Computing the mean for every day %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if(graph_mean_day_spectral_entropy)
temp = [ y_2'; y_3'; y_4'; y_5'];
y_mean = zeros(1,1440); % Because the epochs are on 1 min interval and is for 24 hours
y_mean_day = zeros(1,1440); % Because the epochs are on 1 min interval and is for 24 hours
y_mean_night = zeros(1,1440); % Because the epochs are on 1 min interval and is for 24 hours
for i=1:1440 % Because the epochs are on 1 min interval and is for 24 hours
y_mean(i) = mean([y_2(i) y_3(i) y_4(i) y_5(i)]);
y_mean_day(i) = mean([y_2_day_find(i) y_3_day_find(i) y_4_day_find(i) y_5_day_find(i)]);
y_mean_night(i) = mean([y_2_night_find(i) y_3_night_find(i) y_4_night_find(i) y_5_night_find(i)]);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Creating the chunk of data %%%
%%% %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Chunks every k min %%%
k = 120; %%%% 120 min = 2 h
% for day 2
% y2_total = y2_morning + y2_night;
% t2_total = t2_morning + t2_night;
% figure,
% subplot(2,2,1), plot(t2_total, y2_total);
% subplot(2,2,2), plot(t2_morning, y2_morning);
% subplot(2,2,3), plot(t2_night, y2_night);
% subplot(2,2,4), plot(t_2, y_2);
number_of_chunks = 24*60/k;
number_of_chunks_day = 12*60/k;
number_of_chunks_night = 12*60/k;
L_y2 = length(y_2); % because epocs of 1 min
j = 1;
for i=1:k:L_y2
y2_chunk{j} = y_2(i:i+k-1);
j = j + 1;
end
L_y3 = length(y_3); % because epocs of 1 min
j = 1;
for i=1:k:L_y2
y3_chunk{j} = y_3(i:i+k-1);
j = j + 1;
end
L_y4 = length(y_4); % because epocs of 1 min
j = 1;
for i=1:k:L_y2
y4_chunk{j} = y_4(i:i+k-1);
j = j + 1;
end
% I am considering day 5 because the first day is not considered. The
% reason is that day 1 is the first day where the patient has the
% acticmeter on his arm, and normally start between 12 pm and 2 pm, which
% pretty much reduces a lot the time for computation.
L_y5 = length(y_5); % because epocs of 1 min
j = 1;
for i=1:k:L_y2
y5_chunk{j} = y_5(i:i+k-1);
j = j + 1;
end
L_y5 = length(y_5); % because epocs of 1 min
j = 1;
for i=1:k:L_y2
y5_chunk{j} = y_5(i:i+k-1);
j = j + 1;
end
%save('y2chunk', 'y2_chunk', 'y3_chunk');
if(graph_mean_day_spectral_entropy)
% this part computes the y_mean for the whole 24 hours, starting at
% day 2
L_ymean = length(y_mean); % because epocs of 1 min
j = 1;
for i=1:k:L_ymean
y_mean_chunk{j} = y_mean(i:i+k-1);
j = j + 1;
end
% Creating chunks for the day
jj = 1;
for ii=init_day*factor_day:k:end_day*factor_day - k
yday_mean_chunk{jj} = y_mean_day(ii:ii+k-1);
jj = jj + 1;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Spectral Entropy %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
%for dd = 2:5 % from day 2 to 5
windows_i = 60
if(graph_mean_day_spectral_entropy)
% figure,
for k =1:6
SE = [];
TM = [];
for i = 1 : 15 : length(y_mean_chunk{k})
if i+windows_i-1 <= length(y_mean_chunk{k})
%aux = act(i:i+30-1);
aux = y_mean_chunk{k}(i:i+30-1);
Y = my_spectral_entropy(aux,1/60,[.0006 .0083],windows_i,length(aux),0);
SE = [SE Y];
TM = [TM i];
end
end
% subplot(3,2,k),plot(TM, SE), ylim([.7 1]);
end
% figure,
for k =7:12
SE = [];
TM = [];
for i = 1 : 1 : length(y_mean_chunk{k}) % it was 15
if i+windows_i-1 <= length(y_mean_chunk{k})
%aux = act(i:i+30-1);
aux = y_mean_chunk{k}(i:i+30-1);
Y = my_spectral_entropy(aux,1/60,[.0006 .0083],windows_i,length(aux),0);
SE = [SE Y];
TM = [TM i];
end
end
% subplot(3,2,k-6),plot(TM, SE), ylim([.7 1]);
end
% This part computes the mean of the mean of the chunks per day,
% which means that creates only one chunk that resumes the activemeter
% data from day 2 to day 5
temp_y_mean_chunk = [];
for ii = 1:number_of_chunks
% temp_y_mean_chunk = [y_mean_chunk{2}; y_mean_chunk{3}; y_mean_chunk{4}; y_mean_chunk{5} ];
temp_y_mean_chunk = [temp_y_mean_chunk; y_mean_chunk{ii} ];
end
mean_y_mean_chunk = mean(temp_y_mean_chunk);
% This part computes the mean of the mean of the chunks per day during day time ( 8 to 20 hours),
% which means that creates only one chunk that resumes the activemeter
% data from day 2 to day 5
temp_yday_mean_chunk = [];
[ mm, nchunks_day] = size(yday_mean_chunk);
for iii = 1:nchunks_day
% temp_y_mean_chunk = [y_mean_chunk{2}; y_mean_chunk{3}; y_mean_chunk{4}; y_mean_chunk{5} ];
temp_yday_mean_chunk = [temp_yday_mean_chunk; yday_mean_chunk{iii} ];
end
mean_yday_mean_chunk = mean(temp_yday_mean_chunk);
% figure,
if(graph_mean_day_spectral_entropy_morning)
disp('-------------------------------------------');
fprintf(1,'\n Computing the spectral entropy for the day (8h to 20 h) \n' );
disp('-------------------------------------------');
SE_mean_day = [];
TM_mean_day = [];
for i = 1 : 1: length(mean_yday_mean_chunk) % it was 15
if i+windows_i-1 <= length(mean_yday_mean_chunk)
%aux = act(i:i+30-1);
aux = mean_yday_mean_chunk(i:i+30-1);
Y = my_spectral_entropy(aux,1/60,[.0006 .0083],windows_i,length(aux),0);
SE_mean_day = [SE_mean_day Y];
TM_mean_day = [TM_mean_day i];
end
end
% plot(TM_mean, SE_mean), ylim([.7 1]),title('Plot of the mean of chunks for the days 2,3,4 and 5 ');
crs = 'UWS';
graph_spectral_entropy(SE_mean_day, crs);
else
disp('-------------------------------------------');
fprintf(1,'\n Computing the spectral entropy for the whole day (0h to 24 h) \n' );
disp('-------------------------------------------');
SE_mean = [];
TM_mean = [];
for i = 1 : 1: length(mean_y_mean_chunk) % it was 15
if i+windows_i-1 <= length(mean_y_mean_chunk)
%aux = act(i:i+30-1);
aux = mean_y_mean_chunk(i:i+30-1);
Y = my_spectral_entropy(aux,1/60,[.0006 .0083],windows_i,length(aux),0);
SE_mean = [SE_mean Y];
TM_mean = [TM_mean i];
end
end
% plot(TM_mean, SE_mean), ylim([.7 1]),title('Plot of the mean of chunks for the days 2,3,4 and 5 ');
crs = 'UWS';
graph_spectral_entropy(SE_mean, crs);
%save('y_mean_chunk_120min', 'TM_mean', 'SE_mean', 'mean_y_mean_chunk');
end
s1 = name_ses;
s2 = '.mat';
s = strcat(s1,s2);
pathstr_ses = strcat(pathstr_ses, '/');
path_copy = strcat(pathstr_ses, s)
copyfile('save_aux.mat', path_copy )
delete save_aux.mat
else
% Working for days 2, 3, 4 and 5
% day 2%
% figure,
for k =1:6
SE = [];
TM = [];
for i = 1 : 15 : length(y2_chunk{k})
if i+windows_i-1 <= length(y2_chunk{k})
%aux = act(i:i+30-1);
aux = y2_chunk{k}(i:i+30-1);
Y = my_spectral_entropy(aux,1/60,[.0006 .0083],windows_i,length(aux),0);
SE = [SE Y];
TM = [TM i];
end
end
% subplot(3,2,k),plot(TM, SE), ylim([.7 1]);
end
% figure,
for k =7:12
SE = [];
TM = [];
for i = 1 : 15 : length(y2_chunk{k})
if i+windows_i-1 <= length(y2_chunk{k})
%aux = act(i:i+30-1);
aux = y2_chunk{k}(i:i+30-1);
Y = my_spectral_entropy(aux,1/60,[.0006 .0083],windows_i,length(aux),0);
SE = [SE Y];
TM = [TM i];
end
end
% subplot(3,2,k-6),plot(TM, SE), ylim([.7 1]);
end
%%% day 3 %%%
% figure,
for k =1:6
SE = [];
TM = [];
for i = 1 : 15 : length(y3_chunk{k})
if i+windows_i-1 <= length(y3_chunk{k})
%aux = act(i:i+30-1);
aux = y3_chunk{k}(i:i+30-1);
Y = my_spectral_entropy(aux,1/60,[.0006 .0083],windows_i,length(aux),0);
SE = [SE Y];
TM = [TM i];
end
end
% subplot(3,2,k),plot(TM, SE), ylim([.7 1]);
end
% figure,
for k =7:12
SE = [];
TM = [];
for i = 1 : 15 : length(y3_chunk{k})
if i+windows_i-1 <= length(y3_chunk{k})
%aux = act(i:i+30-1);
aux = y3_chunk{k}(i:i+30-1);
Y = my_spectral_entropy(aux,1/60,[.0006 .0083],windows_i,length(aux),0);
SE = [SE Y];
TM = [TM i];
end
end
% subplot(3,2,k-6),plot(TM, SE), ylim([.7 1]);
end
%%% day 4 %%%%%%
% figure,
for k =1:6
SE = [];
TM = [];
for i = 1 : 15 : length(y4_chunk{k})
if i+windows_i-1 <= length(y4_chunk{k})
%aux = act(i:i+30-1);
aux = y4_chunk{k}(i:i+30-1);
Y = my_spectral_entropy(aux,1/60,[.0006 .0083],windows_i,length(aux),0);
SE = [SE Y];
TM = [TM i];
end
end
% subplot(3,2,k),plot(TM, SE), ylim([.7 1]);
end
%figure,
for k =7:12
SE = [];
TM = [];
for i = 1 : 15 : length(y4_chunk{k})
if i+windows_i-1 <= length(y4_chunk{k})
%aux = act(i:i+30-1);
aux = y4_chunk{k}(i:i+30-1);
Y = my_spectral_entropy(aux,1/60,[.0006 .0083],windows_i,length(aux),0);
SE = [SE Y];
TM = [TM i];
end
end
% subplot(3,2,k-6),plot(TM, SE), ylim([.7 1]);
end
%%% day 5 %%%%%%
% figure,
for k =1:6
SE = [];
TM = [];
for i = 1 : 15 : length(y5_chunk{k})
if i+windows_i-1 <= length(y5_chunk{k})
%aux = act(i:i+30-1);
aux = y5_chunk{k}(i:i+30-1);
Y = my_spectral_entropy(aux,1/60,[.0006 .0083],windows_i,length(aux),0);
SE = [SE Y];
TM = [TM i];
end
end
% subplot(3,2,k),plot(TM, SE), ylim([.7 1]);
end
figure,
for k =7:12
SE = [];
TM = [];
for i = 1 : 15 : length(y5_chunk{k})
if i+windows_i-1 <= length(y5_chunk{k})
%aux = act(i:i+30-1);
aux = y5_chunk{k}(i:i+30-1);
Y = my_spectral_entropy(aux,1/60,[.0006 .0083],windows_i,length(aux),0);
SE = [SE Y];
TM = [TM i];
end
end
% subplot(3,2,k-6),plot(TM, SE), ylim([.7 1]);
end
end
end