|
3 | 3 |
|
4 | 4 | clear variables |
5 | 5 | eeglab |
6 | | -home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Control\'; |
7 | | -save_path = [home_path 'figures\Microstates\']; |
8 | | -subject_list = {'12512' '12648' '12651' '12707' '12727' '12739' '12750' '12815' '12898' '12899' '10033' '10130' '10131' '10158' '10165' '10257' '10281' '10293' '10360' '10369' '10384' '10394' '10407' '10438' '10446' '10451' '10463' '10467' '10476' '10501' '10526' '10534' '10545' '10561' '10562' '10581' '10585' '10616' '10615' '10620' '10639' '10748' '10780' '10784' '10822' '10858' '10906' '10915' '10929' '10935' '10844' '10956' '12005' '12007' '12010' '12215' '12328' '12360' '12413' };% ------------------------------------------------ |
9 | | -for s=1:length(subject_list) |
10 | | - data_path = [home_path subject_list{s} ''];% Path to the folder containing the current subject's data |
11 | | - % Load original dataset |
12 | | - fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); |
13 | | - EEG = pop_loadset('filename', [subject_list{s} '_inter.set'], 'filepath', data_path); |
14 | | - [ALLEEG, EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); |
15 | | -end |
16 | | -%this creates a grouped dataset using the standard values |
17 | | -[EEG, ALLEEG] = pop_micro_selectdata( EEG, ALLEEG, 'datatype', 'spontaneous', 'avgref', 1, 'normalise', 0, 'MinPeakDist', 10, 'Npeaks', 1000, 'GFPthresh', 1, 'dataset_idx', 1:length(ALLEEG) ); |
18 | | -%[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); |
19 | | -eeglab redraw |
20 | | -[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, length(ALLEEG)-1,'retrieve',length(ALLEEG),'study',0); %this should select the last one, but not sure how to make it do that for sure |
21 | | -eeglab redraw |
22 | | -EEG = pop_micro_segment( EEG, 'algorithm', 'modkmeans', 'sorting', 'Global explained variance', 'normalise', 0, 'Nmicrostates', 2:8, 'verbose', 1, 'Nrepetitions', 50, 'fitmeas', 'CV', 'max_iterations', 1000, 'threshold', 1e-06, 'optimised', 0 ); |
23 | | - |
24 | | -[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); |
25 | | -figure;MicroPlotTopo( EEG, 'plot_range', [] ); %plotting microstates |
26 | | -print([save_path 'Group_microstate'], '-djpeg'); |
27 | 6 |
|
28 | | -EEG = pop_micro_selectNmicro( EEG ); % only select CV and GEV, look for where GEV doesn't increase significantly |
29 | | -[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); |
30 | | -%errors are coming, line 83 of pop_micro_fit Dot indexing is not supported for variables of this type |
31 | | -for s=1:length(subject_list) |
32 | | - %[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 60,'retrieve',s,'study',0); |
33 | | - fprintf('Importing prototypes and backfitting for dataset %i\n',i) |
34 | | - [ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET,'retrieve',s,'study',0); |
35 | | - EEG = pop_micro_import_proto( EEG, ALLEEG, length(ALLEEG)); |
36 | | - %% 3.6 Back-fit microstates on EEG |
37 | | - EEG = pop_micro_fit( EEG, 'polarity', 0 ); |
38 | | - %% 3.7 Temporally smooth microstates labels |
39 | | - EEG = pop_micro_smooth( EEG, 'label_type', 'backfit', ... |
40 | | - 'smooth_type', 'reject segments', ... |
41 | | - 'minTime', 30, ... |
42 | | - 'polarity', 0 ); |
43 | | - %% 3.9 Calculate microstate statistics |
44 | | - EEG = pop_micro_stats( EEG, 'label_type', 'backfit', ... |
45 | | - 'polarity', 0 ); |
| 7 | +Group = {'Aging' 'ASD' 'Control'};%'Control' |
| 8 | +name_paradigm = 'restingstate'; % this is needed for saving the table at the end |
| 9 | +for g=1:length(Group) |
| 10 | + switch Group{g} |
| 11 | + case 'Control' |
| 12 | + home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Control\'; |
| 13 | + subject_list = {'12512' '12648' '12651' '12707' '12727' '12739' '12750' '12815' '12898' '12899' '10033' '10130' '10131' '10158' '10165' '10257' '10281' '10293' '10360' '10369' '10384' '10394' '10407' '10438' '10446' '10451' '10463' '10467' '10476' '10501' '10526' '10534' '10545' '10561' '10562' '10581' '10585' '10616' '10615' '10620' '10639' '10748' '10780' '10784' '10822' '10858' '10906' '10915' '10929' '10935' '10844' '10956' '12005' '12007' '12010' '12215' '12328' '12360' '12413' };% ------------------------------------------------ |
| 14 | + case 'ASD' |
| 15 | + home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\ASD\'; |
| 16 | + subject_list = {'1101' '1164' '1808' '1852' '1855' '11014' '11094' '11151' '11170' '11275' '11349' '11516' '11558' '11583' '11647' '11729' '11735' '11768' '11783' '11820' '11912' '1106' '1132' '1134' '1154' '1160' '1173' '1174' '1179' '1190' '1838' '1839' '1874' '11013' '11056' '11098' '11106' '11198' '11244' '11293' '11325' '11354' '11375' '11515' '11560' '11580' '11667' '11721' '11723' '11750' '11852' '11896' '11898' '11913' '11927' '11958' '11965'}; %all the IDs for the indivual particpants; |
| 17 | + case 'Aging' |
| 18 | + home_path = 'C:\Users\dohorsth\Desktop\Testing restingstate\Aging\'; |
| 19 | + subject_list = {'12022' '12023' '12031' '12081' '12094' '12188' '12255' '12335' '12339' '12362' '12364' '12372' '12376' '12390' '12398' '12407' '12408' '12451' '12454' '12457' '12458' '12459' '12468' '12478' '12498' '12510' '12517' '12532' '12564' '12631' '12633' '12634' '12636' '12665' '12670' '12696' '12719' '12724' '12751' '12763' '12769' '12776' '12790' '12806' '12814' '12823' '12830' '12847' '12851' '12855' '12856' '12857' '12859' '12871' '12872' '12892'}; |
| 20 | + end |
| 21 | + save_path = [home_path 'figures\Microstates\']; |
| 22 | + for s=1:length(subject_list) |
| 23 | + data_path = [home_path subject_list{s} ''];% Path to the folder containing the current subject's data |
| 24 | + % Load original dataset |
| 25 | + fprintf('\n\n\n**** %s: Loading dataset ****\n\n\n', subject_list{s}); |
| 26 | + EEG = pop_loadset('filename', [subject_list{s} '_inter.set'], 'filepath', data_path); |
| 27 | + [ALLEEG, EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); |
| 28 | + end |
| 29 | + %this creates a grouped dataset using the standard values |
| 30 | + [EEG, ALLEEG] = pop_micro_selectdata( EEG, ALLEEG, 'datatype', 'spontaneous', 'avgref', 1, 'normalise', 0, 'MinPeakDist', 10, 'Npeaks', 1000, 'GFPthresh', 1, 'dataset_idx', 1:length(ALLEEG) ); |
| 31 | + %[ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); |
| 32 | + eeglab redraw |
| 33 | + [ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, length(ALLEEG)-1,'retrieve',length(ALLEEG),'study',0); %this should select the last one, but not sure how to make it do that for sure |
| 34 | + eeglab redraw |
| 35 | + EEG = pop_micro_segment( EEG, 'algorithm', 'modkmeans', 'sorting', 'Global explained variance', 'normalise', 0, 'Nmicrostates', 2:8, 'verbose', 1, 'Nrepetitions', 50, 'fitmeas', 'CV', 'max_iterations', 1000, 'threshold', 1e-06, 'optimised', 0 ); |
| 36 | + |
46 | 37 | [ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); |
47 | | -end |
48 | | -for s=1:length(subject_list) |
49 | | - [ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET,'retrieve',s,'study',0); |
50 | | - figure('units','normalized','outerposition',[0 0 1 1]);[t]=title(subject_list(s));t.FontSize = 35; MicroPlotSegments( EEG, 'label_type', 'backfit', ... |
51 | | - 'plotsegnos', 'first', 'plot_time', [4200 5700], 'plottopos', 1 ); |
52 | | - print([save_path subject_list{s} '_microstate'], '-djpeg'); |
53 | | - close all |
54 | | - EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_microstate.set'],'filepath', data_path); |
| 38 | + figure;MicroPlotTopo( EEG, 'plot_range', [] ); %plotting microstates |
| 39 | + print([save_path 'Group_microstate'], '-djpeg'); |
| 40 | + |
| 41 | + EEG = pop_micro_selectNmicro( EEG ); % only select CV and GEV, look for where GEV doesn't increase significantly |
| 42 | + [ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); |
| 43 | + %errors are coming, line 83 of pop_micro_fit Dot indexing is not supported for variables of this type |
| 44 | + for s=1:length(subject_list) |
| 45 | + %[ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, 60,'retrieve',s,'study',0); |
| 46 | + fprintf('Importing prototypes and backfitting for dataset %i\n',i) |
| 47 | + [ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET,'retrieve',s,'study',0); |
| 48 | + EEG = pop_micro_import_proto( EEG, ALLEEG, length(ALLEEG)); |
| 49 | + %% 3.6 Back-fit microstates on EEG |
| 50 | + EEG = pop_micro_fit( EEG, 'polarity', 0 ); |
| 51 | + %% 3.7 Temporally smooth microstates labels |
| 52 | + EEG = pop_micro_smooth( EEG, 'label_type', 'backfit', ... |
| 53 | + 'smooth_type', 'reject segments', ... |
| 54 | + 'minTime', 30, ... |
| 55 | + 'polarity', 0 ); |
| 56 | + %% 3.9 Calculate microstate statistics |
| 57 | + EEG = pop_micro_stats( EEG, 'label_type', 'backfit', ... |
| 58 | + 'polarity', 0 ); |
| 59 | + [ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); |
| 60 | + end |
| 61 | + for s=1:length(subject_list) |
| 62 | + [ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, CURRENTSET,'retrieve',s,'study',0); |
| 63 | + figure('units','normalized','outerposition',[0 0 1 1]);[t]=title(subject_list(s));t.FontSize = 35; MicroPlotSegments( EEG, 'label_type', 'backfit', ... |
| 64 | + 'plotsegnos', 'first', 'plot_time', [4200 5700], 'plottopos', 1 ); |
| 65 | + print([save_path subject_list{s} '_microstate'], '-djpeg'); |
| 66 | + close all |
| 67 | + EEG = pop_saveset( EEG, 'filename',[subject_list{s} '_microstate.set'],'filepath', data_path); |
| 68 | + end |
55 | 69 | end |
0 commit comments