|  | 
| 58 | 58 | 
 | 
| 59 | 59 | % ms_dir=fullfile(plot_dir,'ms'); | 
| 60 | 60 | % mkdir(ms_dir); | 
| 61 |  | -% | 
|  | 61 | +% | 
| 62 | 62 | % gevtotal_dir=fullfile(plot_dir,'gevtotal'); | 
| 63 | 63 | % mkdir(gevtotal_dir); | 
| 64 |  | -% | 
|  | 64 | +% | 
| 65 | 65 | % mat_dir=fullfile(plot_dir,'mat'); | 
| 66 | 66 | % mkdir(mat_dir); | 
| 67 | 67 | 
 | 
|  | 
| 155 | 155 |  [fpath,fname,fext] = fileparts(input_file_name); | 
| 156 | 156 |  tmpEEG = pop_loadset('filename',[fname,fext],'filepath',fpath); | 
| 157 | 157 |  end | 
| 158 |  | -% tmpEEG = pop_loadset(input_file_name); | 
|  | 158 | +% tmpEEG = pop_loadset(input_file_name); | 
| 159 | 159 |  tmpEEG = pop_select(tmpEEG,'channel' ,1:project.eegdata.nch_eeg); | 
| 160 | 160 |  tmpEEG = eeg_checkset(tmpEEG); | 
| 161 | 161 |  ALLEEG = eeg_store(ALLEEG,tmpEEG, CURRENTSET); | 
|  | 
| 210 | 210 |  EEG.xmax = xmax_ms; | 
| 211 | 211 | 
 | 
| 212 | 212 | 
 | 
| 213 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 214 |  | -% str2 = [str,'_',project.subjects.group_names{ng}]; | 
|  | 213 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 214 | +% str2 = [str,'_',project.subjects.group_names{ng}]; | 
| 215 | 215 |  EEG = pop_saveset( EEG, 'filename',[str2,'.set'],'filepath',input_path); | 
| 216 | 216 | 
 | 
| 217 | 217 | 
 | 
| 218 | 218 |  end | 
| 219 | 219 | 
 | 
| 220 | 220 |  if project.microstates.do_segment | 
| 221 | 221 | 
 | 
| 222 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 223 |  | -% str2 = [str,'_',project.subjects.group_names{ng}]; | 
|  | 222 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 223 | +% str2 = [str,'_',project.subjects.group_names{ng}]; | 
| 224 | 224 |  EEG = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 225 | 225 | 
 | 
| 226 |  | - | 
| 227 |  | - EEG = pop_micro_segment( EEG, ... | 
| 228 |  | - 'algorithm', project.microstates.micro_segment.algorithm, ... | 
| 229 |  | - 'sorting', project.microstates.micro_segment.sorting,... | 
| 230 |  | - 'normalise', project.microstates.micro_segment.normalise, ... | 
| 231 |  | - 'Nmicrostates', project.microstates.micro_segment.Nmicrostates,... | 
| 232 |  | - 'verbose', project.microstates.micro_segment.verbose,... | 
| 233 |  | - 'determinism', project.microstates.micro_segment.determinism,... | 
| 234 |  | - 'polarity', project.microstates.micro_segment.polarity ); | 
| 235 |  | - | 
|  | 226 | + if strcmp(project.microstates.micro_segment.algorithm,'taah') ||... | 
|  | 227 | + strcmp(project.microstates.micro_segment.algorithm,'aah') | 
|  | 228 | + EEG = pop_micro_segment( EEG, ... | 
|  | 229 | + 'algorithm', project.microstates.micro_segment.algorithm, ... | 
|  | 230 | + 'sorting', project.microstates.micro_segment.sorting,... | 
|  | 231 | + 'normalise', project.microstates.micro_segment.normalise, ... | 
|  | 232 | + 'Nmicrostates', project.microstates.micro_segment.Nmicrostates,... | 
|  | 233 | + 'verbose', project.microstates.micro_segment.verbose,... | 
|  | 234 | + 'determinism', project.microstates.micro_segment.determinism,... | 
|  | 235 | + 'polarity', project.microstates.micro_segment.polarity ); | 
|  | 236 | + else | 
|  | 237 | + EEG = pop_micro_segment( EEG, ... | 
|  | 238 | + 'algorithm', project.microstates.micro_segment.algorithm, ... | 
|  | 239 | + 'sorting', project.microstates.micro_segment.sorting,... | 
|  | 240 | + 'normalise', project.microstates.micro_segment.normalise, ... | 
|  | 241 | + 'Nmicrostates', project.microstates.micro_segment.Nmicrostates,... | 
|  | 242 | + 'verbose', project.microstates.micro_segment.verbose... | 
|  | 243 | + ); | 
|  | 244 | + end | 
| 236 | 245 | 
 | 
| 237 | 246 |  [ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); | 
| 238 | 247 |  EEG = pop_saveset( EEG, 'filename',[str2,'.set'],'filepath',input_path); | 
|  | 
| 241 | 250 |  EEG.xmin = xmin_ms; | 
| 242 | 251 |  EEG.xmax = xmax_ms; | 
| 243 | 252 | 
 | 
| 244 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 245 |  | -% str2 = [str,'_',project.subjects.group_names{ng}]; | 
|  | 253 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 254 | +% str2 = [str,'_',project.subjects.group_names{ng}]; | 
| 246 | 255 |  EEG = pop_saveset( EEG, 'filename',[str2,'.set'],'filepath',input_path); | 
| 247 | 256 | 
 | 
| 248 | 257 | 
 | 
|  | 
| 252 | 261 | 
 | 
| 253 | 262 | 
 | 
| 254 | 263 |  if project.microstates.do_viewNmicro | 
| 255 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 256 |  | -% str2 = [str,'_',project.subjects.group_names{ng}]; | 
|  | 264 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 265 | +% str2 = [str,'_',project.subjects.group_names{ng}]; | 
| 257 | 266 |  EEG = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 258 | 267 |  %open figure to select | 
| 259 | 268 |  EEG = pop_micro_selectNmicro( EEG ); | 
| 260 | 269 |  end | 
| 261 | 270 |  if project.microstates.do_selectNmicro | 
| 262 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 263 |  | -% str2 = [str,'_',project.subjects.group_names{ng}]; | 
|  | 271 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 272 | +% str2 = [str,'_',project.subjects.group_names{ng}]; | 
| 264 | 273 |  EEG = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 265 | 274 |  EEG = pop_micro_selectNmicro( EEG,... | 
| 266 | 275 |  'Nmicro', project.microstates.selectNmicro.Nmicro_spontaneous ); | 
|  | 
| 270 | 279 |  end | 
| 271 | 280 | 
 | 
| 272 | 281 |  if project.microstates.do_fit | 
| 273 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 274 |  | -% str2 = [str,'_',project.subjects.group_names{ng}]; | 
|  | 282 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 283 | +% str2 = [str,'_',project.subjects.group_names{ng}]; | 
| 275 | 284 |  EEG = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 276 | 285 | 
 | 
| 277 | 286 |  % EEG = pop_micro_fit( EEG,... | 
|  | 
| 287 | 296 |  [ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); | 
| 288 | 297 | 
 | 
| 289 | 298 | 
 | 
| 290 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 291 |  | -% str2 = [str,'_',project.subjects.group_names{ng}]; | 
|  | 299 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 300 | +% str2 = [str,'_',project.subjects.group_names{ng}]; | 
| 292 | 301 | 
 | 
| 293 | 302 |  EEG = pop_saveset( EEG, 'filename',[str2,'.set'],'filepath',input_path); | 
| 294 | 303 | 
 | 
|  | 
| 306 | 315 | 
 | 
| 307 | 316 | 
 | 
| 308 | 317 |  if project.microstates.do_smooth | 
| 309 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 310 |  | -% str2 = [str,'_',project.subjects.group_names{ng}]; | 
|  | 318 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 319 | +% str2 = [str,'_',project.subjects.group_names{ng}]; | 
| 311 | 320 |  EEG = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 312 | 321 | 
 | 
| 313 | 322 |  EEG = pop_micro_smooth( EEG, ... | 
|  | 
| 319 | 328 | 
 | 
| 320 | 329 |  [ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); | 
| 321 | 330 | 
 | 
| 322 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 323 |  | -% str2 = [str,'_',project.subjects.group_names{ng}]; | 
|  | 331 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 332 | +% str2 = [str,'_',project.subjects.group_names{ng}]; | 
| 324 | 333 | 
 | 
| 325 | 334 |  EEG = pop_saveset( EEG, 'filename',[str2,'.set'],'filepath',input_path); | 
| 326 | 335 | 
 | 
|  | 
| 335 | 344 |  end | 
| 336 | 345 | 
 | 
| 337 | 346 |  if project.microstates.do_stats | 
| 338 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 339 |  | -% str2 = [str,'_',project.subjects.group_names{ng}]; | 
|  | 347 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 348 | +% str2 = [str,'_',project.subjects.group_names{ng}]; | 
| 340 | 349 |  EEG = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 341 | 350 |  EEG = pop_micro_stats( EEG,... | 
| 342 | 351 |  'label_type', project.microstates.micro_stats.label_type,... | 
| 343 | 352 |  'polarity', project.microstates.micro_stats.polarity ); | 
| 344 | 353 | 
 | 
| 345 | 354 |  [ALLEEG EEG] = eeg_store(ALLEEG, EEG, CURRENTSET); | 
| 346 | 355 | 
 | 
| 347 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 348 |  | -% str2 = [str,'_',project.subjects.group_names{ng}]; | 
|  | 356 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 357 | +% str2 = [str,'_',project.subjects.group_names{ng}]; | 
| 349 | 358 | 
 | 
| 350 | 359 |  EEG = pop_saveset( EEG, 'filename',[str2,'.set'],'filepath',input_path); | 
| 351 | 360 | 
 | 
|  | 
| 515 | 524 |  EEG.xmin = xmin_ms; | 
| 516 | 525 |  EEG.xmax = xmax_ms; | 
| 517 | 526 | 
 | 
| 518 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 519 |  | -% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
|  | 527 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 528 | +% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
| 520 | 529 |  EEG = pop_saveset( EEG, 'filename',[str2,'.set'],'filepath',input_path); | 
| 521 | 530 | 
 | 
| 522 | 531 | 
 | 
| 523 | 532 |  end | 
| 524 | 533 | 
 | 
| 525 | 534 |  if project.microstates.do_segment | 
| 526 | 535 | 
 | 
| 527 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 528 |  | -% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
|  | 536 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 537 | +% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
| 529 | 538 |  EEG = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 530 | 539 | 
 | 
| 531 | 540 | 
 | 
|  | 
| 550 | 559 |  EEG.xmax = xmax_ms; | 
| 551 | 560 | 
 | 
| 552 | 561 | 
 | 
| 553 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 554 |  | -% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
|  | 562 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 563 | +% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
| 555 | 564 |  EEG = pop_saveset( EEG, 'filename',[str2,'.set'],'filepath',input_path); | 
| 556 | 565 | 
 | 
| 557 | 566 | 
 | 
| 558 | 567 |  end | 
| 559 | 568 | 
 | 
| 560 | 569 | 
 | 
| 561 | 570 |  if project.microstates.do_viewNmicro | 
| 562 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 563 |  | -% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
|  | 571 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 572 | +% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
| 564 | 573 |  EEG = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 565 | 574 |  %open figure to select | 
| 566 | 575 |  EEG = pop_micro_selectNmicro( EEG ); | 
| 567 | 576 |  end | 
| 568 | 577 | 
 | 
| 569 | 578 | 
 | 
| 570 | 579 |  if project.microstates.do_selectNmicro | 
| 571 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 572 |  | -% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
|  | 580 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 581 | +% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
| 573 | 582 |  EEG = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 574 | 583 | 
 | 
| 575 | 584 |  EEG = pop_micro_selectNmicro( EEG,... | 
|  | 
| 589 | 598 | 
 | 
| 590 | 599 |  end | 
| 591 | 600 |  if project.microstates.do_fit | 
| 592 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 593 |  | -% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
|  | 601 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 602 | +% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
| 594 | 603 |  EEG = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 595 | 604 | 
 | 
| 596 | 605 |  EEG = pop_micro_fit( EEG,... | 
|  | 
| 615 | 624 |  end | 
| 616 | 625 |  if project.microstates.do_smooth | 
| 617 | 626 | 
 | 
| 618 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 619 |  | -% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
|  | 627 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 628 | +% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
| 620 | 629 |  EEG = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 621 | 630 | 
 | 
| 622 | 631 |  EEG = pop_micro_smooth( EEG, ... | 
|  | 
| 643 | 652 | 
 | 
| 644 | 653 |  if project.microstates.do_stats | 
| 645 | 654 | 
 | 
| 646 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 647 |  | -% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
|  | 655 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 656 | +% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
| 648 | 657 |  EEG = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 649 | 658 | 
 | 
| 650 | 659 | 
 | 
|  | 
| 678 | 687 |  ylim manual | 
| 679 | 688 |  ylim(project.microstates.MicroPlotSegments.plot_ylim) | 
| 680 | 689 | 
 | 
| 681 |  | -% str = ['microstates','_',project.microstates.suffix]; | 
| 682 |  | -% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
|  | 690 | +% str = ['microstates','_',project.microstates.suffix]; | 
|  | 691 | +% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
| 683 | 692 | 
 | 
| 684 | 693 |  suptitle(str2) | 
| 685 | 694 | 
 | 
|  | 
| 703 | 712 | 
 | 
| 704 | 713 |  if project.microstates.do_backfit | 
| 705 | 714 | 
 | 
| 706 |  | -% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
| 707 |  | -% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
|  | 715 | +% str = ['microstates','_',microstate_type,'_',project.microstates.suffix]; | 
|  | 716 | +% str2 = [str,'_',project.subjects.group_names{ng},'_',current_cond_name]; | 
| 708 | 717 |  [ NewEEG] = pop_loadset( 'filename',[str2,'.set'],'filepath',input_path); | 
| 709 | 718 | 
 | 
| 710 | 719 |  eeglab redraw | 
| 711 | 720 |  ind_ms_set = tset+1; | 
| 712 | 721 |  [ALLEEG EEG] = eeg_store(ALLEEG, NewEEG, ind_ms_set); | 
| 713 | 722 |  eeglab redraw | 
| 714 |  | -% [ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, ind_ms_set,'overwrite','on','gui','off'); | 
| 715 |  | -%  eeglab redraw  | 
|  | 723 | +% [ALLEEG EEG CURRENTSET] = pop_newset(ALLEEG, EEG, ind_ms_set,'overwrite','on','gui','off'); | 
|  | 724 | + % eeglab redraw | 
| 716 | 725 |  outpath_gevtotal = fullfile(gevtotal_dir,['gevtotal','_',current_cond_name,'.txt']); | 
| 717 | 726 |  fid_gevtotal = fopen(outpath_gevtotal, 'a+'); | 
| 718 | 727 |  fprintf(fid_gevtotal, '%s\t%s\n','subject','gevtotal'); | 
|  | 
| 766 | 775 |  row_epoch = []; | 
| 767 | 776 |  col_epoch = []; | 
| 768 | 777 |  epoch = []; | 
| 769 |  | - | 
|  | 778 | + | 
| 770 | 779 |  for nepo = 1:EEG.trials | 
| 771 | 780 |  mat_epoch = EEG.microstate.stats.TP(:,:,nepo); | 
| 772 | 781 |  tmat = numel(mat_epoch); | 
|  | 
| 775 | 784 |  [rrow, ccol] = ind2sub(size(EEG.microstate.stats.TP), LIDX); | 
| 776 | 785 |  row_epoch = [row_epoch, rrow]; | 
| 777 | 786 |  col_epoch = [col_epoch, ccol]; | 
| 778 |  | - epoch = [epoch, repmat(nepo,1,tmat)]; | 
|  | 787 | + epoch = [epoch, repmat(nepo,1,tmat)]; | 
| 779 | 788 |  end | 
| 780 | 789 |  data_mat.epoch = epoch; | 
| 781 | 790 |  data_mat.row = row_epoch; | 
| 782 | 791 |  data_mat.col = col_epoch; | 
| 783 | 792 |  data_mat.TP = TP_epoch; | 
| 784 |  | - | 
| 785 |  | - | 
|  | 793 | + | 
|  | 794 | + | 
| 786 | 795 |  data_mat = structfun(@transpose,data_mat,'UniformOutput',false); | 
| 787 | 796 |  data_mat = struct2table(data_mat); | 
| 788 | 797 |  outpath_mat = fullfile(mat_dir,[fout,'_',current_cond_name,'_mat','.txt']); | 
|  | 
0 commit comments