Browse Source

finalize analyses, harmonize naming, add readme

kosciessa 2 years ago
parent
commit
2cd4fa115c
100 changed files with 1839 additions and 1693 deletions
  1. 262 0
      README.md
  2. 5 4
      code/a_eegmp_calculate_erp_tfr.m
  3. 0 109
      code/b1_taskPLS_scenecat_N1.m
  4. 0 111
      code/b1_taskPLS_scenecat_N1_avg.m
  5. 0 181
      code/b2a_taskPLS_novelty_frontal_erp_plotLV1.m
  6. 0 156
      code/b2a_taskPLS_novelty_frontal_erp_plot_trace.m
  7. 0 303
      code/b_scenecat_n1.m
  8. 73 16
      code/b_scenecat_n1_bl.m
  9. 2 2
      code/b2a_taskPLS_novelty_frontal_erp.m
  10. 26 35
      code/b2b_taskPLS_novelty_frontal_theta_plotLV1.m
  11. 268 0
      code/c1_taskPLS_novelty_frontal_erp_trace.m
  12. 328 0
      code/c23_novelty_plot_theta_alpha.m
  13. 2 2
      code/b2b_taskPLS_novelty_frontal_theta.m
  14. 35 49
      code/b1_taskPLS_scenecat_N1_plotLV1.m
  15. 1 1
      code/b2c_taskPLS_novelty_posterior_alpha.m
  16. 8 23
      code/b1_taskPLS_scenecat_N1_avg_plotLV1.m
  17. 1 1
      code/b3a_taskPLS_recognition_erp.m
  18. 131 36
      code/b3a_taskPLS_recognition_erp_LV1.m
  19. 350 0
      code/d1_taskPLS_recognition_erp_trace.m
  20. 1 1
      code/b3b_taskPLS_recognition_erf.m
  21. 84 60
      code/b3b_taskPLS_recognition_erf_LV1.m
  22. 39 26
      code/b3x_rcognition_plot_theta_alpha.m
  23. 1 1
      code/b4a_taskPLS_memory_erp.m
  24. 9 43
      code/b4a_taskPLS_memory_erp_LV1.m
  25. 1 1
      code/b4a_taskPLS_memory_erp_nooutlier.m
  26. 14 39
      code/b2c_taskPLS_novelty_posterior_alpha_LV1.m
  27. 67 0
      code/e1_taskPLS_memory_erp_trace.m
  28. 1 1
      code/b4b_taskPLS_memory_erf.m
  29. 24 16
      code/b4b_taskPLS_memory_erf_LV1.m
  30. 41 44
      code/b2x_novelty_plot_theta_alpha.m
  31. 0 156
      code/z_archive/b2a_taskPLS_novelty_frontal_erp_plot_trace_tmp.m
  32. 0 59
      code/z_eegmp_old_new_ERP.m
  33. 0 27
      code/z_eegmp_old_new_ERP_START.sh
  34. 0 125
      code/z_eegmp_old_new_ERP_trace.m
  35. 1 1
      data/erf/sub-001_erf.mat
  36. 1 1
      data/erf/sub-002_erf.mat
  37. 1 1
      data/erf/sub-003_erf.mat
  38. 1 1
      data/erf/sub-004_erf.mat
  39. 1 1
      data/erf/sub-005_erf.mat
  40. 1 1
      data/erf/sub-006_erf.mat
  41. 1 1
      data/erf/sub-007_erf.mat
  42. 1 1
      data/erf/sub-008_erf.mat
  43. 1 1
      data/erf/sub-009_erf.mat
  44. 1 1
      data/erf/sub-010_erf.mat
  45. 1 1
      data/erf/sub-011_erf.mat
  46. 1 1
      data/erf/sub-012_erf.mat
  47. 1 1
      data/erf/sub-013_erf.mat
  48. 1 1
      data/erf/sub-014_erf.mat
  49. 1 1
      data/erf/sub-015_erf.mat
  50. 1 1
      data/erf/sub-016_erf.mat
  51. 1 1
      data/erf/sub-017_erf.mat
  52. 1 1
      data/erf/sub-018_erf.mat
  53. 1 1
      data/erf/sub-019_erf.mat
  54. 1 1
      data/erf/sub-020_erf.mat
  55. 1 1
      data/erf/sub-021_erf.mat
  56. 1 1
      data/erf/sub-022_erf.mat
  57. 1 1
      data/erf/sub-023_erf.mat
  58. 1 1
      data/erf/sub-024_erf.mat
  59. 1 1
      data/erf/sub-025_erf.mat
  60. 1 1
      data/erf/sub-026_erf.mat
  61. 1 1
      data/erf/sub-027_erf.mat
  62. 1 1
      data/erf/sub-028_erf.mat
  63. 1 1
      data/erf/sub-029_erf.mat
  64. 1 1
      data/erf/sub-030_erf.mat
  65. 1 1
      data/erf/sub-031_erf.mat
  66. 1 1
      data/erf/sub-032_erf.mat
  67. 1 1
      data/erf/sub-033_erf.mat
  68. 1 1
      data/erp/sub-001_erp.mat
  69. 1 1
      data/erp/sub-001_erp_bl.mat
  70. 1 1
      data/erp/sub-002_erp.mat
  71. 1 1
      data/erp/sub-002_erp_bl.mat
  72. 1 1
      data/erp/sub-003_erp.mat
  73. 1 1
      data/erp/sub-003_erp_bl.mat
  74. 1 1
      data/erp/sub-004_erp.mat
  75. 1 1
      data/erp/sub-004_erp_bl.mat
  76. 1 1
      data/erp/sub-005_erp.mat
  77. 1 1
      data/erp/sub-005_erp_bl.mat
  78. 1 1
      data/erp/sub-006_erp.mat
  79. 1 1
      data/erp/sub-006_erp_bl.mat
  80. 1 1
      data/erp/sub-007_erp.mat
  81. 1 1
      data/erp/sub-007_erp_bl.mat
  82. 1 1
      data/erp/sub-008_erp.mat
  83. 1 1
      data/erp/sub-008_erp_bl.mat
  84. 1 1
      data/erp/sub-009_erp.mat
  85. 1 1
      data/erp/sub-009_erp_bl.mat
  86. 1 1
      data/erp/sub-010_erp.mat
  87. 1 1
      data/erp/sub-010_erp_bl.mat
  88. 1 1
      data/erp/sub-011_erp.mat
  89. 1 1
      data/erp/sub-011_erp_bl.mat
  90. 1 1
      data/erp/sub-012_erp.mat
  91. 1 1
      data/erp/sub-012_erp_bl.mat
  92. 1 1
      data/erp/sub-013_erp.mat
  93. 1 1
      data/erp/sub-013_erp_bl.mat
  94. 1 1
      data/erp/sub-014_erp.mat
  95. 1 1
      data/erp/sub-014_erp_bl.mat
  96. 1 1
      data/erp/sub-015_erp.mat
  97. 1 1
      data/erp/sub-015_erp_bl.mat
  98. 1 1
      data/erp/sub-016_erp.mat
  99. 1 1
      data/erp/sub-016_erp_bl.mat
  100. 0 0
      data/erp/sub-017_erp.mat

+ 262 - 0
README.md

@@ -0,0 +1,262 @@
+[![made-with-datalad](https://www.datalad.org/badges/made_with.svg)](https://datalad.org)
+
+# **EEGmanypipelines analysis**
+
+**a_eegmp_calculate_erp_tfr**
+
+- 50, 100, 150 Hz notch filter
+- CSD transform implemented via spherical splines using eeg1005 template
+- time-frequency transform using superlets
+- TFR: single-trial log10, no baseline
+- ERP: single-trial baseline -200:0 ms subtraction
+- condition averaging
+
+**b_scenecat_n1_bl**
+
+Assess effect of scene novelty on visual N1 peak amplitude.
+
+<details>
+
+  <summary>Expand figures</summary>
+
+  Figure 1a:
+
+  <img src='figures/b_topo_minimum.png' width = 200 />
+
+  Figure 1b:
+
+  <img src='figures/b_twogroups.png' width = 200 />
+
+  Figure 1c:
+
+  <img src='figures/b_scenecat_N1.png' width = 200 />
+
+  Figure 1d:
+
+  <img src='figures/b_rcp.png' width = 200 />
+
+  Topography around N1 trough:
+
+  <img src='figures/b_trough_topo.png' width = 200 />
+
+</details> <br/>
+
+**c1_taskPLS_novelty_frontal_erp**
+
+Assess effect of image novelty on fronto-central voltage.
+
+<details>
+
+  <summary>Expand figures</summary>
+
+  Figure 2a:
+
+  <img src='figures/c1_frontal_erp_topo.png' width = 200 />
+
+  Figure 2b:
+
+  <img src='figures/c1_frontalerp_rcp.png' width = 200 />
+
+  Figure 2c:
+
+  <img src='figures/c_novelty_frontalERP.png' width = 200 />
+
+  Figure 2d:
+
+  <img src='figures/c_novelty_centralERP.png' width = 200 />
+
+</details> <br/>
+
+**c2_taskPLS_novelty_frontal_theta**
+
+Assess effect of image novelty on fronto-central theta power.
+
+<details>
+
+  <summary>Expand figures</summary>
+
+  Figure 3a:
+
+  <img src='figures/c_theta_topo.png' width = 200 />
+
+  Figure 3b:
+
+  <img src='figures/c_theta_rcp.png' width = 200 />
+
+  Figure 3c:
+
+  <img src='figures/c_novelty_frontaltheta.png' width = 200 />
+
+</details> <br/>
+
+**c3_taskPLS_novelty_posterior_alpha**
+
+Assess effect of image novelty on posterior alpha power.
+
+<details>
+
+  <summary>Expand figures</summary>
+
+  Figure 4:
+
+  <img src='figures/c_novelty_alpha.png' width = 200 />
+
+</details> <br/>
+
+**d1_taskPLS_recognition_erp**
+
+Assess effect of successful 'old' recognition on voltage.
+
+<details>
+
+  <summary>Expand figures</summary>
+
+  Figure 5a:
+
+  <img src='figures/d1_rec_erp_bsr.png' width = 200 />
+
+  Figure 5b:
+
+  <img src='figures/d1_rec_erp_rcp.png' width = 200 />
+
+</details> <br/>
+
+**d2_taskPLS_recognition_erf**
+
+Assess effect of successful 'old' recognition on spectral power.
+
+<details>
+
+  <summary>Expand figures</summary>
+
+  Figure 6a:
+
+  <img src='figures/d2_erf_bsr.png' width = 200 />
+
+  Figure 6b:
+
+  <img src='figures/d2_erf_rcp.png' width = 200 />
+
+  Figure 6c:
+
+  <img src='figures/d2_erf_theta_trace.png' width = 200 />
+  <img src='figures/d2_erf_topo4.png' width = 200 />
+  <img src='figures/d2_erf_topo2.png' width = 200 />
+
+  Figure 6d:
+
+  <img src='figures/d2_erf_latealpha_trace.png' width = 200 />
+  <img src='figures/d2_erf_topo3.png' width = 200 />
+  <img src='figures/d2_erf_topo1.png' width = 200 />
+
+</details> <br/>
+
+**e1_taskPLS_memory_erp**
+
+Assess effect of subsequent memory on voltage.
+
+**e2_taskPLS_memory_erf**
+
+Assess effect of subsequent memory on spectral power.
+
+<details>
+
+  <summary>Expand figures</summary>
+
+  Figure 7a:
+
+  <img src='figures/e2_memory_erf_loadings.png' width = 200 />
+
+  Figure 7b:
+
+  <img src='figures/e2_memory_erf_rcp.png' width = 200 />
+
+  Figure 7c:
+
+  <img src='figures/e2_memory_erf_topo_theta.png' width = 200 />
+  <img src='figures/e2_memory_theta.png' width = 200 />
+
+  Figure 7d:
+
+  <img src='figures/e2_memory_erf_topo_alpha.png' width = 200 />
+  <img src='figures/e2_memory_alpha.png' width = 200 />
+
+</details> <br/>
+
+---
+
+# **DataLad datasets and how to use them**
+
+This repository is a [DataLad](https://www.datalad.org/) dataset. It provides
+fine-grained data access down to the level of individual files, and allows for
+tracking future updates. In order to use this repository for data retrieval,
+[DataLad](https://www.datalad.org/) is required. It is a free and
+open source command line tool, available for all major operating
+systems, and builds up on Git and [git-annex](https://git-annex.branchable.com/)
+to allow sharing, synchronizing, and version controlling collections of
+large files. You can find information on how to install DataLad at
+[handbook.datalad.org/en/latest/intro/installation.html](http://handbook.datalad.org/en/latest/intro/installation.html).
+
+### Get the dataset
+
+A DataLad dataset can be `cloned` by running
+
+```
+datalad clone <url>
+```
+
+Once a dataset is cloned, it is a light-weight directory on your local machine.
+At this point, it contains only small metadata and information on the
+identity of the files in the dataset, but not actual *content* of the
+(sometimes large) data files.
+
+### Retrieve dataset content
+
+After cloning a dataset, you can retrieve file contents by running
+
+```
+datalad get <path/to/directory/or/file>`
+```
+
+This command will trigger a download of the files, directories, or
+subdatasets you have specified.
+
+DataLad datasets can contain other datasets, so called *subdatasets*.
+If you clone the top-level dataset, subdatasets do not yet contain
+metadata and information on the identity of files, but appear to be
+empty directories. In order to retrieve file availability metadata in
+subdatasets, run
+
+```
+datalad get -n <path/to/subdataset>
+```
+
+Afterwards, you can browse the retrieved metadata to find out about
+subdataset contents, and retrieve individual files with `datalad get`.
+If you use `datalad get <path/to/subdataset>`, all contents of the
+subdataset will be downloaded at once.
+
+### Stay up-to-date
+
+DataLad datasets can be updated. The command `datalad update` will
+*fetch* updates and store them on a different branch (by default
+`remotes/origin/master`). Running
+
+```
+datalad update --merge
+```
+
+will *pull* available updates and integrate them in one go.
+
+### Find out what has been done
+
+DataLad datasets contain their history in the ``git log``.
+By running ``git log`` (or a tool that displays Git history) in the dataset or on
+specific files, you can find out what has been done to the dataset or to individual files
+by whom, and when.
+
+### More information
+
+More information on DataLad and how to use it can be found in the DataLad Handbook at
+[handbook.datalad.org](http://handbook.datalad.org/en/latest/index.html). The chapter
+"DataLad datasets" can help you to familiarize yourself with the concept of a dataset.

+ 5 - 4
code/a_eegmp_calculate_erp_tfr.m

@@ -33,18 +33,19 @@ data_eeg = ft_preprocessing(cfg, data_eeg);
 csd_cfg = [];
 csd_cfg.elecfile = 'standard_1005.elc';
 csd_cfg.method = 'spline';
+csd_cfg.degree = 14;
 data_eeg = ft_scalpcurrentdensity(csd_cfg, data_eeg);
 
-%% time-frequency transform using wavelets
+%% time-frequency transform using superlets
 
 freq_cfg = [];
 freq_cfg.channel     = 'all';
-freq_cfg.method      = 'wavelet';
-freq_cfg.width       = 5;
+freq_cfg.method      = 'superlet';
+freq_cfg.width       = 3;
 freq_cfg.keeptrials  = 'yes';
 freq_cfg.output      = 'pow';
 freq_cfg.foi         = 1:1:40;
-freq_cfg.toi         = -1:0.05:2;
+freq_cfg.toi         = -1:0.025:2;
 tfr = ft_freqanalysis(freq_cfg, data_eeg);
 
 % single-trial log10-transform

+ 0 - 109
code/b1_taskPLS_scenecat_N1.m

@@ -1,109 +0,0 @@
-% Set up EEG PLS for a task PLS using spectral power
-
-clear all; cla; clc;
-
-currentFile = mfilename('fullpath');
-[pathstr,~,~] = fileparts(currentFile);
-cd(fullfile(pathstr,'..'))
-rootpath = pwd;
-
-pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
-pn.data_erp = fullfile(rootpath, 'data', 'erp');
-pn.data_erf = fullfile(rootpath, 'data', 'erf');
-pn.data = fullfile(rootpath, 'data', 'stats'); mkdir(pn.data);
-pn.tools = fullfile(rootpath, 'tools');
-    addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
-    addpath(genpath(fullfile(pn.tools, '[MEG]PLS', 'MEGPLS_PIPELINE_v2.02b')))
-    addpath(fullfile(pn.tools, 'BrewerMap'));
-    addpath(fullfile(pn.tools, 'shadedErrorBar'));
-
-%% add seed for reproducibility
-
-rng(0, 'twister');
-    
-%% load event info
-
-load(fullfile(pn.data_eeg, ['sub-001_task-xxxx_eeg_art.mat']), 'events');
-
-parameter = {'scene_category'; 'old'; 'behavior'; 'subsequent_memory'};
-for ind_param = 1:numel(parameter)
-    conds.(parameter{ind_param}) = unique(events.(parameter{ind_param}));
-end
-
-%% load erp
-
-for ind_id = 1:33
-    id = sprintf('sub-%03d', ind_id);
-    load(fullfile(pn.data_erp, [id,'_erp_bl.mat']));
-    for ind_option = 1:numel(conds.scene_category)
-        if ind_id == 1
-             erpgroup.scene_category.(conds.scene_category{ind_option}) = erp_bl.scene_category{ind_option};
-             erpgroup.scene_category.(conds.scene_category{ind_option}) = ...
-                 rmfield(erpgroup.scene_category.(conds.scene_category{ind_option}), {'avg', 'var', 'dof'});
-             erpgroup.scene_category.(conds.scene_category{ind_option}).dimord = 'sub_chan_time';
-        end
-        % only include time points from 0 to 300 ms
-        time = erp_bl.scene_category{ind_option}.time;
-        toi = time >0 & time <0.3;        
-        erpgroup.scene_category.(conds.scene_category{ind_option}).avg(ind_id,:,:) = erp_bl.scene_category{ind_option}.avg(:,toi);
-    end
-end
-
-time = erpgroup.scene_category.manmade.time(toi);
-elec = erpgroup.scene_category.manmade.elec;
-channels = erpgroup.scene_category.manmade.label;
-
-mergeddata = cat(4, erpgroup.scene_category.manmade.avg, ...
-    erpgroup.scene_category.natural.avg);
-
-num_chans = numel(channels);
-num_freqs = 1;
-num_time = numel(time);
-
-num_subj_lst = [33];
-num_cond = 2;
-num_grp = 1;
-
-datamat_lst = cell(num_grp); lv_evt_list = [];
-indCount_cont = 1;
-indCount = 1;
-indGroup = 1;
-for indCond = 1:num_cond
-    for indID = 1:num_subj_lst(indGroup)
-        datamat_lst{indGroup}(indCount,:) = reshape(squeeze(mergeddata(indID,:,:,indCond)), [], 1);
-        lv_evt_list(indCount_cont) = indCond;
-        indCount = indCount+1;
-        indCount_cont = indCount_cont+1;
-    end
-end
-datamat_lst{indGroup}(isnan(datamat_lst{indGroup})) = 0;
-
-%% set PLS options and run PLS
-
-option = [];
-option.method = 1; % [1] | 2 | 3 | 4 | 5 | 6
-option.num_perm = 1000; %( single non-negative integer )
-option.num_split = 0; %( single non-negative integer )
-option.num_boot = 1000; % ( single non-negative integer )
-option.cormode = 0; % [0] | 2 | 4 | 6
-option.meancentering_type = 0;% [0] | 1 | 2 | 3
-option.boot_type = 'strat'; %['strat'] | 'nonstrat'
-
-result = pls_analysis(datamat_lst, num_subj_lst, num_cond, option);
-
-%% rearrange into fieldtrip structure
-
-lvdat = reshape(result.boot_result.compare_u(:,1), num_chans, num_freqs, num_time);
-%udat = reshape(result.u, num_chans, num_freqs, num_time);
-
-stat = [];
-stat.prob = lvdat;
-stat.dimord = 'chan_freq_time';
-stat.clusters = [];
-stat.clusters.prob = result.perm_result.sprob; % check for significance of LV
-stat.mask = lvdat > 3 | lvdat < -3;
-stat.cfg = option;
-stat.time = time;
-
-save(fullfile(pn.data, 'b01_taskpls_erp.mat'),...
-    'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')

+ 0 - 111
code/b1_taskPLS_scenecat_N1_avg.m

@@ -1,111 +0,0 @@
-% Set up EEG PLS for a task PLS using spectral power
-
-clear all; cla; clc;
-
-currentFile = mfilename('fullpath');
-[pathstr,~,~] = fileparts(currentFile);
-cd(fullfile(pathstr,'..'))
-rootpath = pwd;
-
-pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
-pn.data_erp = fullfile(rootpath, 'data', 'erp');
-pn.data_erf = fullfile(rootpath, 'data', 'erf');
-pn.data = fullfile(rootpath, 'data', 'stats'); mkdir(pn.data);
-pn.tools = fullfile(rootpath, 'tools');
-    addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
-    addpath(genpath(fullfile(pn.tools, '[MEG]PLS', 'MEGPLS_PIPELINE_v2.02b')))
-    addpath(fullfile(pn.tools, 'BrewerMap'));
-    addpath(fullfile(pn.tools, 'shadedErrorBar'));
-
-%% add seed for reproducibility
-
-rng(0, 'twister');
-    
-%% load event info
-
-load(fullfile(pn.data_eeg, ['sub-001_task-xxxx_eeg_art.mat']), 'events');
-
-parameter = {'scene_category'; 'old'; 'behavior'; 'subsequent_memory'};
-for ind_param = 1:numel(parameter)
-    conds.(parameter{ind_param}) = unique(events.(parameter{ind_param}));
-end
-
-%% load erp
-
-for ind_id = 1:33
-    id = sprintf('sub-%03d', ind_id);
-    load(fullfile(pn.data_erp, [id,'_erp.mat']));
-    for ind_option = 1:numel(conds.scene_category)
-        if ind_id == 1
-             erpgroup.scene_category.(conds.scene_category{ind_option}) = erp.scene_category{ind_option};
-             erpgroup.scene_category.(conds.scene_category{ind_option}) = ...
-                 rmfield(erpgroup.scene_category.(conds.scene_category{ind_option}), {'avg', 'var', 'dof'});
-             erpgroup.scene_category.(conds.scene_category{ind_option}).dimord = 'sub_chan_time';
-        end
-        % average in N1 time window
-        time = erpgroup.scene_category.(conds.scene_category{ind_option}).time;
-        toi = time >0.08 & time <0.12;
-        erpgroup.scene_category.(conds.scene_category{ind_option}).avg(ind_id,:,:) = nanmean(erp.scene_category{ind_option}.avg(:,toi),2);
-    end
-end
-
-% average in N1 time window
-
-time = 0.1;
-elec = erpgroup.scene_category.manmade.elec;
-channels = erpgroup.scene_category.manmade.label;
-
-mergeddata = cat(4, erpgroup.scene_category.manmade.avg, ...
-    erpgroup.scene_category.natural.avg);
-
-num_chans = numel(channels);
-num_freqs = 1;
-num_time = numel(time);
-
-num_subj_lst = [33];
-num_cond = 2;
-num_grp = 1;
-
-datamat_lst = cell(num_grp); lv_evt_list = [];
-indCount_cont = 1;
-indCount = 1;
-indGroup = 1;
-for indCond = 1:num_cond
-    for indID = 1:num_subj_lst(indGroup)
-        datamat_lst{indGroup}(indCount,:) = reshape(squeeze(mergeddata(indID,:,:,indCond)), [], 1);
-        lv_evt_list(indCount_cont) = indCond;
-        indCount = indCount+1;
-        indCount_cont = indCount_cont+1;
-    end
-end
-datamat_lst{indGroup}(isnan(datamat_lst{indGroup})) = 0;
-
-%% set PLS options and run PLS
-
-option = [];
-option.method = 1; % [1] | 2 | 3 | 4 | 5 | 6
-option.num_perm = 1000; %( single non-negative integer )
-option.num_split = 0; %( single non-negative integer )
-option.num_boot = 1000; % ( single non-negative integer )
-option.cormode = 0; % [0] | 2 | 4 | 6
-option.meancentering_type = 0;% [0] | 1 | 2 | 3
-option.boot_type = 'strat'; %['strat'] | 'nonstrat'
-
-result = pls_analysis(datamat_lst, num_subj_lst, num_cond, option);
-
-%% rearrange into fieldtrip structure
-
-lvdat = reshape(result.boot_result.compare_u(:,1), num_chans, num_freqs, num_time);
-%udat = reshape(result.u, num_chans, num_freqs, num_time);
-
-stat = [];
-stat.prob = lvdat;
-stat.dimord = 'chan_freq_time';
-stat.clusters = [];
-stat.clusters.prob = result.perm_result.sprob; % check for significance of LV
-stat.mask = lvdat > 3 | lvdat < -3;
-stat.cfg = option;
-stat.time = time;
-
-save(fullfile(pn.data, 'b01_taskpls_erp_avg.mat'),...
-    'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')

+ 0 - 181
code/b2a_taskPLS_novelty_frontal_erp_plotLV1.m

@@ -1,181 +0,0 @@
-% Create an overview plot featuring the results of the multivariate PLS
-% comparing spectral changes during the stimulus period under load
-
-clear all; cla; clc;
-
-currentFile = mfilename('fullpath');
-[pathstr,~,~] = fileparts(currentFile);
-cd(fullfile(pathstr,'..'))
-rootpath = pwd;
-
-pn.data         = fullfile(rootpath, 'data', 'stats');
-pn.figures      = fullfile(rootpath, 'figures');
-pn.tools        = fullfile(rootpath, 'tools');
-    addpath(genpath(fullfile(pn.tools, '[MEG]PLS', 'MEGPLS_PIPELINE_v2.02b')))
-    addpath(fullfile(pn.tools, 'fieldtrip')); ft_defaults;
-    addpath(genpath(fullfile(pn.tools, 'RainCloudPlots')));
-    addpath(fullfile(pn.tools, 'BrewerMap'));
-    addpath(fullfile(pn.tools, 'winsor'));
-
-% set custom colormap
-cBrew = brewermap(500,'RdBu');
-cBrew = flipud(cBrew);
-colormap(cBrew)
-
-load(fullfile(pn.data, 'c01_taskpls_erp.mat'),...
-    'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
-load(fullfile(rootpath, 'data','erp', ['sub-001_erp.mat']));
-elec = erp.scene_category{1}.elec;
-
-result.perm_result.sprob
-
-indLV = 1;
-
-lvdat = reshape(result.boot_result.compare_u(:,indLV), num_chans, num_freqs, num_time);
-stat.prob = lvdat;
-stat.mask = lvdat > 3 | lvdat < -3;
-
-% maskNaN = double(stat.mask);
-% maskNaN(maskNaN==0) = NaN;
-
-%% invert solution
-
-% stat.mask = stat.mask;
-% stat.prob = stat.prob.*-1;
-% result.vsc = result.vsc.*-1;
-% result.usc = result.usc.*-1;
-
-h = figure('units','centimeter','position',[0 0 15 10]);
-set(gcf,'renderer','Painters')
-statsPlot = [];
-statsPlot = cat(1, statsPlot,squeeze(nanmax(abs(stat.prob(1:64,:,:)),[],1)));
-plot(stat.time,statsPlot, 'k')
-xlabel('Time [s from stim onset]'); ylabel('max abs BSR');
-title({'ERP changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
-set(findall(gcf,'-property','FontSize'),'FontSize',18)
-% figureName = ['b01_pls_traces'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
-
-
-h = figure('units','centimeter','position',[0 0 15 10]);
-set(gcf,'renderer','Painters')
-statsPlot = [];
-statsPlot = cat(1, statsPlot,squeeze(mean(stat.prob(1:64,:,:),1)));
-plot(stat.time,statsPlot, 'k')
-xlabel('Time [s from stim onset]'); ylabel('mean BSR');
-title({'ERP changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
-set(findall(gcf,'-property','FontSize'),'FontSize',18)
-%xlim([0 0.3])
-% figureName = ['b01_pls_traces'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
-
-%% plot multivariate topographies
-
-h = figure('units','centimeters','position',[0 0 10 10]);
-set(gcf,'renderer','Painters')
-
-cfg = [];
-cfg.layout = 'biosemi64.lay';
-cfg.parameter = 'powspctrm';
-cfg.comment = 'no';
-cfg.colormap = cBrew;
-cfg.colorbar = 'EastOutside';
-
-plotData = [];
-plotData.label = elec.label; % {1 x N}
-plotData.dimord = 'chan';
-cfg.zlim = [-2 2]; 
-cfg.figure = h;
-plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,:).*...
-    stat.prob(:,:,:),3)); 
-ft_topoplotER(cfg,plotData);
-cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
-figureName = ['b01_lv1'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
-
-%% plot using raincloud plot
-
-groupsizes=result.num_subj_lst;
-conditions=lv_evt_list;
-conds = {'old'; 'new'};
-condData = []; uData = [];
-for indGroup = 1
-    if indGroup == 1
-        relevantEntries = 1:groupsizes(1)*numel(conds);
-    elseif indGroup == 2
-        relevantEntries = groupsizes(1)*numel(conds)+1:...
-             groupsizes(1)*numel(conds)+groupsizes(2)*numel(conds);
-    end
-    for indCond = 1:numel(conds)
-        targetEntries = relevantEntries(conditions(relevantEntries)==indCond);        
-        condData{indGroup}(indCond,:) = result.vsc(targetEntries,indLV);
-        uData{indGroup}(indCond,:) = result.usc(targetEntries,indLV);
-    end
-end
-
-%% plot RainCloudPlot (within-subject centered)
-
-cBrew(1,:) = 2.*[.3 .1 .1];
-cBrew(2,:) = [.6 .6 .6];
-
-idx_outlier = cell(1); idx_standard = cell(1);
-for indGroup = 1
-    dataToPlot = uData{indGroup}';
-    % define outlier as lin. modulation that is more than three scaled median absolute deviations (MAD) away from the median
-    X = [1 1; 1 2]; b=X\dataToPlot'; IndividualSlopes = b(2,:);
-    outliers = isoutlier(IndividualSlopes, 'median');
-    idx_outlier{indGroup} = find(outliers);
-    idx_standard{indGroup} = find(outliers==0);
-end
-
-h = figure('units','centimeter','position',[0 0 25 10]);
-for indGroup = 1
-    dataToPlot = uData{indGroup}';
-    % read into cell array of the appropriate dimensions
-    data = []; data_ws = [];
-    for i = 1:2
-        for j = 1:1
-            data{i, j} = dataToPlot(:,i);
-            % individually demean for within-subject visualization
-            data_ws{i, j} = dataToPlot(:,i)-...
-                nanmean(dataToPlot(:,:),2)+...
-                repmat(nanmean(nanmean(dataToPlot(:,:),2),1),size(dataToPlot(:,:),1),1);
-            data_nooutlier{i, j} = data{i, j};
-            data_nooutlier{i, j}(idx_outlier{indGroup}) = [];
-            data_ws_nooutlier{i, j} = data_ws{i, j};
-            data_ws_nooutlier{i, j}(idx_outlier{indGroup}) = [];
-            % sort outliers to back in original data for improved plot overlap
-            data_ws{i, j} = [data_ws{i, j}(idx_standard{indGroup}); data_ws{i, j}(idx_outlier{indGroup})];
-        end
-    end
-
-    % IMPORTANT: plot individually centered estimates, stats on uncentered estimates!
-
-    subplot(1,2,indGroup);
-    set(gcf,'renderer','Painters')
-        cla;
-        cl = cBrew(indGroup,:);
-        [~, dist] = rm_raincloud_fixedSpacing(data_ws, [.8 .8 .8],1);
-        h_rc = rm_raincloud_fixedSpacing(data_ws_nooutlier, cl,1,[],[],[],dist);
-        view([90 -90]);
-        axis ij
-    box(gca,'off')
-    set(gca, 'YTickLabels', {conds{2}; conds{1}});
-    yticks = get(gca, 'ytick'); ylim([yticks(1)-(yticks(2)-yticks(1))./2, yticks(2)+(yticks(2)-yticks(1))./1.5]);
-
-    minmax = [min(min(cat(2,data_ws{:}))), max(max(cat(2,data_ws{:})))];
-    xlim(minmax+[-0.2*diff(minmax), 0.2*diff(minmax)])
-    ylabel('novelty'); xlabel({'Brainscore'; '[Individually centered]'})
-
-    % test linear effect
-    curData = [data_nooutlier{1, 1}, data_nooutlier{2, 1}];
-    X = [1 1; 1 2]; b=X\curData'; IndividualSlopes = b(2,:);
-    [~, p, ci, stats] = ttest(IndividualSlopes);
-    title(['M:', num2str(round(mean(IndividualSlopes),3)), '; p=', num2str(round(p,3))])
-end
-% figureName = ['b01_rcp'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');

+ 0 - 156
code/b2a_taskPLS_novelty_frontal_erp_plot_trace.m

@@ -1,156 +0,0 @@
-
-currentFile = mfilename('fullpath');
-[pathstr,~,~] = fileparts(currentFile);
-cd(fullfile(pathstr,'..'))
-rootpath = pwd;
-
-pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
-pn.data_erp = fullfile(rootpath, 'data', 'erp');
-pn.data_erf = fullfile(rootpath, 'data', 'erf');
-pn.tools = fullfile(rootpath, 'tools');
-    addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
-    addpath(fullfile(pn.tools, 'BrewerMap'));
-    addpath(fullfile(pn.tools, 'shadedErrorBar'));
-    
-%% load erp
-
-for ind_id = 1:33
-    id = sprintf('sub-%03d', ind_id);
-    load(fullfile(pn.data_erp, [id,'_erp_bl.mat']));
-    for ind_option = 1:numel(conds.old)
-        if ind_id == 1
-             erpgroup.old.(conds.old{ind_option}) = erp_bl.old{ind_option};
-             erpgroup.old.(conds.old{ind_option}) = ...
-                 rmfield(erpgroup.old.(conds.old{ind_option}), {'avg', 'var', 'dof'});
-             erpgroup.old.(conds.old{ind_option}).dimord = 'sub_chan_time';
-        end
-        erpgroup.old.(conds.old{ind_option}).avg(ind_id,:,:) = erp_bl.old{ind_option}.avg;
-    end
-end
-
-time = erpgroup.old.old.time;
-elec = erpgroup.old.old.elec;
-channels = erpgroup.old.old.label;
-
-%idx_chans = find(ismember(channels, {'O1', 'Oz', 'O2'}));
-%idx_chans = find(ismember(channels, {'PO7', 'PO8'}));
-%idx_chans = find(ismember(channels, {'Pz', 'CPz', 'P1'}));
-
-mergeddata = cat(4, erpgroup.old.old.avg, ...
-    erpgroup.old.new.avg);
-
-%% plot ERP topography
-
-% set custom colormap
-cBrew = brewermap(500,'RdBu');
-cBrew = flipud(cBrew);
-colormap(cBrew)
-
-h = figure('units','centimeters','position',[0 0 10 10]);
-set(gcf,'renderer','Painters')
-
-cfg = [];
-cfg.layout = 'biosemi64.lay';
-cfg.parameter = 'powspctrm';
-cfg.comment = 'no';
-cfg.colormap = cBrew;
-cfg.colorbar = 'EastOutside';
-
-plotData = [];
-plotData.label = elec.label; % {1 x N}
-plotData.dimord = 'chan';
-plotData.powspctrm = squeeze(nanmean(nanmean(nanmean(mergeddata(:,:,time>=0.3& time <=0.5,1:2),3),1),4))'; 
-
-cfg.zlim = [-14 14]*10^-4; 
-cfg.figure = h;
-ft_topoplotER(cfg,plotData);
-cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
-% figureName = ['xxx'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
-
-%% visualize frontal ERP
-
-idx_chans = [38];
-
-% avg across channels and conditions
-condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% highlight relevant phase in background
-patches.timeVec = [0.3 0.5];
-patches.colorVec = [1 .95 .8];
-for indP = 1:size(patches.timeVec,2)-1
-    YLim = [-8 2]*10^-4;
-    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
-                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
-    p.EdgeColor = 'none';
-end
-% new value = old value ? subject average + grand average
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-% ax = gca; ax.YDir = 'reverse';
-legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
-    'location', 'southwest'); legend('boxoff')
-xlabel('Time (s) from stim onset')
-xlim([-.05 .6]); %ylim([-.03 .18])
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',14)
-
-%% plot difference
-
-idx_chans = [38];
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% highlight relevant phase in background
-patches.timeVec = [0.3 0.5];
-patches.colorVec = [1 .95 .8];
-for indP = 1:size(patches.timeVec,2)-1
-    YLim = [-10 5]*10^-5;
-    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
-                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
-    p.EdgeColor = 'none';
-end
-% new value = old value ? subject average + grand average
-curData = squeeze(mergeddata(:,idx_chans,:,2)-mergeddata(:,idx_chans,:,1));
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-legend([l1.mainLine],{'new-old'}, ...
-    'location', 'southwest'); legend('boxoff')
-xlabel('Time (s) from stim onset')
-xlim([-.05 .6]); %ylim([-.03 .18])
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',14)
-
-
-%% plot difference between conditions
-
-h = figure('units','centimeters','position',[0 0 10 10]);
-set(gcf,'renderer','Painters')
-
-cfg = [];
-cfg.layout = 'biosemi64.lay';
-cfg.parameter = 'powspctrm';
-cfg.comment = 'no';
-cfg.colormap = cBrew;
-cfg.colorbar = 'EastOutside';
-
-plotData = [];
-plotData.label = elec.label; % {1 x N}
-plotData.dimord = 'chan';
-oldminnew = mergeddata(:,:,:,1)-mergeddata(:,:,:,2);
-plotData.powspctrm = squeeze(nanmean(nanmean(oldminnew(:,:,time>=.3 & time <=.5),3),1))'; 
-
-cfg.figure = h;
-ft_topoplotER(cfg,plotData);
-cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');

+ 0 - 303
code/b_scenecat_n1.m

@@ -1,303 +0,0 @@
-
-currentFile = mfilename('fullpath');
-[pathstr,~,~] = fileparts(currentFile);
-cd(fullfile(pathstr,'..'))
-rootpath = pwd;
-
-pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
-pn.data_erp = fullfile(rootpath, 'data', 'erp');
-pn.data_erf = fullfile(rootpath, 'data', 'erf');
-pn.tools = fullfile(rootpath, 'tools');
-    addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
-    addpath(fullfile(pn.tools, 'BrewerMap'));
-    addpath(fullfile(pn.tools, 'shadedErrorBar'));
-    
-%% load event info
-
-load(fullfile(pn.data_eeg, ['sub-001_task-xxxx_eeg_art.mat']), 'events');
-
-parameter = {'scene_category'; 'old'; 'behavior'; 'subsequent_memory'};
-for ind_param = 1:numel(parameter)
-    conds.(parameter{ind_param}) = unique(events.(parameter{ind_param}));
-end
-
-%% load erp
-
-for ind_id = 1:33
-    id = sprintf('sub-%03d', ind_id);
-    load(fullfile(pn.data_erp, [id,'_erp.mat']));
-    for ind_option = 1:numel(conds.scene_category)
-        if ind_id == 1
-             erpgroup.scene_category.(conds.scene_category{ind_option}) = erp.scene_category{ind_option};
-             erpgroup.scene_category.(conds.scene_category{ind_option}) = ...
-                 rmfield(erpgroup.scene_category.(conds.scene_category{ind_option}), {'avg', 'var', 'dof'});
-             erpgroup.scene_category.(conds.scene_category{ind_option}).dimord = 'sub_chan_time';
-        end
-        erpgroup.scene_category.(conds.scene_category{ind_option}).avg(ind_id,:,:) = erp.scene_category{ind_option}.avg;
-    end
-end
-
-time = erpgroup.scene_category.manmade.time;
-elec = erpgroup.scene_category.manmade.elec;
-channels = erpgroup.scene_category.manmade.label;
-
-%idx_chans = find(ismember(channels, {'O1', 'Oz', 'O2'}));
-%idx_chans = find(ismember(channels, {'PO7', 'PO8'}));
-%idx_chans = find(ismember(channels, {'Pz', 'CPz', 'P1'}));
-
-mergeddata = cat(4, erpgroup.scene_category.manmade.avg, ...
-    erpgroup.scene_category.natural.avg);
-
-%% plot topography of visual N1
-
-% set custom colormap
-cBrew = brewermap(500,'RdBu');
-cBrew = flipud(cBrew);
-colormap(cBrew)
-
-h = figure('units','centimeters','position',[0 0 10 10]);
-set(gcf,'renderer','Painters')
-
-cfg = [];
-cfg.layout = 'EEG1010.lay';
-cfg.parameter = 'powspctrm';
-cfg.comment = 'no';
-cfg.colormap = cBrew;
-cfg.colorbar = 'EastOutside';
-
-plotData = [];
-plotData.label = elec.label(1:64); % {1 x N}
-plotData.dimord = 'chan';
-plotData.powspctrm = squeeze(nanmean(nanmean(nanmin(mergeddata(:,:,time>0.04 & time <0.12,1:2),[],3),1),4))'; 
-[~, sortidx] = sort(plotData.powspctrm, 'ascend');
-idx_chans = sortidx(1);
-idx_chans_visual = idx_chans;
-
-cfg.marker = 'off'; 
-cfg.highlight = 'yes';
-cfg.highlightchannel = plotData.label(idx_chans);
-cfg.highlightcolor = [1 0 0];
-cfg.highlightsymbol = '.';
-cfg.highlightsize = 18;
-cfg.zlim = [-10 10]*10^-4; 
-cfg.figure = h;
-ft_topoplotER(cfg,plotData);
-cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
-
-%% visualize N1 over negative maximum
-
-% avg across channels and conditions
-condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
-
-condAvg1 = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1),2),4));
-condAvg2 = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,2),2),4));
-
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% new value = old value ? subject average + grand average
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-% ax = gca; ax.YDir = 'reverse';
-xlabel('Time (s) from stim onset')
-xlim([-.025 .16]); %ylim([-.03 .18])
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',12)
-
-%% ERP components for subjects 1-17 and 18-33 are shifted in time!
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% new value = old value ? subject average + grand average
-curData = squeeze(nanmean(mergeddata(1:17,idx_chans,:,1),2));
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(nanmean(mergeddata(18:end,idx_chans,:,1),2));
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-% ax = gca; ax.YDir = 'reverse';
-xlabel('Time (s) from stim onset')
-xlim([-.025 .16]); %ylim([-.03 .18])
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',12)
-
-%% align individual subjects N1 to first negative peak
-
-% find individual minimum (avg. across conditions) between 40 and 120 ms
-
-time2search = find(time>0.04 & time <0.12);
-
-newtime = 0-100*(time(2)-time(1)):(time(2)-time(1)):0+100*(time(2)-time(1));
-
-for indID = 1:size(condAvg,1)
-    %[peaks, locs] = findpeaks(condAvg1(indID,:));
-    tmp = find(islocalmin(condAvg(indID,time2search), ...
-        'FlatSelection', 'center', ...
-        'MinSeparation', 25));
-    minVal1(indID) = condAvg1(indID,time2search(tmp(1)));
-    curmin = time2search(tmp(1));
-    alignedN1_1(indID,:) = condAvg1(indID,curmin-100:curmin+100);
-
-    minVal2(indID) = condAvg2(indID,time2search(tmp(1)));
-    curmin = time2search(tmp(1));
-    alignedN1_2(indID,:) = condAvg2(indID,curmin-100:curmin+100);
-    
-    alignedTopo(indID,:,:) = squeeze(nanmean(mergeddata(indID,:,curmin-100:curmin+100,1:2),4));
-end
-
-% alternatively: consider global minimum
-% for indID = 1:size(condAvg,1)
-%     [~, minLoc1(indID)] = min(condAvg(indID,time2search));
-%     curmin = time2search(minLoc1(indID));
-%     minVal1(indID) = condAvg1(indID,curmin);
-%     alignedN1_1(indID,:) = condAvg1(indID,curmin-100:curmin+100);
-%     [~, minLoc2(indID)] = min(condAvg(indID,time2search));
-%     curmin = time2search(minLoc2(indID));
-%     minVal1(indID) = condAvg2(indID,curmin);
-%     alignedN1_2(indID,:) = condAvg2(indID,curmin-100:curmin+100);
-% end
-
-mergeddata_aligned = cat(3, alignedN1_1, alignedN1_2);
-
-[h, p] = ttest(minVal1, minVal2)
-
-% avg across channels and conditions
-condAvg_al = squeeze(nanmean(mergeddata_aligned(:,:,1:2),3));
-
-% check that troughs are aligned
-% figure; imagesc(zscore(condAvg_al,[],2))
-% figure; imagesc(condAvg_al)
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% new value = old value ? subject average + grand average
-curData = squeeze(mergeddata_aligned(:,:,1));
-curData = curData-condAvg_al+repmat(nanmean(condAvg_al,1),size(condAvg_al,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(newtime*1000,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(mergeddata_aligned(:,:,2));
-curData = curData-condAvg_al+repmat(nanmean(condAvg_al,1),size(condAvg_al,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l2 = shadedErrorBar(newtime*1000,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-% ax = gca; ax.YDir = 'reverse';
-legend({'manmade', 'natural'}, 'location', 'NorthWest'); legend('boxoff')
-xlabel('Time (s) from local minimum')
-xlim([-100 100]); %ylim([-.03 .18])
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (ms) from local minimum'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',12)
-
-%% plot topography around detected trough
-
-h = figure('units','centimeters','position',[0 0 10 10]);
-set(gcf,'renderer','Painters')
-
-cfg = [];
-cfg.layout = 'EEG1010.lay';
-cfg.parameter = 'powspctrm';
-cfg.comment = 'no';
-cfg.colormap = cBrew;
-cfg.colorbar = 'EastOutside';
-
-plotData = [];
-plotData.label = elec.label(1:64); % {1 x N}
-plotData.dimord = 'chan';
-plotData.powspctrm = squeeze(nanmean(nanmean(alignedTopo(:, :, newtime>-.01 & newtime < .01),3),1))'; 
-[~, sortidx] = sort(plotData.powspctrm, 'ascend');
-idx_chans = sortidx(1);
-idx_chans_visual = idx_chans;
-
-cfg.marker = 'off'; 
-cfg.highlight = 'yes';
-cfg.highlightchannel = plotData.label(idx_chans);
-cfg.highlightcolor = [1 0 0];
-cfg.highlightsymbol = '.';
-cfg.highlightsize = 18;
-cfg.zlim = [-5 5]*10^-4; 
-cfg.figure = h;
-ft_topoplotER(cfg,plotData);
-cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
-
-%% plot difference between conditions
-
-h = figure('units','centimeters','position',[0 0 10 10]);
-set(gcf,'renderer','Painters')
-
-cfg = [];
-cfg.layout = 'biosemi64.lay';
-cfg.parameter = 'powspctrm';
-cfg.comment = 'no';
-cfg.colormap = cBrew;
-cfg.colorbar = 'EastOutside';
-
-plotData = [];
-plotData.label = elec.label; % {1 x N}
-plotData.dimord = 'chan';
-plotData.powspctrm = squeeze(nanmean(nanmean(nanmean(mergeddata(:,:,time>0.08 & time <0.12,2),3),1),4))'...
-    -squeeze(nanmean(nanmean(nanmean(mergeddata(:,:,time>0.08 & time <0.12,1),3),1),4))'; 
-[~, sortidx] = sort(plotData.powspctrm, 'ascend');
-idx_chans = sortidx(1:6);
-
-cfg.marker = 'off'; 
-cfg.highlight = 'yes';
-cfg.highlightchannel = plotData.label(idx_chans);
-cfg.highlightcolor = [1 0 0];
-cfg.highlightsymbol = '.';
-cfg.highlightsize = 18;
-%cfg.zlim = [-5 5]*10^-4; 
-cfg.figure = h;
-ft_topoplotER(cfg,plotData);
-cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
-
-
-%% visualize for negative pls channels
-
-idx_chans = [28:30];
-condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% new value = old value ? subject average + grand average
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-xlabel('Time (s) from stim onset')
-xlim([-1 2]); %ylim([-.03 .18])
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',12)
-
-%% visualize for positive pls channels
-
-idx_chans = [21:23, 58:62];
-condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% new value = old value ? subject average + grand average
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-xlabel('Time (s) from stim onset')
-xlim([-1 2]); %ylim([-.03 .18])
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',12)

+ 73 - 16
code/b_scenecat_n1_bl.m

@@ -11,17 +11,9 @@ pn.tools = fullfile(rootpath, 'tools');
     addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
     addpath(fullfile(pn.tools, 'BrewerMap'));
     addpath(fullfile(pn.tools, 'shadedErrorBar'));
+    addpath(genpath(fullfile(pn.tools, 'RainCloudPlots')));
 pn.figures = fullfile(rootpath, 'figures');
 
-%% load event info
-
-load(fullfile(pn.data_eeg, ['sub-001_task-xxxx_eeg_art.mat']), 'events');
-
-parameter = {'scene_category'; 'old'; 'behavior'; 'subsequent_memory'};
-for ind_param = 1:numel(parameter)
-    conds.(parameter{ind_param}) = unique(events.(parameter{ind_param}));
-end
-
 %% load erp_bl
 
 for ind_id = 1:33
@@ -42,10 +34,6 @@ time = erpgroup.scene_category.manmade.time;
 elec = erpgroup.scene_category.manmade.elec;
 channels = erpgroup.scene_category.manmade.label;
 
-%idx_chans = find(ismember(channels, {'O1', 'Oz', 'O2'}));
-%idx_chans = find(ismember(channels, {'PO7', 'PO8'}));
-%idx_chans = find(ismember(channels, {'Pz', 'CPz', 'P1'}));
-
 mergeddata = cat(4, erpgroup.scene_category.manmade.avg, ...
     erpgroup.scene_category.natural.avg);
 
@@ -110,7 +98,6 @@ saveas(h, fullfile(pn.figures, figureName), 'png');
 
 % avg across channels and conditions
 condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
-
 condAvg1 = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1),2),4));
 condAvg2 = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,2),2),4));
 
@@ -136,7 +123,6 @@ set(findall(gcf,'-property','FontSize'),'FontSize',12)
 
 h = figure('units','centimeters','position',[0 0 10 8]);
 cla; hold on;
-% new value = old value ? subject average + grand average
 curData = squeeze(nanmean(mergeddata(1:17,idx_chans,:,1),2));
 standError = nanstd(curData,1)./sqrt(size(curData,1));
 l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
@@ -164,7 +150,6 @@ time2search = find(time>0.04 & time <0.12);
 newtime = 0-100*(time(2)-time(1)):(time(2)-time(1)):0+100*(time(2)-time(1));
 
 for indID = 1:size(condAvg,1)
-    %[peaks, locs] = findpeaks(condAvg1(indID,:));
     tmp = find(islocalmin(condAvg(indID,time2search), ...
         'FlatSelection', 'center', ...
         'MinSeparation', 25));
@@ -261,6 +246,78 @@ figureName = ['b_trough_topo'];
 saveas(h, fullfile(pn.figures, figureName), 'epsc');
 saveas(h, fullfile(pn.figures, figureName), 'png');
 
+%% plot raincloudplot of extracted N1 peak amplitudes
+
+% Note that the stats reported here may vary from above in the case of
+% outliers.
+
+conds = {'manmade'; 'natural'};
+uData{1} = [minVal1; minVal2];
+
+cBrew(1,:) = [.6 .6 .6];
+
+idx_outlier = cell(1); idx_standard = cell(1);
+for indGroup = 1
+    dataToPlot = uData{indGroup}';
+    % define outlier as lin. modulation that is more than three scaled median absolute deviations (MAD) away from the median
+    X = [1 1; 1 2]; b=X\dataToPlot'; IndividualSlopes = b(2,:);
+    IndividualSlopes = uData{indGroup}(2,:)-uData{indGroup}(1,:);
+    outliers = isoutlier(IndividualSlopes, 'median');
+    idx_outlier{indGroup} = find(outliers);
+    idx_standard{indGroup} = find(outliers==0);
+end
+
+h = figure('units','centimeter','position',[0 0 10 8]);
+for indGroup = 1
+    dataToPlot = uData{indGroup}';
+    % read into cell array of the appropriate dimensions
+    data = []; data_ws = [];
+    for i = 1:2
+        for j = 1:1
+            data{i, j} = dataToPlot(:,i);
+            % individually demean for within-subject visualization
+            data_ws{i, j} = dataToPlot(:,i)-...
+                nanmean(dataToPlot(:,:),2)+...
+                repmat(nanmean(nanmean(dataToPlot(:,:),2),1),size(dataToPlot(:,:),1),1);
+            data_nooutlier{i, j} = data{i, j};
+            data_nooutlier{i, j}(idx_outlier{indGroup}) = [];
+            data_ws_nooutlier{i, j} = data_ws{i, j};
+            data_ws_nooutlier{i, j}(idx_outlier{indGroup}) = [];
+            % sort outliers to back in original data for improved plot overlap
+            data_ws{i, j} = [data_ws{i, j}(idx_standard{indGroup}); data_ws{i, j}(idx_outlier{indGroup})];
+        end
+    end
+
+    % IMPORTANT: plot individually centered estimates, stats on uncentered estimates!
+
+    set(gcf,'renderer','Painters')
+        cla;
+        cl = cBrew(indGroup,:);
+        [~, dist] = rm_raincloud_fixedSpacing(data_ws, [.8 .8 .8],1);
+        h_rc = rm_raincloud_fixedSpacing(data_ws_nooutlier, cl,1,[],[],[],dist);
+        view([90 -90]);
+        axis ij
+    box(gca,'off')
+    set(gca, 'YTickLabels', {'natural'; 'manmade'});
+    yticks = get(gca, 'ytick'); ylim([yticks(1)-(yticks(2)-yticks(1))./2, yticks(2)+(yticks(2)-yticks(1))./1.5]);
+
+    minmax = [min(min(cat(2,data_ws{:}))), max(max(cat(2,data_ws{:})))];
+    xlim(minmax+[-0.2*diff(minmax), 0.2*diff(minmax)])
+    ylabel('scene category'); xlabel({'ERP'; '[Individually centered]'})
+
+    % test linear effect
+    curData = [data_nooutlier{1, 1}, data_nooutlier{2, 1}];
+    X = [1 1; 1 2]; b=X\curData'; IndividualSlopes = b(2,:);
+    [~, p, ci, stats] = ttest(IndividualSlopes);
+    title(['M:', num2str(round(mean(IndividualSlopes),6)), '; p=', num2str(round(p,6))])
+end
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
+
+figureName = ['b_rcp'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+
 %% plot topography for different timewindows
 % 
 % timewins = [0.03 0.075; ...

+ 2 - 2
code/b2a_taskPLS_novelty_frontal_erp.m

@@ -57,7 +57,7 @@ mergeddata = cat(4, erpgroup.old.old.avg, ...
     erpgroup.old.new.avg);
 
 % identify frontal channels, and set everything else to zero
-idx_chans = startsWith(channels, 'F') | startsWith(channels, 'A') | startsWith(channels, 'C') & ~startsWith(channels, 'CP');
+idx_chans = startsWith(channels, 'F') | startsWith(channels, 'A') | startsWith(channels, 'C');% & ~startsWith(channels, 'CP');
 mergeddata(:, idx_chans==0,:,:) = 0;
 
 num_chans = numel(channels);
@@ -109,5 +109,5 @@ stat.mask = lvdat > 3 | lvdat < -3;
 stat.cfg = option;
 stat.time = time;
 
-save(fullfile(pn.data, 'c01_taskpls_erp.mat'),...
+save(fullfile(pn.data, 'c1_taskpls_erp.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')

+ 26 - 35
code/b2b_taskPLS_novelty_frontal_theta_plotLV1.m

@@ -22,7 +22,7 @@ cBrew = brewermap(500,'RdBu');
 cBrew = flipud(cBrew);
 colormap(cBrew)
 
-load(fullfile(pn.data, 'b2b_taskpls_theta.mat'),...
+load(fullfile(pn.data, 'c1_taskpls_erp.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
 load(fullfile(rootpath, 'data','erp', ['sub-001_erp.mat']));
 elec = erp.scene_category{1}.elec;
@@ -35,15 +35,10 @@ lvdat = reshape(result.boot_result.compare_u(:,indLV), num_chans, num_freqs, num
 stat.prob = lvdat;
 stat.mask = lvdat > 3 | lvdat < -3;
 
-% maskNaN = double(stat.mask);
-% maskNaN(maskNaN==0) = NaN;
+maskNaN = double(stat.mask);
+maskNaN(maskNaN==0) = NaN;
 
-%% invert solution
-
-stat.mask = stat.mask;
-stat.prob = stat.prob.*-1;
-result.vsc = result.vsc.*-1;
-result.usc = result.usc.*-1;
+%% explore temporal loadings
 
 % h = figure('units','centimeter','position',[0 0 15 10]);
 % set(gcf,'renderer','Painters')
@@ -53,10 +48,7 @@ result.usc = result.usc.*-1;
 % xlabel('Time [s from stim onset]'); ylabel('max abs BSR');
 % title({'ERP changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
 % set(findall(gcf,'-property','FontSize'),'FontSize',18)
-% figureName = ['b01_pls_traces'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
-
+% 
 % h = figure('units','centimeter','position',[0 0 15 10]);
 % set(gcf,'renderer','Painters')
 % statsPlot = [];
@@ -65,10 +57,6 @@ result.usc = result.usc.*-1;
 % xlabel('Time [s from stim onset]'); ylabel('mean BSR');
 % title({'ERP changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
 % set(findall(gcf,'-property','FontSize'),'FontSize',18)
-% %xlim([0 0.3])
-% % figureName = ['b01_pls_traces'];
-% % saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% % saveas(h, fullfile(pn.figures, figureName), 'png');
 
 %% plot multivariate topographies
 
@@ -85,24 +73,25 @@ cfg.colorbar = 'EastOutside';
 plotData = [];
 plotData.label = elec.label; % {1 x N}
 plotData.dimord = 'chan';
-cfg.zlim = [-6 6]; 
+cfg.zlim = [-4 4]; 
 cfg.figure = h;
-plotData.powspctrm = squeeze(nanmax(nanmax(stat.mask(:,:,:).*...
-    stat.prob(:,:,:),[],3),[],2));
+plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,:).*...
+    stat.prob(:,:,:),3));
 
 [~, sortind] = sort(plotData.powspctrm, 'descend');
 cfg.marker = 'off'; 
 cfg.highlight = 'yes';
-cfg.highlightchannel = plotData.label(sortind(1:3));
+cfg.highlightchannel = plotData.label(sortind([1:4])); % 38 (frontal) 32, 19, 56 (central)
 cfg.highlightcolor = [0 0 0];
 cfg.highlightsymbol = '.';
 cfg.highlightsize = 15;
 
 ft_topoplotER(cfg,plotData);
-cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Max BSR');
-figureName = ['b01_lv1'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
+cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
+
+figureName = ['c1_frontal_erp_topo'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
 
 %% plot using raincloud plot
 
@@ -119,15 +108,12 @@ for indGroup = 1
     end
     for indCond = 1:numel(conds)
         targetEntries = relevantEntries(conditions(relevantEntries)==indCond);        
-        condData{indGroup}(indCond,:) = -1.*result.vsc(targetEntries,indLV);
-        uData{indGroup}(indCond,:) = -1.*result.usc(targetEntries,indLV);
+        condData{indGroup}(indCond,:) = result.vsc(targetEntries,indLV);
+        uData{indGroup}(indCond,:) = result.usc(targetEntries,indLV);
     end
 end
 
-%% plot RainCloudPlot (within-subject centered)
-
 cBrew(1,:) = 2.*[.3 .1 .1];
-cBrew(2,:) = [.6 .6 .6];
 
 idx_outlier = cell(1); idx_standard = cell(1);
 for indGroup = 1
@@ -139,7 +125,8 @@ for indGroup = 1
     idx_standard{indGroup} = find(outliers==0);
 end
 
-h = figure('units','centimeter','position',[0 0 25 10]);
+h = figure('units','centimeter','position',[0 0 12 10]);
+ax = subplot(1,1,1);
 for indGroup = 1
     dataToPlot = uData{indGroup}';
     % read into cell array of the appropriate dimensions
@@ -162,7 +149,6 @@ for indGroup = 1
 
     % IMPORTANT: plot individually centered estimates, stats on uncentered estimates!
 
-    subplot(1,2,indGroup);
     set(gcf,'renderer','Painters')
         cla;
         cl = cBrew(indGroup,:);
@@ -184,6 +170,11 @@ for indGroup = 1
     [~, p, ci, stats] = ttest(IndividualSlopes);
     title(['M:', num2str(round(mean(IndividualSlopes),3)), '; p=', num2str(round(p,3))])
 end
-% figureName = ['b01_rcp'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
+% change tick order
+ax.XDir = 'reverse';
+set(ax, 'YTickLabels', {conds{1}; conds{2}});
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
+
+figureName = ['c1_frontalerp_rcp'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');

+ 268 - 0
code/c1_taskPLS_novelty_frontal_erp_trace.m

@@ -0,0 +1,268 @@
+
+currentFile = mfilename('fullpath');
+[pathstr,~,~] = fileparts(currentFile);
+cd(fullfile(pathstr,'..'))
+rootpath = pwd;
+
+pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
+pn.data_erp = fullfile(rootpath, 'data', 'erp');
+pn.data_erf = fullfile(rootpath, 'data', 'erf');
+pn.tools = fullfile(rootpath, 'tools');
+    addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
+    addpath(fullfile(pn.tools, 'BrewerMap'));
+    addpath(fullfile(pn.tools, 'shadedErrorBar'));
+pn.figures = fullfile(rootpath, 'figures');
+
+%% load erp
+
+for ind_id = 1:33
+    id = sprintf('sub-%03d', ind_id);
+    load(fullfile(pn.data_erp, [id,'_erp_bl.mat']));
+    for ind_option = 1:numel(conds.old)
+        if ind_id == 1
+             erpgroup.old.(conds.old{ind_option}) = erp_bl.old{ind_option};
+             erpgroup.old.(conds.old{ind_option}) = ...
+                 rmfield(erpgroup.old.(conds.old{ind_option}), {'avg', 'var', 'dof'});
+             erpgroup.old.(conds.old{ind_option}).dimord = 'sub_chan_time';
+        end
+        erpgroup.old.(conds.old{ind_option}).avg(ind_id,:,:) = erp_bl.old{ind_option}.avg;
+    end
+end
+
+time = erpgroup.old.old.time;
+elec = erpgroup.old.old.elec;
+channels = erpgroup.old.old.label;
+
+mergeddata = cat(4, erpgroup.old.old.avg, ...
+    erpgroup.old.new.avg);
+
+%% plot ERP topography
+% 
+% % set custom colormap
+% cBrew = brewermap(500,'RdBu');
+% cBrew = flipud(cBrew);
+% colormap(cBrew)
+% 
+% h = figure('units','centimeters','position',[0 0 10 10]);
+% set(gcf,'renderer','Painters')
+% 
+% cfg = [];
+% cfg.layout = 'biosemi64.lay';
+% cfg.parameter = 'powspctrm';
+% cfg.comment = 'no';
+% cfg.colormap = cBrew;
+% cfg.colorbar = 'EastOutside';
+% 
+% plotData = [];
+% plotData.label = elec.label; % {1 x N}
+% plotData.dimord = 'chan';
+% plotData.powspctrm = squeeze(nanmean(nanmean(nanmean(mergeddata(:,:,time>=0.3& time <=0.5,1:2),3),1),4))'; 
+% 
+% cfg.zlim = [-14 14]*10^-4; 
+% cfg.figure = h;
+% ft_topoplotER(cfg,plotData);
+% cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
+% % figureName = ['xxx'];
+% % saveas(h, fullfile(pn.figures, figureName), 'epsc');
+% % saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% visualize frontal ERP
+
+idx_chans = [38];
+
+% avg across channels and conditions
+condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% highlight relevant phase in background
+patches.timeVec = [0.3 0.5];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-8 2]*10^-4;
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+% ax = gca; ax.YDir = 'reverse';
+legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
+    'location', 'southwest'); legend('boxoff')
+xlabel('Time (s) from stim onset')
+xlim([-.05 .6]); %ylim([-.03 .18])
+ylabel({'ERP';'(microVolts)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',14)
+
+figureName = ['c_novelty_frontalERP'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% visualize central ERP
+
+idx_chans = [32, 19, 56];
+
+% avg across channels and conditions
+condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% highlight relevant phase in background
+patches.timeVec = [0.3 0.5];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-8 4]*10^-4;
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+% ax = gca; ax.YDir = 'reverse';
+legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
+    'location', 'southwest'); legend('boxoff')
+xlabel('Time (s) from stim onset')
+xlim([-.05 .6]); %ylim([-.03 .18])
+ylabel({'ERP';'(microVolts)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',14)
+
+figureName = ['c_novelty_centralERP'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% plot by group
+
+idx_chans = [4, 38];
+
+% avg across channels and conditions
+condAvg = squeeze(nanmean(nanmean(mergeddata(1:17,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 20 8]);
+subplot(1,2,1); cla; hold on;
+    % highlight relevant phase in background
+    patches.timeVec = [0.3 0.5];
+    patches.colorVec = [1 .95 .8];
+    for indP = 1:size(patches.timeVec,2)-1
+        YLim = [-8 2]*10^-4;
+        p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                    [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+        p.EdgeColor = 'none';
+    end
+    % new value = old value ? subject average + grand average
+    curData = squeeze(nanmean(mergeddata(1:17,idx_chans,:,1),2));
+    curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+    standError = nanstd(curData,1)./sqrt(size(curData,1));
+    l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+    curData = squeeze(nanmean(mergeddata(1:17,idx_chans,:,2),2));
+    curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+    standError = nanstd(curData,1)./sqrt(size(curData,1));
+    l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+    % ax = gca; ax.YDir = 'reverse';
+    legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
+        'location', 'southwest'); legend('boxoff')
+    xlabel('Time (s) from stim onset')
+    xlim([-.05 .6]); %ylim([-.03 .18])
+    ylabel({'ERP';'(microVolts)'});
+    xlabel({'Time (s)'});
+    title('Initial 17')
+    set(findall(gcf,'-property','FontSize'),'FontSize',14)
+subplot(1,2,2); cla; hold on;
+    % avg across channels and conditions
+    condAvg = squeeze(nanmean(nanmean(mergeddata(18:end,idx_chans,:,1:2),2),4));
+    % highlight relevant phase in background
+    patches.timeVec = [0.3 0.5];
+    patches.colorVec = [1 .95 .8];
+    for indP = 1:size(patches.timeVec,2)-1
+        YLim = [-8 2]*10^-4;
+        p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                    [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+        p.EdgeColor = 'none';
+    end
+    % new value = old value ? subject average + grand average
+    curData = squeeze(nanmean(mergeddata(18:end,idx_chans,:,1),2));
+    curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+    standError = nanstd(curData,1)./sqrt(size(curData,1));
+    l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+    curData = squeeze(nanmean(mergeddata(18:end,idx_chans,:,2),2));
+    curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+    standError = nanstd(curData,1)./sqrt(size(curData,1));
+    l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+    % ax = gca; ax.YDir = 'reverse';
+    legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
+        'location', 'southwest'); legend('boxoff')
+    xlabel('Time (s) from stim onset')
+    xlim([-.05 .6]); %ylim([-.03 .18])
+    ylabel({'ERP';'(microVolts)'});
+    xlabel({'Time (s)'});
+    title('Final 16')
+    set(findall(gcf,'-property','FontSize'),'FontSize',14)
+
+figureName = ['c_novelty_frontalERP_bygroup'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% plot difference
+
+idx_chans = [38];
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% highlight relevant phase in background
+patches.timeVec = [0.3 0.5];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-10 5]*10^-5;
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+% new value = old value ? subject average + grand average
+curData = squeeze(mergeddata(:,idx_chans,:,2)-mergeddata(:,idx_chans,:,1));
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+legend([l1.mainLine],{'new-old'}, ...
+    'location', 'southwest'); legend('boxoff')
+xlabel('Time (s) from stim onset')
+xlim([-.05 .6]); %ylim([-.03 .18])
+ylabel({'ERP';'(microVolts)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',14)
+
+
+%% plot difference between conditions
+
+h = figure('units','centimeters','position',[0 0 10 10]);
+set(gcf,'renderer','Painters')
+
+cfg = [];
+cfg.layout = 'biosemi64.lay';
+cfg.parameter = 'powspctrm';
+cfg.comment = 'no';
+cfg.colormap = cBrew;
+cfg.colorbar = 'EastOutside';
+
+plotData = [];
+plotData.label = elec.label; % {1 x N}
+plotData.dimord = 'chan';
+oldminnew = mergeddata(:,:,:,1)-mergeddata(:,:,:,2);
+plotData.powspctrm = squeeze(nanmean(nanmean(oldminnew(:,:,time>=.3 & time <=.5),3),1))'; 
+
+cfg.figure = h;
+ft_topoplotER(cfg,plotData);
+cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');

+ 328 - 0
code/c23_novelty_plot_theta_alpha.m

@@ -0,0 +1,328 @@
+clear all; cla; clc;
+
+currentFile = mfilename('fullpath');
+[pathstr,~,~] = fileparts(currentFile);
+cd(fullfile(pathstr,'..'))
+rootpath = pwd;
+
+pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
+pn.data_erp = fullfile(rootpath, 'data', 'erp');
+pn.data_erf = fullfile(rootpath, 'data', 'erf');
+pn.data = fullfile(rootpath, 'data', 'stats'); mkdir(pn.data);
+pn.tools = fullfile(rootpath, 'tools');
+    addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
+    addpath(genpath(fullfile(pn.tools, '[MEG]PLS', 'MEGPLS_PIPELINE_v2.02b')))
+    addpath(fullfile(pn.tools, 'BrewerMap'));
+    addpath(fullfile(pn.tools, 'shadedErrorBar'));
+pn.figures = fullfile(rootpath, 'figures');
+
+%% add seed for reproducibility
+
+rng(0, 'twister');
+
+%% load erp
+
+for ind_id = 1:33
+    id = sprintf('sub-%03d', ind_id); disp(id)
+    load(fullfile(pn.data_erf, [id,'_erf.mat']));
+    for ind_option = 1:numel(conds.old)
+        if ind_id == 1
+             erpgroup.old.(conds.old{ind_option}) = erf.old{ind_option};
+             erpgroup.old.(conds.old{ind_option}) = ...
+                 rmfield(erpgroup.old.(conds.old{ind_option}), {'powspctrm'});
+             erpgroup.old.(conds.old{ind_option}).dimord = 'sub_chan_freq_time';
+             freq = erpgroup.old.(conds.old{ind_option}).freq;
+        end
+        idx_freq_t = freq >2 & freq <8;
+        thetagroup.old.(conds.old{ind_option}).avg(ind_id,:,:,:) = squeeze(nanmean(erf.old{ind_option}.powspctrm(:,idx_freq_t,:),2));
+        idx_freq_a = freq >7 & freq <13;
+        alphagroup.old.(conds.old{ind_option}).avg(ind_id,:,:,:) = squeeze(nanmean(erf.old{ind_option}.powspctrm(:,idx_freq_a,:),2));
+    end
+end
+
+time = erpgroup.old.old.time;
+channels = erpgroup.old.old.label;
+
+% identify frontal channels
+%idx_chans_t = startsWith(channels, 'F') | startsWith(channels, 'A') | startsWith(channels, 'C') & ~startsWith(channels, 'CP');
+
+% identify parieto-occipital channels
+idx_chans_a = startsWith(channels, 'P') | startsWith(channels, 'O');
+
+%% visualize for frontal theta
+
+mergeddata = cat(4, thetagroup.old.old.avg, thetagroup.old.new.avg);
+
+%figure; imagesc(time, [],squeeze(nanmean(thetagroup.old.new.avg-thetagroup.old.old.avg,1)))
+
+idx_chans = [33,4,38]; 
+condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% highlight relevant phase in background
+patches.timeVec = [0.3 0.5];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-4.95 -4.8];
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+xlabel('Time (s) from stim onset')
+legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
+    'location', 'southeast'); legend('boxoff')
+xlim([-.5 1.5]); ylim(YLim)
+%xlim([-.05 .3]);
+ylabel({'theta power';'(log10)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
+
+figureName = ['c_novelty_frontaltheta'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% visualize for two groups
+
+idx_chans = [33,4,38]; 
+condAvg = squeeze(nanmean(nanmean(mergeddata(1:17,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 20 8]);
+subplot(1,2,1); cla; hold on;
+% highlight relevant phase in background
+patches.timeVec = [0.3 0.5];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-4.95 -4.75];
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(1:17,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(1:17,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+xlabel('Time (s) from stim onset')
+legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
+    'location', 'NorthEast'); legend('boxoff')
+xlim([-.5 1.5]); ylim(YLim)
+%xlim([-.05 .3]);
+ylabel({'theta power';'(log10)'});
+xlabel({'Time (s)'});
+title('Initial 17');
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
+
+subplot(1,2,2); cla; hold on;
+condAvg = squeeze(nanmean(nanmean(mergeddata(18:end,idx_chans,:,1:2),2),4));
+
+% highlight relevant phase in background
+patches.timeVec = [0.3 0.5];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-4.95 -4.75];
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(18:end,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(18:end,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+xlabel('Time (s) from stim onset')
+legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
+    'location', 'NorthEast'); legend('boxoff')
+xlim([-.5 1.5]); ylim(YLim)
+%xlim([-.05 .3]);
+ylabel({'theta power';'(log10)'});
+xlabel({'Time (s)'});
+title('Final 16');
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
+
+figureName = ['c_novelty_frontaltheta_bygroup'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% visualize for posterior alpha
+
+mergeddata = cat(4, alphagroup.old.old.avg, alphagroup.old.new.avg);
+
+idx_chans = idx_chans_a;
+condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% highlight relevant phase in background
+patches.timeVec = [0.3 0.5];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-5.2 -4.5];
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'k','linewidth', 3}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'r','linewidth', 3}, 'patchSaturation', .1);
+xlabel('Time (s) from stim onset')
+legend([l1.mainLine, l2.mainLine],{'old', 'new'}, 'location', 'northeast'); legend('boxoff')
+xlim([-.5 1.5]); ylim(YLim)
+%xlim([-.05 .3]);
+ylabel({'alpha power';'(log10)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',15)
+
+figureName = ['c_novelty_alpha'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% visualize for two groups
+
+idx_chans = idx_chans_a;
+condAvg = squeeze(nanmean(nanmean(mergeddata(1:17,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 20 8]);
+subplot(1,2,1); cla; hold on;
+% highlight relevant phase in background
+patches.timeVec = [0.3 0.5];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-5.2 -4.5];
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(1:17,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(1:17,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+xlabel('Time (s) from stim onset')
+legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
+    'location', 'NorthEast'); legend('boxoff')
+xlim([-.5 1.5]); ylim(YLim)
+%xlim([-.05 .3]);
+ylabel({'alpha power';'(log10)'});
+xlabel({'Time (s)'});
+title('Initial 17');
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
+
+subplot(1,2,2); cla; hold on;
+condAvg = squeeze(nanmean(nanmean(mergeddata(18:end,idx_chans,:,1:2),2),4));
+
+% highlight relevant phase in background
+patches.timeVec = [0.3 0.5];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-5.2 -4.5];
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(18:end,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(18:end,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+xlabel('Time (s) from stim onset')
+legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
+    'location', 'NorthEast'); legend('boxoff')
+xlim([-.5 1.5]); ylim(YLim)
+%xlim([-.05 .3]);
+ylabel({'alpha power';'(log10)'});
+xlabel({'Time (s)'});
+title('Final 16');
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
+
+figureName = ['c_novelty_alpha_bygroup'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% plot superimposed
+
+mergeddata = cat(4, thetagroup.old.old.avg, thetagroup.old.new.avg);
+
+idx_chans = [33,4,47]; 
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(nanmean(mergeddata(1:17,idx_chans,:,1:2),4),2));
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(nanmean(mergeddata(18:end,idx_chans,:,1:2),4),2));
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+xlabel('Time (s) from stim onset')
+legend([l1.mainLine, l2.mainLine],{'initial', 'final'}, ...
+    'location', 'southeast'); legend('boxoff')
+xlim([-.5 1.5]); ylim([-5.1 -4.75])
+ylabel({'theta power';'(log10)'});
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
+
+mergeddata = cat(4, alphagroup.old.old.avg, alphagroup.old.new.avg);
+
+idx_chans = idx_chans_a;
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(nanmean(mergeddata(1:17,idx_chans,:,1:2),4),2));
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(nanmean(mergeddata(18:end,idx_chans,:,1:2),4),2));
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
+    {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+xlabel('Time (s) from stim onset')
+legend([l1.mainLine, l2.mainLine],{'initial', 'final'}, ...
+    'location', 'southeast'); legend('boxoff')
+xlim([-.5 1.5]); ylim([-5.2 -4.5])
+ylabel({'alpha power';'(log10)'});
+set(findall(gcf,'-property','FontSize'),'FontSize',12)

+ 2 - 2
code/b2b_taskPLS_novelty_frontal_theta.m

@@ -49,7 +49,7 @@ channels = erpgroup.old.old.label;
 mergeddata = cat(5, erpgroup.old.old.avg, erpgroup.old.new.avg);
 
 % identify frontal channels, and set everything else to zero
-idx_chans = startsWith(channels, 'F') | startsWith(channels, 'A') | startsWith(channels, 'C') & ~startsWith(channels, 'CP');
+idx_chans = startsWith(channels, 'F') | startsWith(channels, 'A') | startsWith(channels, 'C'); % & ~startsWith(channels, 'CP');
 mergeddata(:, idx_chans==0,:,:,:) = 0;
 
 num_chans = numel(channels);
@@ -102,5 +102,5 @@ stat.cfg = option;
 stat.freq = freq;
 stat.time = time;
 
-save(fullfile(pn.data, 'b2b_taskpls_theta.mat'),...
+save(fullfile(pn.data, 'c2_taskpls_theta.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')

+ 35 - 49
code/b1_taskPLS_scenecat_N1_plotLV1.m

@@ -22,7 +22,7 @@ cBrew = brewermap(500,'RdBu');
 cBrew = flipud(cBrew);
 colormap(cBrew)
 
-load(fullfile(pn.data, 'b01_taskpls_erp.mat'),...
+load(fullfile(pn.data, 'c2_taskpls_theta.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
 load(fullfile(rootpath, 'data','erp', ['sub-001_erp.mat']));
 elec = erp.scene_category{1}.elec;
@@ -40,36 +40,10 @@ stat.mask = lvdat > 3 | lvdat < -3;
 
 %% invert solution
 
-% stat.mask = stat.mask;
-% stat.prob = stat.prob.*-1;
-% result.vsc = result.vsc.*-1;
-% result.usc = result.usc.*-1;
-
-h = figure('units','centimeter','position',[0 0 15 10]);
-set(gcf,'renderer','Painters')
-statsPlot = [];
-statsPlot = cat(1, statsPlot,squeeze(nanmax(abs(stat.prob(1:64,:,:)),[],1)));
-plot(stat.time,statsPlot, 'k')
-xlabel('Time [s from stim onset]'); ylabel('max abs BSR');
-title({'ERP changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
-set(findall(gcf,'-property','FontSize'),'FontSize',18)
-figureName = ['b01_pls_traces'];
-saveas(h, fullfile(pn.figures, figureName), 'epsc');
-saveas(h, fullfile(pn.figures, figureName), 'png');
-
-
-h = figure('units','centimeter','position',[0 0 15 10]);
-set(gcf,'renderer','Painters')
-statsPlot = [];
-statsPlot = cat(1, statsPlot,squeeze(mean(stat.prob(1:64,:,:),1)));
-plot(stat.time,statsPlot, 'k')
-xlabel('Time [s from stim onset]'); ylabel('mean BSR');
-title({'ERP changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
-set(findall(gcf,'-property','FontSize'),'FontSize',18)
-xlim([0 0.3])
-figureName = ['b01_pls_traces'];
-saveas(h, fullfile(pn.figures, figureName), 'epsc');
-saveas(h, fullfile(pn.figures, figureName), 'png');
+stat.mask = stat.mask;
+stat.prob = stat.prob.*-1;
+result.vsc = result.vsc.*-1;
+result.usc = result.usc.*-1;
 
 %% plot multivariate topographies
 
@@ -86,21 +60,31 @@ cfg.colorbar = 'EastOutside';
 plotData = [];
 plotData.label = elec.label; % {1 x N}
 plotData.dimord = 'chan';
-cfg.zlim = [-6 6]; 
+cfg.zlim = [-3 3]; 
 cfg.figure = h;
-plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time >0.08 & stat.time <0.12).*...
-    stat.prob(:,:,stat.time >0.08 & stat.time <0.12),3)); 
+plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,:,:).*...
+    stat.prob(:,:,:),3),2));
+
+[~, sortind] = sort(plotData.powspctrm, 'descend');
+cfg.marker = 'off'; 
+cfg.highlight = 'yes';
+cfg.highlightchannel = plotData.label(sortind(1:3)); %33, 4, 38
+cfg.highlightcolor = [0 0 0];
+cfg.highlightsymbol = '.';
+cfg.highlightsize = 15;
+
 ft_topoplotER(cfg,plotData);
-cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
-figureName = ['b01_lv1'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
+cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Max BSR');
+
+figureName = ['c_theta_topo'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
 
 %% plot using raincloud plot
 
 groupsizes=result.num_subj_lst;
 conditions=lv_evt_list;
-conds = {'manmade'; 'natural'};
+conds = {'old'; 'new'};
 condData = []; uData = [];
 for indGroup = 1
     if indGroup == 1
@@ -116,10 +100,7 @@ for indGroup = 1
     end
 end
 
-%% plot RainCloudPlot (within-subject centered)
-
 cBrew(1,:) = 2.*[.3 .1 .1];
-cBrew(2,:) = [.6 .6 .6];
 
 idx_outlier = cell(1); idx_standard = cell(1);
 for indGroup = 1
@@ -131,7 +112,8 @@ for indGroup = 1
     idx_standard{indGroup} = find(outliers==0);
 end
 
-h = figure('units','centimeter','position',[0 0 25 10]);
+h = figure('units','centimeter','position',[0 0 12 10]);
+ax = subplot(1,1,1);
 for indGroup = 1
     dataToPlot = uData{indGroup}';
     % read into cell array of the appropriate dimensions
@@ -154,7 +136,6 @@ for indGroup = 1
 
     % IMPORTANT: plot individually centered estimates, stats on uncentered estimates!
 
-    subplot(1,2,indGroup);
     set(gcf,'renderer','Painters')
         cla;
         cl = cBrew(indGroup,:);
@@ -163,12 +144,12 @@ for indGroup = 1
         view([90 -90]);
         axis ij
     box(gca,'off')
-    set(gca, 'YTickLabels', {'natural'; 'manmade'});
+    set(gca, 'YTickLabels', {conds{2}; conds{1}});
     yticks = get(gca, 'ytick'); ylim([yticks(1)-(yticks(2)-yticks(1))./2, yticks(2)+(yticks(2)-yticks(1))./1.5]);
 
     minmax = [min(min(cat(2,data_ws{:}))), max(max(cat(2,data_ws{:})))];
     xlim(minmax+[-0.2*diff(minmax), 0.2*diff(minmax)])
-    ylabel('scene category'); xlabel({'Brainscore'; '[Individually centered]'})
+    ylabel('novelty'); xlabel({'Brainscore'; '[Individually centered]'})
 
     % test linear effect
     curData = [data_nooutlier{1, 1}, data_nooutlier{2, 1}];
@@ -176,6 +157,11 @@ for indGroup = 1
     [~, p, ci, stats] = ttest(IndividualSlopes);
     title(['M:', num2str(round(mean(IndividualSlopes),3)), '; p=', num2str(round(p,3))])
 end
-figureName = ['b01_rcp'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
+% change tick order
+ax.XDir = 'reverse';
+set(ax, 'YTickLabels', {conds{1}; conds{2}});
+set(findall(gcf,'-property','FontSize'),'FontSize',12)
+
+figureName = ['c_theta_rcp'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');

+ 1 - 1
code/b2c_taskPLS_novelty_posterior_alpha.m

@@ -112,5 +112,5 @@ stat.cfg = option;
 stat.freq = freq;
 stat.time = time;
 
-save(fullfile(pn.data, 'b2c_taskpls_alpha.mat'),...
+save(fullfile(pn.data, 'c3_taskpls_alpha.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')

+ 8 - 23
code/b1_taskPLS_scenecat_N1_avg_plotLV1.m

@@ -22,7 +22,7 @@ cBrew = brewermap(500,'RdBu');
 cBrew = flipud(cBrew);
 colormap(cBrew)
 
-load(fullfile(pn.data, 'b01_taskpls_erp_avg.mat'),...
+load(fullfile(pn.data, 'c3_taskpls_alpha.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
 load(fullfile(rootpath, 'data','erp', ['sub-001_erp.mat']));
 elec = erp.scene_category{1}.elec;
@@ -53,20 +53,18 @@ cfg.colorbar = 'EastOutside';
 plotData = [];
 plotData.label = elec.label; % {1 x N}
 plotData.dimord = 'chan';
-cfg.zlim = [-6 6]; 
+cfg.zlim = [-2 2]; 
 cfg.figure = h;
-plotData.powspctrm = squeeze(stat.mask.*stat.prob); 
+plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,:).*...
+    stat.prob(:,:,:),3)); 
 ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
-figureName = ['b01_lv1'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
 
-%% plot using raincloud plot
+%% plot RainCloudPlot (within-subject centered)
 
 groupsizes=result.num_subj_lst;
 conditions=lv_evt_list;
-conds = {'manmade'; 'natural'};
+conds = {'old'; 'new'};
 condData = []; uData = [];
 for indGroup = 1
     if indGroup == 1
@@ -82,10 +80,7 @@ for indGroup = 1
     end
 end
 
-%% plot RainCloudPlot (within-subject centered)
-
 cBrew(1,:) = 2.*[.3 .1 .1];
-cBrew(2,:) = [.6 .6 .6];
 
 idx_outlier = cell(1); idx_standard = cell(1);
 for indGroup = 1
@@ -97,7 +92,7 @@ for indGroup = 1
     idx_standard{indGroup} = find(outliers==0);
 end
 
-h = figure('units','centimeter','position',[0 0 25 10]);
+h = figure('units','centimeter','position',[0 0 10 10]);
 for indGroup = 1
     dataToPlot = uData{indGroup}';
     % read into cell array of the appropriate dimensions
@@ -120,7 +115,6 @@ for indGroup = 1
 
     % IMPORTANT: plot individually centered estimates, stats on uncentered estimates!
 
-    subplot(1,2,indGroup);
     set(gcf,'renderer','Painters')
         cla;
         cl = cBrew(indGroup,:);
@@ -134,7 +128,7 @@ for indGroup = 1
 
     minmax = [min(min(cat(2,data_ws{:}))), max(max(cat(2,data_ws{:})))];
     xlim(minmax+[-0.2*diff(minmax), 0.2*diff(minmax)])
-    ylabel('scene category'); xlabel({'Brainscore'; '[Individually centered]'})
+    ylabel('novelty'); xlabel({'Brainscore'; '[Individually centered]'})
 
     % test linear effect
     curData = [data_nooutlier{1, 1}, data_nooutlier{2, 1}];
@@ -142,12 +136,3 @@ for indGroup = 1
     [~, p, ci, stats] = ttest(IndividualSlopes);
     title(['M:', num2str(round(mean(IndividualSlopes),3)), '; p=', num2str(round(p,3))])
 end
-figureName = ['b01_rcp'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
-
-
-%% get channels to visualize
-
-positive = find(squeeze(stat.mask.*stat.prob)>0);
-negative = find(squeeze(stat.mask.*stat.prob)<0);

+ 1 - 1
code/b3a_taskPLS_recognition_erp.m

@@ -102,5 +102,5 @@ stat.mask = lvdat > 3 | lvdat < -3;
 stat.cfg = option;
 stat.time = time;
 
-save(fullfile(pn.data, 'd01_taskpls_erp.mat'),...
+save(fullfile(pn.data, 'd1_taskpls_erp.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')

+ 131 - 36
code/b3a_taskPLS_recognition_erp_LV1.m

@@ -22,7 +22,7 @@ cBrew = brewermap(500,'RdBu');
 cBrew = flipud(cBrew);
 colormap(cBrew)
 
-load(fullfile(pn.data, 'd01_taskpls_erp.mat'),...
+load(fullfile(pn.data, 'd1_taskpls_erp.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
 load(fullfile(rootpath, 'data','erp', ['sub-001_erp.mat']));
 elec = erp.scene_category{1}.elec;
@@ -45,34 +45,55 @@ stat.prob = stat.prob.*-1;
 result.vsc = result.vsc.*-1;
 result.usc = result.usc.*-1;
 
-h = figure('units','centimeter','position',[0 0 15 10]);
+%% plot temporal loadings
+
+h = figure('units','centimeter','position',[0 0 10 10]);
 set(gcf,'renderer','Painters')
 hold on;
+
+% highlight relevant phase in background
+patches.timeVec = [.35 .55];
+patches.colorVec = [.8 .95 1];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-.5 .5];
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+
+
+% highlight relevant phase in background
+patches.timeVec = [.6 1];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-.5 .5];
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+
+% highlight relevant phase in background
+patches.timeVec = [1.2 1.7];
+patches.colorVec = [1 .8 .7];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-.5 .5];
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+
 statsPlot = [];
 statsPlot = cat(1, statsPlot,squeeze(nanmean(stat.mask(1:64,:,:).*stat.prob(1:64,:,:),1)));
 plot(stat.time,statsPlot, 'k')
-xlabel('Time [s from stim onset]'); ylabel('max abs BSR');
+xlabel('Time [s from stim onset]'); ylabel('mean BSR');
 title({'ERP changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
 set(findall(gcf,'-property','FontSize'),'FontSize',18)
-% figureName = ['b01_pls_traces'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
-
-% 
-% h = figure('units','centimeter','position',[0 0 15 10]);
-% set(gcf,'renderer','Painters')
-% statsPlot = [];
-% statsPlot = cat(1, statsPlot,squeeze(mean(stat.prob(1:64,:,:),1)));
-% plot(stat.time,statsPlot, 'k')
-% xlabel('Time [s from stim onset]'); ylabel('mean BSR');
-% title({'ERP changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
-% set(findall(gcf,'-property','FontSize'),'FontSize',18)
-%xlim([0 0.3])
-% figureName = ['b01_pls_traces'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
-
-%% plot multivariate topographies
+
+figureName = ['d1_rec_erp_bsr'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% plot early positivity/negativity
 
 h = figure('units','centimeters','position',[0 0 10 10]);
 set(gcf,'renderer','Painters')
@@ -87,14 +108,28 @@ cfg.colorbar = 'EastOutside';
 plotData = [];
 plotData.label = elec.label; % {1 x N}
 plotData.dimord = 'chan';
-cfg.zlim = [-5 5]; 
+cfg.zlim = [-4 4]; 
 cfg.figure = h;
-plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>.5 & stat.time<.8).*...
-    stat.prob(:,:,stat.time>0.5 & stat.time<.8),3)); 
+plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>.35 & stat.time<.55).*...
+    stat.prob(:,:,stat.time>.35 & stat.time<.55),3));
+
+[~, sortind] = sort(plotData.powspctrm, 'ascend');
+cfg.marker = 'off'; 
+cfg.highlight = 'yes';
+cfg.highlightchannel = plotData.label(sortind([1:2, end])); % 42, 35 (neg) 37 (pos)
+cfg.highlightcolor = [0 0 0];
+cfg.highlightsymbol = '.';
+cfg.highlightsize = 30;
+
 ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
 
-%%
+figureName = ['d1_rec_erp_topo1'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% plot later positivity
+
 h = figure('units','centimeters','position',[0 0 10 10]);
 set(gcf,'renderer','Painters')
 
@@ -108,13 +143,65 @@ cfg.colorbar = 'EastOutside';
 plotData = [];
 plotData.label = elec.label; % {1 x N}
 plotData.dimord = 'chan';
-cfg.zlim = [-2 2]; 
+cfg.zlim = [-4 4]; 
 cfg.figure = h;
-plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>1.2 & stat.time<1.8).*...
-    stat.prob(:,:,stat.time>1.2 & stat.time<1.8),3)); 
+plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>.6 & stat.time<1).*...
+    stat.prob(:,:,stat.time>0.6 & stat.time<1),3));
+
+[~, sortind] = sort(plotData.powspctrm, 'descend');
+cfg.marker = 'off'; 
+cfg.highlight = 'yes';
+cfg.highlightchannel = plotData.label(sortind([1:2])); % 19, 21
+cfg.highlightcolor = [0 0 0];
+cfg.highlightsymbol = '.';
+cfg.highlightsize = 30;
+
 ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
 
+figureName = ['d1_rec_erp_topo2'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% plot late negativity
+
+h = figure('units','centimeters','position',[0 0 10 10]);
+set(gcf,'renderer','Painters')
+
+cfg = [];
+cfg.layout = 'biosemi64.lay';
+cfg.parameter = 'powspctrm';
+cfg.comment = 'no';
+cfg.colormap = cBrew;
+cfg.colorbar = 'EastOutside';
+
+plotData = [];
+plotData.label = elec.label; % {1 x N}
+plotData.dimord = 'chan';
+cfg.zlim = [-2.5 2.5]; 
+cfg.figure = h;
+plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>1.2 & stat.time<1.7).*...
+    stat.prob(:,:,stat.time>1.2 & stat.time<1.7),3));
+
+[~, sortind] = sort(plotData.powspctrm, 'descend');
+cfg.marker = 'off'; 
+cfg.highlight = 'yes';
+%cfg.highlightchannel = plotData.label(sortind([end-3:end])); % 63, 26, 21, 58 (negative)
+%cfg.highlightchannel = plotData.label(sortind([8])); % 16, 53, 15, 54, 52, 51 (positive lateral)
+%cfg.highlightchannel = plotData.label([16, 53, 15, 52]); % (positive lateral)
+%cfg.highlightchannel = plotData.label([28]); % (positive posterior)
+cfg.highlightchannel = plotData.label([63, 26, 21, 58, 16, 53, 15, 52, 28]); % (positive posterior)
+cfg.highlightcolor = [.5 .5 .5];
+cfg.highlightsymbol = '.';
+cfg.highlightsize = 30;
+
+ft_topoplotER(cfg,plotData);
+cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
+
+figureName = ['d1_rec_erp_topo3'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
 %% plot using raincloud plot
 
 groupsizes=result.num_subj_lst;
@@ -130,8 +217,8 @@ for indGroup = 1
     end
     for indCond = 1:numel(conds)
         targetEntries = relevantEntries(conditions(relevantEntries)==indCond);        
-        condData{indGroup}(indCond,:) = -1.*result.vsc(targetEntries,indLV);
-        uData{indGroup}(indCond,:) = -1.*result.usc(targetEntries,indLV);
+        condData{indGroup}(indCond,:) = result.vsc(targetEntries,indLV);
+        uData{indGroup}(indCond,:) = result.usc(targetEntries,indLV);
     end
 end
 
@@ -148,7 +235,8 @@ for indGroup = 1
     idx_standard{indGroup} = find(outliers==0);
 end
 
-h = figure('units','centimeter','position',[0 0 25 10]);
+h = figure('units','centimeter','position',[0 0 8 10]);
+ax = subplot(1,1,1);
 for indGroup = 1
     dataToPlot = uData{indGroup}';
     % read into cell array of the appropriate dimensions
@@ -171,7 +259,7 @@ for indGroup = 1
 
     % IMPORTANT: plot individually centered estimates, stats on uncentered estimates!
 
-    subplot(1,2,indGroup);
+    %subplot(1,2,indGroup);
     set(gcf,'renderer','Painters')
         cla;
         cl = cBrew(indGroup,:);
@@ -185,11 +273,18 @@ for indGroup = 1
 
     minmax = [min(min(cat(2,data_ws{:}))), max(max(cat(2,data_ws{:})))];
     xlim(minmax+[-0.2*diff(minmax), 0.2*diff(minmax)])
-    ylabel('scene category'); xlabel({'Brainscore'; '[Individually centered]'})
+    ylabel('recognition'); xlabel({'Brainscore'; '[Individually centered]'})
 
     % test linear effect
     curData = [data_nooutlier{1, 1}, data_nooutlier{2, 1}];
     X = [1 1; 1 2]; b=X\curData'; IndividualSlopes = b(2,:);
     [~, p, ci, stats] = ttest(IndividualSlopes);
-    title(['M:', num2str(round(mean(IndividualSlopes),3)), '; p=', num2str(round(p,3))])
-end
+    title(['M:', num2str(round(mean(IndividualSlopes),3)), '; p=', num2str(round(p,6))])
+end
+% make misses initial tick
+ax.XDir = 'reverse';
+set(ax, 'YTickLabels', {conds{1}; conds{2}});
+
+figureName = ['d1_rec_erp_rcp'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');

+ 350 - 0
code/d1_taskPLS_recognition_erp_trace.m

@@ -0,0 +1,350 @@
+
+currentFile = mfilename('fullpath');
+[pathstr,~,~] = fileparts(currentFile);
+cd(fullfile(pathstr,'..'))
+rootpath = pwd;
+
+pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
+pn.data_erp = fullfile(rootpath, 'data', 'erp');
+pn.data_erf = fullfile(rootpath, 'data', 'erf');
+pn.tools = fullfile(rootpath, 'tools');
+    addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
+    addpath(fullfile(pn.tools, 'BrewerMap'));
+    addpath(fullfile(pn.tools, 'shadedErrorBar'));
+    
+%% load erp
+
+for ind_id = 1:33
+    id = sprintf('sub-%03d', ind_id); disp(id)
+    load(fullfile(pn.data_erp, [id,'_erp_bl.mat']));
+    for ind_option = 1:4%numel(conds.behavior)
+        if ind_id == 1
+             erpgroup.behavior.(conds.behavior{ind_option}) = erp_bl.behavior{ind_option};
+             erpgroup.behavior.(conds.behavior{ind_option}) = ...
+                 rmfield(erpgroup.behavior.(conds.behavior{ind_option}), {'avg', 'var', 'dof'});
+             erpgroup.behavior.(conds.behavior{ind_option}).dimord = 'sub_chan_time';
+        end
+        erpgroup.behavior.(conds.behavior{ind_option}).avg(ind_id,:,:) = erp_bl.behavior{ind_option}.avg;
+    end
+end
+
+time = erpgroup.behavior.hit.time;
+elec = erpgroup.behavior.hit.elec;
+channels = erpgroup.behavior.hit.label;
+
+mergeddata = cat(4, erpgroup.behavior.hit.avg, ...
+    erpgroup.behavior.miss.avg);
+
+smoothdur = 10; % 5 = 10 ms
+
+%% get max. channels
+
+load(fullfile(pn.data, 'd1_taskpls_erp.mat'),...
+    'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
+
+stat.mask = stat.mask;
+stat.prob = stat.prob.*-1;
+result.vsc = result.vsc.*-1;
+result.usc = result.usc.*-1;
+
+plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>.35 & stat.time<.55).*...
+    stat.prob(:,:,stat.time>.35 & stat.time<.55),3)); 
+[~, topo1] = sort(plotData.powspctrm, 'descend');
+
+plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>.6 & stat.time<.8).*...
+    stat.prob(:,:,stat.time>0.6 & stat.time<.8),3)); 
+[~, topo2] = sort(plotData.powspctrm, 'descend');
+
+plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>1.2 & stat.time<1.7).*...
+    stat.prob(:,:,stat.time>1.2 & stat.time<1.7),3)); 
+[~, topo3] = sort(plotData.powspctrm, 'descend');
+
+%% visualize intial changes
+
+idx_chans = topo1(1);
+% avg across channels and conditions
+condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% highlight relevant phase in background
+patches.timeVec = [0.35 0.55];
+patches.colorVec = [.8 .95 1];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-7 2]*10^-4;
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+% ax = gca; ax.YDir = 'reverse';
+legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
+    'location', 'southwest'); legend('boxoff')
+xlabel('Time (s) from stim onset')
+xlim([-.25 1.9]); ylim(YLim)
+ylabel({'ERP';'(microVolts)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',14)
+
+figureName = ['d_rec_erp_1_pos'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+idx_chans = topo1(end-1:end);
+% avg across channels and conditions
+condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% highlight relevant phase in background
+patches.timeVec = [0.35 0.55];
+patches.colorVec = [.8 .95 1];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-3 3]*10^-4;
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+% ax = gca; ax.YDir = 'reverse';
+legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
+    'location', 'southwest'); legend('boxoff')
+xlabel('Time (s) from stim onset')
+xlim([-.25 1.9]); ylim(YLim)
+ylabel({'ERP';'(microVolts)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',14)
+
+figureName = ['d_rec_erp_1_neg'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% visualize second topo
+
+idx_chans = topo2(1);
+% avg across channels and conditions
+condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% highlight relevant phase in background
+patches.timeVec = [0.6 1.0];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-5 5]*10^-4;
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+
+% % highlight relevant phase in background
+% patches.timeVec = [1.2 1.7];
+% patches.colorVec = [1 .8 .7];
+% for indP = 1:size(patches.timeVec,2)-1
+%     YLim = [-5 5]*10^-4;
+%     p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+%                 [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+%     p.EdgeColor = 'none';
+% end
+
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+% ax = gca; ax.YDir = 'reverse';
+legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
+    'location', 'southwest'); legend('boxoff')
+xlabel('Time (s) from stim onset')
+xlim([-.25 1.9]); ylim(YLim)
+ylabel({'ERP';'(microVolts)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',14)
+
+figureName = ['d_rec_erp_2_pos'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% topo 3: negative
+
+idx_chans = [63, 26, 21, 58];
+% avg across channels and conditions
+condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% highlight relevant phase in background
+patches.timeVec = [0.6 1.0];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-2 12]*10^-4;
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+
+% highlight relevant phase in background
+patches.timeVec = [1.2 1.7];
+patches.colorVec = [1 .8 .7];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-2 12]*10^-4;
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+% ax = gca; ax.YDir = 'reverse';
+legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
+    'location', 'southwest'); legend('boxoff')
+xlabel('Time (s) from stim onset')
+xlim([-.25 1.9]); ylim(YLim)
+ylabel({'ERP';'(microVolts)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',14)
+
+figureName = ['d_rec_erp_3_neg'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% topo 3: positive lateral
+
+idx_chans = [16, 53, 15, 54, 52, 51];
+% avg across channels and conditions
+condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% % highlight relevant phase in background
+% patches.timeVec = [0.6 1.0];
+% patches.colorVec = [1 .95 .8];
+% for indP = 1:size(patches.timeVec,2)-1
+%     YLim = [-4 2.5]*10^-4;
+%     p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+%                 [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+%     p.EdgeColor = 'none';
+% end
+
+% highlight relevant phase in background
+patches.timeVec = [1.2 1.7];
+patches.colorVec = [1 .8 .7];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-4 2.5]*10^-4;
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+% ax = gca; ax.YDir = 'reverse';
+legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
+    'location', 'southwest'); legend('boxoff')
+xlabel('Time (s) from stim onset')
+xlim([-.25 1.9]); ylim(YLim)
+ylabel({'ERP';'(microVolts)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',14)
+
+figureName = ['d_rec_erp_3_pos_lat'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% topo 3: positive posterior
+
+idx_chans = [28];
+% avg across channels and conditions
+condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+% highlight relevant phase in background
+patches.timeVec = [0.6 1.0];
+patches.colorVec = [1 .95 .8];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-6 2.5]*10^-4;
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+
+% highlight relevant phase in background
+patches.timeVec = [1.2 1.7];
+patches.colorVec = [1 .8 .7];
+for indP = 1:size(patches.timeVec,2)-1
+    YLim = [-6 2.5]*10^-4;
+    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
+                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
+    p.EdgeColor = 'none';
+end
+
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+% ax = gca; ax.YDir = 'reverse';
+legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
+    'location', 'southwest'); legend('boxoff')
+xlabel('Time (s) from stim onset')
+xlim([-.25 1.9]); ylim(YLim)
+ylabel({'ERP';'(microVolts)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',14)
+
+figureName = ['d_rec_erp_3_pos_post'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');

+ 1 - 1
code/b3b_taskPLS_recognition_erf.m

@@ -103,5 +103,5 @@ stat.cfg = option;
 stat.freq = freq;
 stat.time = time;
 
-save(fullfile(pn.data, 'b3b_taskpls_erf.mat'),...
+save(fullfile(pn.data, 'd2_taskpls_erf.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')

+ 84 - 60
code/b3b_taskPLS_recognition_erf_LV1.m

@@ -22,7 +22,7 @@ cBrew = brewermap(500,'RdBu');
 cBrew = flipud(cBrew);
 colormap(cBrew)
 
-load(fullfile(pn.data, 'b3b_taskpls_erf.mat'),...
+load(fullfile(pn.data, 'd2_taskpls_erf.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
 load(fullfile(rootpath, 'data','erp', ['sub-001_erp.mat']));
 elec = erp.scene_category{1}.elec;
@@ -40,17 +40,19 @@ stat.mask = lvdat > 3 | lvdat < -3;
 
 %% invert solution
 
-% stat.mask = stat.mask;
-% stat.prob = stat.prob.*-1;
-% result.vsc = result.vsc.*-1;
-% result.usc = result.usc.*-1;
+stat.mask = stat.mask;
+stat.prob = stat.prob.*-1;
+result.vsc = result.vsc.*-1;
+result.usc = result.usc.*-1;
+
+%% plot BSR loadings
 
 h = figure('units','centimeter','position',[0 0 15 10]);
 set(gcf,'renderer','Painters')
 statsPlot = [];
 %statsPlot = cat(1, statsPlot,squeeze(nanmean(stat.prob(1:64,:,:),1)));
 statsPlot = cat(1, statsPlot,squeeze(nanmean(stat.mask(1:64,:,:).*stat.prob(1:64,:,:),1)));
-range_plot = [-4 1.5];
+range_plot = [-1 3.5];
 imagesc(stat.time,[],statsPlot, range_plot);
 set(gca,'Ydir','Normal');
 % set custom colormap
@@ -71,41 +73,9 @@ title({'ERF changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))
 set(findall(gcf,'-property','FontSize'),'FontSize',18)
 set(gca, 'YTickLabels', round(stat.freq(get(gca, 'YTick')),0));
 
-%https://de.mathworks.com/matlabcentral/answers/476715-superimposing-two-imagesc-graphs-over-each-other
-
-% h = figure('units','centimeter','position',[0 0 15 10]);
-% set(gcf,'renderer','Painters')
-% hold all; axis square; 
-% ax1 = axes; 
-%     statsPlot = [];
-%     statsPlot = cat(1, statsPlot,squeeze(nanmean(stat.prob(1:64,:,:),1)));
-%     im1 = imagesc(stat.time,[],statsPlot, [-4 4]);
-%     im1.AlphaData = .5;
-%     axis square; 
-% ax2 = axes; 
-%     statsPlot = [];
-%     statsPlot = cat(1, statsPlot,squeeze(nanmean(stat.mask(1:64,:,:).*stat.prob(1:64,:,:),1)));
-%     im2 = imagesc(stat.time,[],statsPlot, [-4 4]);
-%     im2.AlphaData = .8;
-%     axis square; 
-% linkaxes([ax1,ax2])
-% %%Hide the top axes 
-% ax2.Visible = 'off'; 
-% ax2.XTick = []; 
-% ax2.YTick = []; 
-% colormap(ax1,gray) 
-% colormap(ax2,cBrew)
-% set(gca,'Ydir','Normal');
-% xlabel('Time [s from stim onset]'); ylabel('Frequency (Hz)');
-% title({'ERF changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
-% set(findall(gcf,'-property','FontSize'),'FontSize',18)
-% set(gca, 'YTickLabels', round(stat.freq(get(gca, 'YTick')),0));
-% colorbar;
-
-
-% figureName = ['b01_pls_traces'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
+figureName = ['d2_erf_bsr'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
 
 %% plot multivariate topographies
 
@@ -130,18 +100,22 @@ cfg.zlim = [-4 4];
 cfg.figure = h;
 plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>8 & stat.freq<20,stat.time>1 & stat.time<2).*...
     stat.prob(:,stat.freq>8 & stat.freq<20,stat.time>1 & stat.time<2),3),2)); 
-[~, sortind] = sort(plotData.powspctrm, 'ascend');
+[~, sortind] = sort(plotData.powspctrm, 'descend');
 cfg.marker = 'off'; 
 cfg.highlight = 'yes';
-cfg.highlightchannel = plotData.label(sortind(1:6));
-cfg.highlightcolor = [1 1 1];
+cfg.highlightchannel = plotData.label(sortind(1:6)); %26, 20, 30, 31, 21, 63
+cfg.highlightcolor = [0 0 0];
 cfg.highlightsymbol = '.';
 cfg.highlightsize = 30;
 ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
 title('AlphaBeta 1-2s')
 
-%% 'Theta 1-2s'
+figureName = ['d2_erf_topo1'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% 'Theta 200 - 500 ms'
 
 h = figure('units','centimeters','position',[0 0 10 10]);
 set(gcf,'renderer','Painters')
@@ -156,20 +130,58 @@ cfg.colorbar = 'EastOutside';
 plotData = [];
 plotData.label = elec.label; % {1 x N}
 plotData.dimord = 'chan';
-cfg.zlim = [-2 2]; 
+cfg.zlim = [-1.5 1.5]; 
 cfg.figure = h;
-plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>2 &stat.freq<7,stat.time>1 & stat.time<2).*...
-    stat.prob(:,stat.freq>2 & stat.freq<7,stat.time>1 & stat.time<2),3),2)); 
+plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>2 &stat.freq<7,stat.time>.3 & stat.time<.5).*...
+    stat.prob(:,stat.freq>2 & stat.freq<7,stat.time>.3 & stat.time<.5),3),2)); 
 [~, sortind] = sort(plotData.powspctrm, 'descend');
 cfg.marker = 'off'; 
 cfg.highlight = 'yes';
-cfg.highlightchannel = plotData.label(sortind(1:3));
+cfg.highlightchannel = plotData.label(sortind(1:2)); % 38, 47
+cfg.highlightcolor = [0 0 0];
+cfg.highlightsymbol = '.';
+cfg.highlightsize = 30;
+ft_topoplotER(cfg,plotData);
+cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
+title('Theta 200 - 500 ms')
+
+figureName = ['d2_erf_topo4'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
+%% 'Theta 1-2s'
+
+h = figure('units','centimeters','position',[0 0 10 10]);
+set(gcf,'renderer','Painters')
+
+cfg = [];
+cfg.layout = 'biosemi64.lay';
+cfg.parameter = 'powspctrm';
+cfg.comment = 'no';
+cfg.colormap = cBrew;
+cfg.colorbar = 'EastOutside';
+
+plotData = [];
+plotData.label = elec.label; % {1 x N}
+plotData.dimord = 'chan';
+cfg.zlim = [-4 4]; 
+cfg.figure = h;
+plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>2 &stat.freq<7,stat.time>1 & stat.time<1.5).*...
+    stat.prob(:,stat.freq>2 & stat.freq<7,stat.time>1 & stat.time<1.5),3),2)); 
+[~, sortind] = sort(plotData.powspctrm, 'ascend');
+cfg.marker = 'off'; 
+cfg.highlight = 'yes';
+cfg.highlightchannel = plotData.label([38, 47]); % 46, 47, 38
 cfg.highlightcolor = [1 1 1];
 cfg.highlightsymbol = '.';
 cfg.highlightsize = 30;
 ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
-title('Theta 1-2s')
+title('Theta 1-1.5s')
+
+figureName = ['d2_erf_topo2'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
 
 %% title('AlphaBeta 0.5-1s')
 
@@ -186,20 +198,24 @@ cfg.colorbar = 'EastOutside';
 plotData = [];
 plotData.label = elec.label; % {1 x N}
 plotData.dimord = 'chan';
-cfg.zlim = [-2 2]; 
+cfg.zlim = [-1.5 1.5]; 
 cfg.figure = h;
-plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>8 & stat.freq<20,stat.time>0.5 & stat.time<1).*...
-    stat.prob(:,stat.freq>8 & stat.freq<20,stat.time>0.5 & stat.time<1),3),2)); 
-[~, sortind] = sort(plotData.powspctrm, 'descend');
+plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>8 & stat.freq<25,stat.time>0.6 & stat.time<1).*...
+    stat.prob(:,stat.freq>8 & stat.freq<25,stat.time>0.6 & stat.time<1),3),2)); 
+[~, sortind] = sort(plotData.powspctrm, 'ascend');
 cfg.marker = 'off'; 
 cfg.highlight = 'yes';
-cfg.highlightchannel = plotData.label(sortind(1:3));
-cfg.highlightcolor = [1 1 1];
+cfg.highlightchannel = plotData.label(sortind(1:3)); % 20, 21, 12
+cfg.highlightcolor = [0 0 0];
 cfg.highlightsymbol = '.';
 cfg.highlightsize = 30;
 ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
-title('AlphaBeta 0.5-1s')
+title('AlphaBeta 0.6-1s')
+
+figureName = ['d2_erf_topo3'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
 
 %% plot using raincloud plot
 
@@ -235,6 +251,7 @@ for indGroup = 1
 end
 
 h = figure('units','centimeter','position',[0 0 8 10]);
+ax = subplot(1,1,1);
 for indGroup = 1
     dataToPlot = uData{indGroup}';
     % read into cell array of the appropriate dimensions
@@ -271,11 +288,18 @@ for indGroup = 1
 
     minmax = [min(min(cat(2,data_ws{:}))), max(max(cat(2,data_ws{:})))];
     xlim(minmax+[-0.2*diff(minmax), 0.2*diff(minmax)])
-    ylabel('scene category'); xlabel({'Brainscore'; '[Individually centered]'})
+    ylabel('recognition'); xlabel({'Brainscore'; '[Individually centered]'})
 
     % test linear effect
     curData = [data_nooutlier{1, 1}, data_nooutlier{2, 1}];
     X = [1 1; 1 2]; b=X\curData'; IndividualSlopes = b(2,:);
     [~, p, ci, stats] = ttest(IndividualSlopes);
-    title(['M:', num2str(round(mean(IndividualSlopes),3)), '; p=', num2str(round(p,3))])
-end
+    title(['M:', num2str(round(mean(IndividualSlopes),3)), '; p=', num2str(round(p,6))])
+end
+% make misses initial tick
+ax.XDir = 'reverse';
+set(ax, 'YTickLabels', {conds{1}; conds{2}});
+
+figureName = ['d2_erf_rcp'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');

+ 39 - 26
code/b3x_rcognition_plot_theta_alpha.m

@@ -14,6 +14,7 @@ pn.tools = fullfile(rootpath, 'tools');
     addpath(genpath(fullfile(pn.tools, '[MEG]PLS', 'MEGPLS_PIPELINE_v2.02b')))
     addpath(fullfile(pn.tools, 'BrewerMap'));
     addpath(fullfile(pn.tools, 'shadedErrorBar'));
+pn.figures = fullfile(rootpath, 'figures');
 
 %% add seed for reproducibility
 
@@ -24,7 +25,7 @@ rng(0, 'twister');
 for ind_id = 1:33
     id = sprintf('sub-%03d', ind_id); disp(id)
     load(fullfile(pn.data_erf, [id,'_erf.mat']));
-    for ind_option = 1:numel(conds.old)
+    for ind_option = 1:numel(conds.behavior)
         if ind_id == 1
              erpgroup.behavior.(conds.behavior{ind_option}) = erf.behavior{ind_option};
              erpgroup.behavior.(conds.behavior{ind_option}) = ...
@@ -34,38 +35,38 @@ for ind_id = 1:33
         end
         idx_freq_t = freq >2 & freq <7;
         thetagroup.behavior.(conds.behavior{ind_option}).avg(ind_id,:,:,:) = squeeze(nanmean(erf.behavior{ind_option}.powspctrm(:,idx_freq_t,:),2));
-        idx_freq_a = freq >8 & freq <20;
+        idx_freq_a = freq >8 & freq <25;
         alphagroup.behavior.(conds.behavior{ind_option}).avg(ind_id,:,:,:) = squeeze(nanmean(erf.behavior{ind_option}.powspctrm(:,idx_freq_a,:),2));
     end
 end
 
-time = erpgroup.behavior.correctreject.time;
-channels = erpgroup.behavior.correctreject.label;
+time = erpgroup.behavior.hit.time;
+channels = erpgroup.behavior.hit.label;
 
 %% get max. channels
 
-load(fullfile(pn.data, 'b3b_taskpls_erf.mat'),...
+load(fullfile(pn.data, 'd2_taskpls_erf.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
 
-plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>8 & stat.freq<20,stat.time>1 & stat.time<2).*...
-    stat.prob(:,stat.freq>8 & stat.freq<20,stat.time>1 & stat.time<2),3),2));
+plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>8 & stat.freq<25,stat.time>1 & stat.time<2).*...
+    stat.prob(:,stat.freq>8 & stat.freq<25,stat.time>1 & stat.time<2),3),2));
 [~, alphaChanMin] = sort(plotData.powspctrm, 'ascend');
 
-plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>2 &stat.freq<7,stat.time>1 & stat.time<2).*...
-    stat.prob(:,stat.freq>2 & stat.freq<7,stat.time>1 & stat.time<2),3),2)); 
-[~, thetaChan] = sort(plotData.powspctrm, 'descend');
-
-plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>8 & stat.freq<20,stat.time>0.5 & stat.time<1).*...
-    stat.prob(:,stat.freq>8 & stat.freq<20,stat.time>0.5 & stat.time<1),3),2)); 
+% plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>2 &stat.freq<7,stat.time>1 & stat.time<2).*...
+%     stat.prob(:,stat.freq>2 & stat.freq<7,stat.time>1 & stat.time<2),3),2)); 
+% [~, thetaChan] = sort(plotData.powspctrm, 'descend');
+% 
+plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>8 & stat.freq<25,stat.time>0.5 & stat.time<1).*...
+    stat.prob(:,stat.freq>8 & stat.freq<25,stat.time>0.5 & stat.time<1),3),2)); 
 [~, alphaChanMax] = sort(plotData.powspctrm, 'descend');
 
 %% visualize for frontal theta
 
-mergeddata = cat(4, thetagroup.behavior.correctreject.avg, thetagroup.behavior.falsealarm.avg);
+mergeddata = cat(4, thetagroup.behavior.hit.avg, thetagroup.behavior.miss.avg);
 
 %figure; imagesc(squeeze(nanmean(thetagroup.old.new.avg-thetagroup.old.old.avg,1)))
 
-idx_chans = thetaChan(1:3); channels(idx_chans) %[33,38,47];
+idx_chans = [38, 47];% thetaChan(1:3); channels(idx_chans) %[33,38,47];
 condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
 
 h = figure('units','centimeters','position',[0 0 10 8]);
@@ -82,18 +83,22 @@ standError = nanstd(curData,1)./sqrt(size(curData,1));
 l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
     {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
 xlabel('Time (s) from stim onset')
-legend([l1.mainLine, l2.mainLine],{'correctreject', 'falsealarm'}, ...
-    'location', 'southwest'); legend('boxoff')
-xlim([-.5 1.7]); %ylim(YLim)
+legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
+    'location', 'southeast'); legend('boxoff')
+xlim([-.5 1.50]); %ylim(YLim)
 ylabel({'theta power';'(log10)'});
 xlabel({'Time (s)'});    
 set(findall(gcf,'-property','FontSize'),'FontSize',12)
 
+figureName = ['d2_erf_theta_trace'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
 %% visualize for posterior alpha
 
-mergeddata = cat(4, alphagroup.behavior.correctreject.avg, alphagroup.behavior.falsealarm.avg);
+mergeddata = cat(4, alphagroup.behavior.hit.avg, alphagroup.behavior.miss.avg);
 
-idx_chans = alphaChanMin(1:3); channels(idx_chans) %[33,38,47];
+idx_chans = alphaChanMin(1:6); channels(idx_chans) %[33,38,47];
 condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
 
 h = figure('units','centimeters','position',[0 0 10 8]);
@@ -110,18 +115,22 @@ standError = nanstd(curData,1)./sqrt(size(curData,1));
 l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
     {'color', 'r','linewidth', 3}, 'patchSaturation', .1);
 xlabel('Time (s) from stim onset')
-legend([l1.mainLine, l2.mainLine],{'correctreject', 'falsealarm'}, ...
-    'location', 'northeast'); legend('boxoff')
+legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
+    'location', 'north'); legend('boxoff')
 xlim([-.5 1.75]);
 ylabel({'alpha power';'(log10)'});
 xlabel({'Time (s)'});    
 set(findall(gcf,'-property','FontSize'),'FontSize',15)
 
+figureName = ['d2_erf_latealpha_trace'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
 %% visualize for central alpha
 
-mergeddata = cat(4, alphagroup.behavior.correctreject.avg, alphagroup.behavior.falsealarm.avg);
+mergeddata = cat(4, alphagroup.behavior.hit.avg, alphagroup.behavior.miss.avg);
 
-idx_chans = alphaChanMax(1:3); channels(idx_chans) %[33,38,47];
+idx_chans = alphaChanMax(1:3); channels(idx_chans) %[20,21,12];
 condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
 
 h = figure('units','centimeters','position',[0 0 10 8]);
@@ -138,9 +147,13 @@ standError = nanstd(curData,1)./sqrt(size(curData,1));
 l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
     {'color', 'r','linewidth', 3}, 'patchSaturation', .1);
 xlabel('Time (s) from stim onset')
-legend([l1.mainLine, l2.mainLine],{'correctreject', 'falsealarm'}, ...
+legend([l1.mainLine, l2.mainLine],{'hit', 'miss'}, ...
     'location', 'northeast'); legend('boxoff')
 xlim([-.5 1.75]);
 ylabel({'alpha power';'(log10)'});
 xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',15)
+set(findall(gcf,'-property','FontSize'),'FontSize',15)
+
+figureName = ['d2_erf_earlyalpha_trace'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');

+ 1 - 1
code/b4a_taskPLS_memory_erp.m

@@ -102,5 +102,5 @@ stat.mask = lvdat > 3 | lvdat < -3;
 stat.cfg = option;
 stat.time = time;
 
-save(fullfile(pn.data, 'e01_taskpls_erp.mat'),...
+save(fullfile(pn.data, 'e1_taskpls_erp.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')

+ 9 - 43
code/b4a_taskPLS_memory_erp_LV1.m

@@ -22,7 +22,7 @@ cBrew = brewermap(500,'RdBu');
 cBrew = flipud(cBrew);
 colormap(cBrew)
 
-load(fullfile(pn.data, 'e01_taskpls_erp.mat'),...
+load(fullfile(pn.data, 'e1_taskpls_erp.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
 load(fullfile(rootpath, 'data','erp', ['sub-001_erp.mat']));
 elec = erp.scene_category{1}.elec;
@@ -38,12 +38,7 @@ stat.mask = lvdat > 3 | lvdat < -3;
 % maskNaN = double(stat.mask);
 % maskNaN(maskNaN==0) = NaN;
 
-%% invert solution
-
-% stat.mask = stat.mask;
-% stat.prob = stat.prob.*-1;
-% result.vsc = result.vsc.*-1;
-% result.usc = result.usc.*-1;
+%% plot BSR loadings
 
 h = figure('units','centimeter','position',[0 0 15 10]);
 set(gcf,'renderer','Painters')
@@ -55,18 +50,6 @@ xlabel('Time [s from stim onset]'); ylabel('max abs BSR');
 title({'ERP changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
 set(findall(gcf,'-property','FontSize'),'FontSize',18)
 
-% h = figure('units','centimeter','position',[0 0 15 10]);
-% set(gcf,'renderer','Painters')
-% statsPlot = [];
-% statsPlot = cat(1, statsPlot,squeeze(nanmax(abs(stat.prob(1:64,:,:)),[],1)));
-% plot(stat.time,statsPlot, 'k')
-% xlabel('Time [s from stim onset]'); ylabel('max abs BSR');
-% title({'ERP changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
-% set(findall(gcf,'-property','FontSize'),'FontSize',18)
-% % figureName = ['b01_pls_traces'];
-% % saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% % saveas(h, fullfile(pn.figures, figureName), 'png');
-
 %% plot multivariate topographies
 
 h = figure('units','centimeters','position',[0 0 10 10]);
@@ -84,32 +67,11 @@ plotData.label = elec.label; % {1 x N}
 plotData.dimord = 'chan';
 cfg.zlim = [-2 2]; 
 cfg.figure = h;
-plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>.3 & stat.time<.5).*...
-    stat.prob(:,:,stat.time>.3 & stat.time<.5),3)); 
+plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>.3 & stat.time<.8).*...
+    stat.prob(:,:,stat.time>.3 & stat.time<.8),3)); 
 ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
 
-h = figure('units','centimeters','position',[0 0 10 10]);
-set(gcf,'renderer','Painters')
-
-cfg = [];
-cfg.layout = 'biosemi64.lay';
-cfg.parameter = 'powspctrm';
-cfg.comment = 'no';
-cfg.colormap = cBrew;
-cfg.colorbar = 'EastOutside';
-
-plotData = [];
-plotData.label = elec.label; % {1 x N}
-plotData.dimord = 'chan';
-cfg.zlim = [-.5 .5]; 
-cfg.figure = h;
-plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,:).*...
-    stat.prob(:,:,:),3)); 
-ft_topoplotER(cfg,plotData);
-cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
-
-
 %% plot using raincloud plot
 
 groupsizes=result.num_subj_lst;
@@ -143,7 +105,7 @@ for indGroup = 1
     idx_standard{indGroup} = find(outliers==0);
 end
 
-h = figure('units','centimeter','position',[0 0 8 10]);
+h = figure('units','centimeter','position',[0 0 10 8]);
 for indGroup = 1
     dataToPlot = uData{indGroup}';
     % read into cell array of the appropriate dimensions
@@ -190,3 +152,7 @@ for indGroup = 1
 end
 
 set(findall(gcf,'-property','FontSize'),'FontSize',14)
+
+figureName = ['e_memory_erp_rcp'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');

+ 1 - 1
code/b4a_taskPLS_memory_erp_nooutlier.m

@@ -105,5 +105,5 @@ stat.mask = lvdat > 3 | lvdat < -3;
 stat.cfg = option;
 stat.time = time;
 
-save(fullfile(pn.data, 'e01_taskpls_erp_nooutlier.mat'),...
+save(fullfile(pn.data, 'e1_taskpls_erp_nooutlier.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')

+ 14 - 39
code/b2c_taskPLS_novelty_posterior_alpha_LV1.m

@@ -22,7 +22,7 @@ cBrew = brewermap(500,'RdBu');
 cBrew = flipud(cBrew);
 colormap(cBrew)
 
-load(fullfile(pn.data, 'b2c_taskpls_alpha.mat'),...
+load(fullfile(pn.data, 'e1_taskpls_erp_nooutlier.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
 load(fullfile(rootpath, 'data','erp', ['sub-001_erp.mat']));
 elec = erp.scene_category{1}.elec;
@@ -38,38 +38,17 @@ stat.mask = lvdat > 3 | lvdat < -3;
 % maskNaN = double(stat.mask);
 % maskNaN(maskNaN==0) = NaN;
 
-%% invert solution
-
-% stat.mask = stat.mask;
-% stat.prob = stat.prob.*-1;
-% result.vsc = result.vsc.*-1;
-% result.usc = result.usc.*-1;
+%% plot BSR loadings
 
 h = figure('units','centimeter','position',[0 0 15 10]);
 set(gcf,'renderer','Painters')
+hold on;
 statsPlot = [];
-statsPlot = cat(1, statsPlot,squeeze(nanmax(abs(stat.prob(1:64,:,:)),[],1)));
+statsPlot = cat(1, statsPlot,squeeze(nanmean(stat.mask(1:64,:,:).*stat.prob(1:64,:,:),1)));
 plot(stat.time,statsPlot, 'k')
 xlabel('Time [s from stim onset]'); ylabel('max abs BSR');
 title({'ERP changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
 set(findall(gcf,'-property','FontSize'),'FontSize',18)
-% figureName = ['b01_pls_traces'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
-
-
-h = figure('units','centimeter','position',[0 0 15 10]);
-set(gcf,'renderer','Painters')
-statsPlot = [];
-statsPlot = cat(1, statsPlot,squeeze(mean(stat.prob(1:64,:,:),1)));
-plot(stat.time,statsPlot, 'k')
-xlabel('Time [s from stim onset]'); ylabel('mean BSR');
-title({'ERP changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))]})
-set(findall(gcf,'-property','FontSize'),'FontSize',18)
-%xlim([0 0.3])
-% figureName = ['b01_pls_traces'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
 
 %% plot multivariate topographies
 
@@ -88,19 +67,16 @@ plotData.label = elec.label; % {1 x N}
 plotData.dimord = 'chan';
 cfg.zlim = [-2 2]; 
 cfg.figure = h;
-plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,:).*...
-    stat.prob(:,:,:),3)); 
+plotData.powspctrm = squeeze(nanmean(stat.mask(:,:,stat.time>.3 & stat.time<.8).*...
+    stat.prob(:,:,stat.time>.3 & stat.time<.8),3)); 
 ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
-figureName = ['b01_lv1'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
 
-%% plot RainCloudPlot (within-subject centered)
+%% plot using raincloud plot
 
 groupsizes=result.num_subj_lst;
 conditions=lv_evt_list;
-conds = {'manmade'; 'natural'};
+conds = {'forgotten'; 'remembered'};
 condData = []; uData = [];
 for indGroup = 1
     if indGroup == 1
@@ -129,7 +105,7 @@ for indGroup = 1
     idx_standard{indGroup} = find(outliers==0);
 end
 
-h = figure('units','centimeter','position',[0 0 25 10]);
+h = figure('units','centimeter','position',[0 0 10 8]);
 for indGroup = 1
     dataToPlot = uData{indGroup}';
     % read into cell array of the appropriate dimensions
@@ -152,7 +128,6 @@ for indGroup = 1
 
     % IMPORTANT: plot individually centered estimates, stats on uncentered estimates!
 
-    subplot(1,2,indGroup);
     set(gcf,'renderer','Painters')
         cla;
         cl = cBrew(indGroup,:);
@@ -161,7 +136,7 @@ for indGroup = 1
         view([90 -90]);
         axis ij
     box(gca,'off')
-    set(gca, 'YTickLabels', {'natural'; 'manmade'});
+    set(gca, 'YTickLabels', {conds{2}; conds{1}});
     yticks = get(gca, 'ytick'); ylim([yticks(1)-(yticks(2)-yticks(1))./2, yticks(2)+(yticks(2)-yticks(1))./1.5]);
 
     minmax = [min(min(cat(2,data_ws{:}))), max(max(cat(2,data_ws{:})))];
@@ -172,8 +147,8 @@ for indGroup = 1
     curData = [data_nooutlier{1, 1}, data_nooutlier{2, 1}];
     X = [1 1; 1 2]; b=X\curData'; IndividualSlopes = b(2,:);
     [~, p, ci, stats] = ttest(IndividualSlopes);
-    title(['M:', num2str(round(mean(IndividualSlopes),3)), '; p=', num2str(round(p,3))])
+    %title(['M:', num2str(round(mean(IndividualSlopes),3)), '; p=', num2str(round(p,3))])
+    title(['M:', num2str(round(mean(IndividualSlopes),3)), '; p=', num2str(round(result.perm_result.sprob(indLV),3))])
 end
-% figureName = ['b01_rcp'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
+
+set(findall(gcf,'-property','FontSize'),'FontSize',14)

+ 67 - 0
code/e1_taskPLS_memory_erp_trace.m

@@ -0,0 +1,67 @@
+
+currentFile = mfilename('fullpath');
+[pathstr,~,~] = fileparts(currentFile);
+cd(fullfile(pathstr,'..'))
+rootpath = pwd;
+
+pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
+pn.data_erp = fullfile(rootpath, 'data', 'erp');
+pn.data_erf = fullfile(rootpath, 'data', 'erf');
+pn.tools = fullfile(rootpath, 'tools');
+    addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
+    addpath(fullfile(pn.tools, 'BrewerMap'));
+    addpath(fullfile(pn.tools, 'shadedErrorBar'));
+    
+%% load erp
+
+for ind_id = 1:33
+    id = sprintf('sub-%03d', ind_id); disp(id)
+    load(fullfile(pn.data_erp, [id,'_erp_bl.mat']));
+    for ind_option = 2:3
+        if ind_id == 1
+             erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}) = erp_bl.subsequent_memory{ind_option};
+             erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}) = ...
+                 rmfield(erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}), {'avg', 'var', 'dof'});
+             erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}).dimord = 'sub_chan_time';
+        end
+        erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}).avg(ind_id,:,:) = erp_bl.subsequent_memory{ind_option}.avg;
+    end
+end
+
+time = erpgroup.subsequent_memory.subsequent_remembered.time;
+elec = erpgroup.subsequent_memory.subsequent_remembered.elec;
+channels = erpgroup.subsequent_memory.subsequent_remembered.label;
+
+mergeddata = cat(4, erpgroup.subsequent_memory.subsequent_forgotten.avg, ...
+    erpgroup.subsequent_memory.subsequent_remembered.avg);
+
+smoothdur = 10; % 5 = 10 ms
+
+%% visualize differences
+
+idx_chans = [44,14,9,15];
+% avg across channels and conditions
+condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
+
+h = figure('units','centimeters','position',[0 0 10 8]);
+cla; hold on;
+
+% new value = old value ? subject average + grand average
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l1 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
+curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
+curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
+standError = nanstd(curData,1)./sqrt(size(curData,1));
+l2 = shadedErrorBar(time,smoothts(nanmean(curData,1),'b',smoothdur),smoothts(standError,'b',smoothdur),...
+    'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
+% ax = gca; ax.YDir = 'reverse';
+legend([l1.mainLine, l2.mainLine],{'forgotten', 'remembered'}, ...
+    'location', 'southwest'); legend('boxoff')
+xlabel('Time (s) from stim onset')
+xlim([-.25 1.9]); %ylim(YLim)
+ylabel({'ERP';'(microVolts)'});
+xlabel({'Time (s)'});    
+set(findall(gcf,'-property','FontSize'),'FontSize',14)

+ 1 - 1
code/b4b_taskPLS_memory_erf.m

@@ -103,5 +103,5 @@ stat.cfg = option;
 stat.freq = freq;
 stat.time = time;
 
-save(fullfile(pn.data, 'b4b_taskpls_erf.mat'),...
+save(fullfile(pn.data, 'e2_taskpls_erf.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')

+ 24 - 16
code/b4b_taskPLS_memory_erf_LV1.m

@@ -22,7 +22,7 @@ cBrew = brewermap(500,'RdBu');
 cBrew = flipud(cBrew);
 colormap(cBrew)
 
-load(fullfile(pn.data, 'b4b_taskpls_erf.mat'),...
+load(fullfile(pn.data, 'e2_taskpls_erf.mat'),...
     'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
 load(fullfile(rootpath, 'data','erp', ['sub-001_erp.mat']));
 elec = erp.scene_category{1}.elec;
@@ -35,20 +35,14 @@ lvdat = reshape(result.boot_result.compare_u(:,indLV), num_chans, num_freqs, num
 stat.prob = lvdat;
 stat.mask = lvdat > 3 | lvdat < -3;
 
-% maskNaN = double(stat.mask);
-% maskNaN(maskNaN==0) = NaN;
+maskNaN = double(stat.mask);
+maskNaN(maskNaN==0) = NaN;
 
-%% invert solution
-
-% stat.mask = stat.mask;
-% stat.prob = stat.prob.*-1;
-% result.vsc = result.vsc.*-1;
-% result.usc = result.usc.*-1;
+%% plot BSR loadings
 
 h = figure('units','centimeter','position',[0 0 15 10]);
 set(gcf,'renderer','Painters')
 statsPlot = [];
-%statsPlot = cat(1, statsPlot,squeeze(nanmean(stat.prob(1:64,:,:),1)));
 statsPlot = cat(1, statsPlot,squeeze(nanmean(stat.mask(1:64,:,:).*stat.prob(1:64,:,:),1)));
 range_plot = [-.5 0.25];
 imagesc(stat.time,[],statsPlot, range_plot);
@@ -71,6 +65,9 @@ title({'ERF changes'; ['p = ', num2str(round(result.perm_result.sprob(indLV),4))
 set(findall(gcf,'-property','FontSize'),'FontSize',18)
 set(gca, 'YTickLabels', round(stat.freq(get(gca, 'YTick')),0));
 
+figureName = ['e2_memory_erf_loadings'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
 
 %% plot multivariate topographies
 % set custom colormap
@@ -97,7 +94,7 @@ plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>8 & stat.freq
 [~, sortind] = sort(plotData.powspctrm, 'ascend');
 cfg.marker = 'off'; 
 cfg.highlight = 'yes';
-cfg.highlightchannel = plotData.label(sortind(1:6));
+cfg.highlightchannel = plotData.label(sortind(1:6)); % 26, 32, 22, 31, 62, 59
 cfg.highlightcolor = [1 1 1];
 cfg.highlightsymbol = '.';
 cfg.highlightsize = 30;
@@ -105,6 +102,10 @@ ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
 title('AlphaBeta')
 
+figureName = ['e2_memory_erf_topo_alpha'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
 %% Theta
 
 h = figure('units','centimeters','position',[0 0 10 10]);
@@ -127,7 +128,7 @@ plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>2 & stat.freq
 [~, sortind] = sort(plotData.powspctrm, 'descend');
 cfg.marker = 'off'; 
 cfg.highlight = 'yes';
-cfg.highlightchannel = plotData.label(sortind(1:6));
+cfg.highlightchannel = plotData.label(sortind(1)); % 33
 cfg.highlightcolor = [1 1 1];
 cfg.highlightsymbol = '.';
 cfg.highlightsize = 30;
@@ -135,6 +136,10 @@ ft_topoplotER(cfg,plotData);
 cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Mean BSR');
 title('Theta')
 
+figureName = ['e2_memory_erf_topo_theta'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
 %% plot using raincloud plot
 
 groupsizes=result.num_subj_lst;
@@ -168,7 +173,7 @@ for indGroup = 1
     idx_standard{indGroup} = find(outliers==0);
 end
 
-h = figure('units','centimeter','position',[0 0 25 10]);
+h = figure('units','centimeter','position',[0 0 10 10]);
 for indGroup = 1
     dataToPlot = uData{indGroup}';
     % read into cell array of the appropriate dimensions
@@ -191,7 +196,6 @@ for indGroup = 1
 
     % IMPORTANT: plot individually centered estimates, stats on uncentered estimates!
 
-    subplot(1,2,indGroup);
     set(gcf,'renderer','Painters')
         cla;
         cl = cBrew(indGroup,:);
@@ -205,11 +209,15 @@ for indGroup = 1
 
     minmax = [min(min(cat(2,data_ws{:}))), max(max(cat(2,data_ws{:})))];
     xlim(minmax+[-0.2*diff(minmax), 0.2*diff(minmax)])
-    ylabel('scene category'); xlabel({'Brainscore'; '[Individually centered]'})
+    ylabel('memory'); xlabel({'Brainscore'; '[Individually centered]'})
 
     % test linear effect
     curData = [data_nooutlier{1, 1}, data_nooutlier{2, 1}];
     X = [1 1; 1 2]; b=X\curData'; IndividualSlopes = b(2,:);
     [~, p, ci, stats] = ttest(IndividualSlopes);
     title(['M:', num2str(round(mean(IndividualSlopes),3)), '; p=', num2str(round(p,3))])
-end
+end
+
+figureName = ['e2_memory_erf_rcp'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');

+ 41 - 44
code/b2x_novelty_plot_theta_alpha.m

@@ -14,6 +14,7 @@ pn.tools = fullfile(rootpath, 'tools');
     addpath(genpath(fullfile(pn.tools, '[MEG]PLS', 'MEGPLS_PIPELINE_v2.02b')))
     addpath(fullfile(pn.tools, 'BrewerMap'));
     addpath(fullfile(pn.tools, 'shadedErrorBar'));
+pn.figures = fullfile(rootpath, 'figures');
 
 %% add seed for reproducibility
 
@@ -24,50 +25,49 @@ rng(0, 'twister');
 for ind_id = 1:33
     id = sprintf('sub-%03d', ind_id); disp(id)
     load(fullfile(pn.data_erf, [id,'_erf.mat']));
-    for ind_option = 1:numel(conds.old)
+    for ind_option = 1:numel(conds.subsequent_memory)
         if ind_id == 1
-             erpgroup.old.(conds.old{ind_option}) = erf.old{ind_option};
-             erpgroup.old.(conds.old{ind_option}) = ...
-                 rmfield(erpgroup.old.(conds.old{ind_option}), {'powspctrm'});
-             erpgroup.old.(conds.old{ind_option}).dimord = 'sub_chan_freq_time';
-             freq = erpgroup.old.(conds.old{ind_option}).freq;
+             erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}) = erf.subsequent_memory{ind_option};
+             erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}) = ...
+                 rmfield(erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}), {'powspctrm'});
+             erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}).dimord = 'sub_chan_freq_time';
+             freq = erpgroup.subsequent_memory.(conds.subsequent_memory{ind_option}).freq;
         end
-        idx_freq_t = freq >2 & freq <8;
-        thetagroup.old.(conds.old{ind_option}).avg(ind_id,:,:,:) = squeeze(nanmean(erf.old{ind_option}.powspctrm(:,idx_freq_t,:),2));
-        idx_freq_a = freq >7 & freq <13;
-        alphagroup.old.(conds.old{ind_option}).avg(ind_id,:,:,:) = squeeze(nanmean(erf.old{ind_option}.powspctrm(:,idx_freq_a,:),2));
+        idx_freq_t = freq >2 & freq <7;
+        thetagroup.subsequent_memory.(conds.subsequent_memory{ind_option}).avg(ind_id,:,:,:) = squeeze(nanmean(erf.subsequent_memory{ind_option}.powspctrm(:,idx_freq_t,:),2));
+        idx_freq_a = freq >8 & freq <20;
+        alphagroup.subsequent_memory.(conds.subsequent_memory{ind_option}).avg(ind_id,:,:,:) = squeeze(nanmean(erf.subsequent_memory{ind_option}.powspctrm(:,idx_freq_a,:),2));
     end
 end
 
-time = erpgroup.old.old.time;
-channels = erpgroup.old.old.label;
+time = erpgroup.subsequent_memory.subsequent_remembered.time;
+channels = erpgroup.subsequent_memory.subsequent_forgotten.label;
 
-% identify frontal channels
-%idx_chans_t = startsWith(channels, 'F') | startsWith(channels, 'A') | startsWith(channels, 'C') & ~startsWith(channels, 'CP');
+%% get max. channels
 
-% identify parieto-occipital channels
-idx_chans_a = startsWith(channels, 'P') | startsWith(channels, 'O');
+load(fullfile(pn.data, 'e2_taskpls_erf.mat'),...
+    'stat', 'result', 'lvdat', 'lv_evt_list', 'num_chans', 'num_freqs', 'num_time')
+
+plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>8 & stat.freq<20,stat.time>.8 & stat.time<1).*...
+    stat.prob(:,stat.freq>8 & stat.freq<20,stat.time>.8 & stat.time<1),3),2)); 
+[~, alphaChanMin] = sort(plotData.powspctrm, 'ascend');
+
+plotData.powspctrm = squeeze(nanmean(nanmean(stat.mask(:,stat.freq>2 & stat.freq<7,stat.time>0 & stat.time<1).*...
+    stat.prob(:,stat.freq>2 & stat.freq<7,stat.time>0 & stat.time<1),3),2)); 
+
+[~, thetaChan] = sort(plotData.powspctrm, 'descend');
 
 %% visualize for frontal theta
 
-mergeddata = cat(4, thetagroup.old.old.avg, thetagroup.old.new.avg);
+mergeddata = cat(4, thetagroup.subsequent_memory.subsequent_remembered.avg, thetagroup.subsequent_memory.subsequent_forgotten.avg);
 
 %figure; imagesc(squeeze(nanmean(thetagroup.old.new.avg-thetagroup.old.old.avg,1)))
 
-idx_chans = [33,38,47];
+idx_chans = thetaChan(1); channels(idx_chans) %[33];
 condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
 
 h = figure('units','centimeters','position',[0 0 10 8]);
 cla; hold on;
-% highlight relevant phase in background
-patches.timeVec = [0.3 0.5];
-patches.colorVec = [1 .95 .8];
-for indP = 1:size(patches.timeVec,2)-1
-    YLim = [-5 -4.8];
-    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
-                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
-    p.EdgeColor = 'none';
-end
 % new value = old value ? subject average + grand average
 curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
 curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
@@ -80,32 +80,26 @@ standError = nanstd(curData,1)./sqrt(size(curData,1));
 l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
     {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
 xlabel('Time (s) from stim onset')
-legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
+legend([l1.mainLine, l2.mainLine],{'remembered', 'forgotten'}, ...
     'location', 'southeast'); legend('boxoff')
-xlim([-.5 1.5]); ylim(YLim)
-%xlim([-.05 .3]);
+xlim([-.5 1.7]); %ylim(YLim)
 ylabel({'theta power';'(log10)'});
 xlabel({'Time (s)'});    
 set(findall(gcf,'-property','FontSize'),'FontSize',12)
 
+figureName = ['e2_memory_theta'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');
+
 %% visualize for posterior alpha
 
-mergeddata = cat(4, alphagroup.old.old.avg, alphagroup.old.new.avg);
+mergeddata = cat(4, alphagroup.subsequent_memory.subsequent_remembered.avg, alphagroup.subsequent_memory.subsequent_forgotten.avg);
 
-idx_chans = idx_chans_a;
+idx_chans = alphaChanMin(1:6); channels(idx_chans) %[33,38,47];
 condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
 
 h = figure('units','centimeters','position',[0 0 10 8]);
 cla; hold on;
-% highlight relevant phase in background
-patches.timeVec = [0.3 0.5];
-patches.colorVec = [1 .95 .8];
-for indP = 1:size(patches.timeVec,2)-1
-    YLim = [-5.2 -4.5];
-    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
-                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
-    p.EdgeColor = 'none';
-end
 % new value = old value ? subject average + grand average
 curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
 curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
@@ -118,10 +112,13 @@ standError = nanstd(curData,1)./sqrt(size(curData,1));
 l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', ...
     {'color', 'r','linewidth', 3}, 'patchSaturation', .1);
 xlabel('Time (s) from stim onset')
-legend([l1.mainLine, l2.mainLine],{'old', 'new'}, 'location', 'northeast'); legend('boxoff')
-xlim([-.5 1.5]); ylim(YLim)
-%xlim([-.05 .3]);
+legend([l1.mainLine, l2.mainLine],{'remembered', 'forgotten'}, ...
+    'location', 'northeast'); legend('boxoff')
+xlim([-.5 1.75]); ylim([-5.325 -4.775])
 ylabel({'alpha power';'(log10)'});
 xlabel({'Time (s)'});    
 set(findall(gcf,'-property','FontSize'),'FontSize',15)
 
+figureName = ['e2_memory_alpha'];
+saveas(h, fullfile(pn.figures, figureName), 'epsc');
+saveas(h, fullfile(pn.figures, figureName), 'png');

+ 0 - 156
code/z_archive/b2a_taskPLS_novelty_frontal_erp_plot_trace_tmp.m

@@ -1,156 +0,0 @@
-
-currentFile = mfilename('fullpath');
-[pathstr,~,~] = fileparts(currentFile);
-cd(fullfile(pathstr,'..'))
-rootpath = pwd;
-
-pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
-pn.data_erp = fullfile(rootpath, 'data', 'erp');
-pn.data_erf = fullfile(rootpath, 'data', 'erf');
-pn.tools = fullfile(rootpath, 'tools');
-    addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
-    addpath(fullfile(pn.tools, 'BrewerMap'));
-    addpath(fullfile(pn.tools, 'shadedErrorBar'));
-    
-%% load erp
-
-for ind_id = 1:33
-    id = sprintf('sub-%03d', ind_id);
-    load(fullfile(pn.data_erp, [id,'_erp.mat']));
-    for ind_option = 1:numel(conds.old)
-        if ind_id == 1
-             erpgroup.old.(conds.old{ind_option}) = erp.old{ind_option};
-             erpgroup.old.(conds.old{ind_option}) = ...
-                 rmfield(erpgroup.old.(conds.old{ind_option}), {'avg', 'var', 'dof'});
-             erpgroup.old.(conds.old{ind_option}).dimord = 'sub_chan_time';
-        end
-        erpgroup.old.(conds.old{ind_option}).avg(ind_id,:,:) = erp.old{ind_option}.avg;
-    end
-end
-
-time = erpgroup.old.old.time;
-elec = erpgroup.old.old.elec;
-channels = erpgroup.old.old.label;
-
-%idx_chans = find(ismember(channels, {'O1', 'Oz', 'O2'}));
-%idx_chans = find(ismember(channels, {'PO7', 'PO8'}));
-%idx_chans = find(ismember(channels, {'Pz', 'CPz', 'P1'}));
-
-mergeddata = cat(4, erpgroup.old.old.avg, ...
-    erpgroup.old.new.avg);
-
-%% plot ERP topography
-
-% set custom colormap
-cBrew = brewermap(500,'RdBu');
-cBrew = flipud(cBrew);
-colormap(cBrew)
-
-h = figure('units','centimeters','position',[0 0 10 10]);
-set(gcf,'renderer','Painters')
-
-cfg = [];
-cfg.layout = 'biosemi64.lay';
-cfg.parameter = 'powspctrm';
-cfg.comment = 'no';
-cfg.colormap = cBrew;
-cfg.colorbar = 'EastOutside';
-
-plotData = [];
-plotData.label = elec.label; % {1 x N}
-plotData.dimord = 'chan';
-plotData.powspctrm = squeeze(nanmean(nanmean(nanmean(mergeddata(:,:,time>=0.3& time <=0.5,1:2),3),1),4))'; 
-
-cfg.zlim = [-14 14]*10^-4; 
-cfg.figure = h;
-ft_topoplotER(cfg,plotData);
-cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');
-% figureName = ['xxx'];
-% saveas(h, fullfile(pn.figures, figureName), 'epsc');
-% saveas(h, fullfile(pn.figures, figureName), 'png');
-
-%% visualize frontal ERP
-
-idx_chans = [38];
-
-% avg across channels and conditions
-condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% highlight relevant phase in background
-patches.timeVec = [0.3 0.5];
-patches.colorVec = [1 .95 .8];
-for indP = 1:size(patches.timeVec,2)-1
-    YLim = [-8 2]*10^-4;
-    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
-                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
-    p.EdgeColor = 'none';
-end
-% new value = old value ? subject average + grand average
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-% ax = gca; ax.YDir = 'reverse';
-legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
-    'location', 'southwest'); legend('boxoff')
-xlabel('Time (s) from stim onset')
-xlim([-.05 .6]); %ylim([-.03 .18])
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',14)
-
-%% plot difference
-
-idx_chans = [38];
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% highlight relevant phase in background
-patches.timeVec = [0.3 0.5];
-patches.colorVec = [1 .95 .8];
-for indP = 1:size(patches.timeVec,2)-1
-    YLim = [-10 5]*10^-5;
-    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
-                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
-    p.EdgeColor = 'none';
-end
-% new value = old value ? subject average + grand average
-curData = squeeze(mergeddata(:,idx_chans,:,2)-mergeddata(:,idx_chans,:,1));
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-legend([l1.mainLine],{'new-old'}, ...
-    'location', 'southwest'); legend('boxoff')
-xlabel('Time (s) from stim onset')
-xlim([-.05 .6]); %ylim([-.03 .18])
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',14)
-
-
-%% plot difference between conditions
-
-h = figure('units','centimeters','position',[0 0 10 10]);
-set(gcf,'renderer','Painters')
-
-cfg = [];
-cfg.layout = 'biosemi64.lay';
-cfg.parameter = 'powspctrm';
-cfg.comment = 'no';
-cfg.colormap = cBrew;
-cfg.colorbar = 'EastOutside';
-
-plotData = [];
-plotData.label = elec.label; % {1 x N}
-plotData.dimord = 'chan';
-oldminnew = mergeddata(:,:,:,1)-mergeddata(:,:,:,2);
-plotData.powspctrm = squeeze(nanmean(nanmean(oldminnew(:,:,time>=.3 & time <=.5),3),1))'; 
-
-cfg.figure = h;
-ft_topoplotER(cfg,plotData);
-cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');

+ 0 - 59
code/z_eegmp_old_new_ERP.m

@@ -1,59 +0,0 @@
-function z_eegmp_old_new_ERP(rootpath, id)
-
-%% paths
-if ismac
-    currentFile = mfilename('fullpath');
-    [pathstr,~,~] = fileparts(currentFile);
-    cd(fullfile(pathstr,'..'))
-    rootpath = pwd;
-    id = 'sub-011';
-end
-
-pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
-pn.data_erp = fullfile(rootpath, 'data', 'test'); mkdir(pn.data_erp);
-pn.tools = fullfile(rootpath, '..', 'eegmp_preproc', 'tools');
-    addpath(fullfile(pn.tools, 'fieldtrip')); ft_defaults
-
-%% load data_eeg
-
-% load preprocessed eeg data_eeg
-load(fullfile(pn.data_eeg, [id,'_task-xxxx_eeg_art.mat']), 'data_eeg', 'events');
-
-%% further preprocessing
-
-% apply notch filter
-
-cfg = [];
-cfg.dftfilter = 'yes';
-data_eeg = ft_preprocessing(cfg, data_eeg);
-
-%% CSD transform
-    
-% csd_cfg = [];
-% csd_cfg.method = 'spline';
-% data_eeg = ft_scalpcurrentdensity(csd_cfg, data_eeg);
-
-%% single-trial baseline-correction for ERPs
-
-time = data_eeg.time{1};
-
-data_eeg_bl = data_eeg;
-
-for indTrial = 1:numel(data_eeg_bl.trial)
-    curbl = squeeze(nanmean(data_eeg_bl.trial{indTrial}(:,time>-.2 & time<0),2));
-    data_eeg_bl.trial{indTrial} = data_eeg_bl.trial{indTrial}-repmat(curbl,1,numel(time));
-end
-
-%% split tfr and time series data by condition, average across trials
-
-cfg = [];
-cfg.trials = ismember(events.old, 'old');
-erp_bl.old = ft_timelockanalysis(cfg, data_eeg_bl);
-
-cfg = [];
-cfg.trials = ismember(events.old, 'new');
-erp_bl.new = ft_timelockanalysis(cfg, data_eeg_bl);
-
-%% save data
-
-save(fullfile(pn.data_erp, [id, '_erp_bl.mat']), 'erp_bl');

+ 0 - 27
code/z_eegmp_old_new_ERP_START.sh

@@ -1,27 +0,0 @@
-#!/bin/bash
-
-#!/bin/bash
-
-fun_name="z_eegmp_old_new_ERP"
-job_name="eegmp_test"
-
-rootpath="$(pwd)/.."
-rootpath=$(builtin cd $rootpath; pwd)
-
-mkdir ${rootpath}/log
-
-for subj in $(seq 1 33); do
-	cursub=$(printf "sub-%03d\n" ${subj})
-	echo ${cursub}
-	# if not been performed yet
-	#if [ ! -f ${rootpath}/data/erf/sub-$(printf "%03d" ${subj})*_erf.mat ]; then
-		sbatch \
-  			--job-name ${job_name}_${cursub} \
-  			--cpus-per-task 4 \
-  			--mem 6gb \
-  			--time 00:30:00 \
-  			--output ${rootpath}/log/${job_name}_${cursub}.out \
-  			--workdir . \
-  			--wrap=". /etc/profile ; module load matlab/R2016b; matlab -nodisplay -r \"${fun_name}('${rootpath}','${cursub}')\""
-  	#fi
-done

+ 0 - 125
code/z_eegmp_old_new_ERP_trace.m

@@ -1,125 +0,0 @@
-
-currentFile = mfilename('fullpath');
-[pathstr,~,~] = fileparts(currentFile);
-cd(fullfile(pathstr,'..'))
-rootpath = pwd;
-
-pn.data_eeg = fullfile(rootpath, '..', 'eegmp_preproc', 'data', 'outputs', 'eeg');
-pn.data_erp = fullfile(rootpath, 'data', 'test');
-pn.data_erf = fullfile(rootpath, 'data', 'erf');
-pn.tools = fullfile(rootpath, 'tools');
-    addpath(fullfile(rootpath, '..', 'eegmp_preproc', 'tools', 'fieldtrip')); ft_defaults
-    addpath(fullfile(pn.tools, 'BrewerMap'));
-    addpath(fullfile(pn.tools, 'shadedErrorBar'));
-    
-%% load erp
-
-for ind_id = 1:33
-    id = sprintf('sub-%03d', ind_id);
-    load(fullfile(pn.data_erp, [id,'_erp_bl.mat']));
-    if ind_id == 1
-         erpgroup.old.old = erp_bl.old;
-         erpgroup.old.old = ...
-             rmfield(erpgroup.old.old, {'avg', 'var', 'dof'});
-         erpgroup.old.old.dimord = 'sub_chan_time';
-
-         erpgroup.old.new = erp_bl.new;
-         erpgroup.old.new = ...
-             rmfield(erpgroup.old.new, {'avg', 'var', 'dof'});
-         erpgroup.old.new.dimord = 'sub_chan_time';
-    end
-    erpgroup.old.old.avg(ind_id,:,:) = erp_bl.old.avg;
-    erpgroup.old.new.avg(ind_id,:,:) = erp_bl.new.avg;
-end
-
-time = erpgroup.old.old.time;
-elec = erpgroup.old.old.elec;
-channels = erpgroup.old.old.label;
-
-mergeddata = cat(4, erpgroup.old.old.avg, ...
-    erpgroup.old.new.avg);
-
-%% visualize frontal ERP
-
-idx_chans = [38];
-
-% avg across channels and conditions
-condAvg = squeeze(nanmean(nanmean(mergeddata(:,idx_chans,:,1:2),2),4));
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% highlight relevant phase in background
-patches.timeVec = [0.3 0.5];
-patches.colorVec = [1 .95 .8];
-for indP = 1:size(patches.timeVec,2)-1
-    YLim = [-8 2]*10^-4;
-    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
-                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
-    p.EdgeColor = 'none';
-end
-% new value = old value ? subject average + grand average
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,1),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-curData = squeeze(nanmean(mergeddata(:,idx_chans,:,2),2));
-curData = curData-condAvg+repmat(nanmean(condAvg,1),size(condAvg,1),1);
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l2 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'r','linewidth', 2}, 'patchSaturation', .1);
-% ax = gca; ax.YDir = 'reverse';
-legend([l1.mainLine, l2.mainLine],{'old', 'new'}, ...
-    'location', 'southwest'); legend('boxoff')
-xlabel('Time (s) from stim onset')
-xlim([-.05 .6]); %ylim([-.03 .18])
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',14)
-
-%% plot difference
-
-idx_chans = [38];
-
-h = figure('units','centimeters','position',[0 0 10 8]);
-cla; hold on;
-% highlight relevant phase in background
-patches.timeVec = [0.3 0.5];
-patches.colorVec = [1 .95 .8];
-for indP = 1:size(patches.timeVec,2)-1
-    YLim = [-10 5]*10^-5;
-    p = patch([patches.timeVec(indP) patches.timeVec(indP+1) patches.timeVec(indP+1) patches.timeVec(indP)], ...
-                [YLim(1) YLim(1)  YLim(2), YLim(2)], patches.colorVec(indP,:));
-    p.EdgeColor = 'none';
-end
-% new value = old value ? subject average + grand average
-curData = squeeze(mergeddata(:,idx_chans,:,2)-mergeddata(:,idx_chans,:,1));
-standError = nanstd(curData,1)./sqrt(size(curData,1));
-l1 = shadedErrorBar(time,nanmean(curData,1),standError, 'lineprops', {'color', 'k','linewidth', 2}, 'patchSaturation', .1);
-legend([l1.mainLine],{'new-old'}, ...
-    'location', 'southwest'); legend('boxoff')
-xlabel('Time (s) from stim onset')
-xlim([-.05 .6]); %ylim([-.03 .18])
-ylabel({'ERP';'(microVolts)'});
-xlabel({'Time (s)'});    
-set(findall(gcf,'-property','FontSize'),'FontSize',14)
-
-%% plot difference between conditions
-
-h = figure('units','centimeters','position',[0 0 10 10]);
-set(gcf,'renderer','Painters')
-
-cfg = [];
-cfg.layout = 'biosemi64.lay';
-cfg.parameter = 'powspctrm';
-cfg.comment = 'no';
-cfg.colormap = cBrew;
-cfg.colorbar = 'EastOutside';
-
-plotData = [];
-plotData.label = elec.label(1:64); % {1 x N}
-plotData.dimord = 'chan';
-oldminnew = mergeddata(:,:,:,1)-mergeddata(:,:,:,2);
-plotData.powspctrm = squeeze(nanmean(nanmean(oldminnew(:,1:64,time>=.3 & time <=.5),3),1))'; 
-
-cfg.figure = h;
-ft_topoplotER(cfg,plotData);
-cb = colorbar('location', 'EastOutside'); set(get(cb,'ylabel'),'string','Amplitude');

+ 1 - 1
data/erf/sub-001_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/qv/XM/MD5E-s13011631--618198f320d3695cba8a67d03fab7b5a.mat/MD5E-s13011631--618198f320d3695cba8a67d03fab7b5a.mat
+../../.git/annex/objects/1z/xG/MD5E-s25965437--5930ca9b2d4bba87ec030bea561ea46a.mat/MD5E-s25965437--5930ca9b2d4bba87ec030bea561ea46a.mat

+ 1 - 1
data/erf/sub-002_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/Ff/Mw/MD5E-s11869185--d9c2b10d3c0a5dd9160202cfeaf8ef94.mat/MD5E-s11869185--d9c2b10d3c0a5dd9160202cfeaf8ef94.mat
+../../.git/annex/objects/v0/09/MD5E-s23708152--97938175f25225af5016aa4a0edbac59.mat/MD5E-s23708152--97938175f25225af5016aa4a0edbac59.mat

+ 1 - 1
data/erf/sub-003_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/mZ/PZ/MD5E-s11899882--2e2999433771e61b84f7b38322cff3a8.mat/MD5E-s11899882--2e2999433771e61b84f7b38322cff3a8.mat
+../../.git/annex/objects/Gq/JG/MD5E-s23752159--22a4646b4ea5136b8f99158abd7c7a22.mat/MD5E-s23752159--22a4646b4ea5136b8f99158abd7c7a22.mat

+ 1 - 1
data/erf/sub-004_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/GV/fZ/MD5E-s12931033--39021b5851025a6805bd4f1f39f60167.mat/MD5E-s12931033--39021b5851025a6805bd4f1f39f60167.mat
+../../.git/annex/objects/7q/0W/MD5E-s25836544--6071c904dc707d0fe0d7e9d6e0fce72c.mat/MD5E-s25836544--6071c904dc707d0fe0d7e9d6e0fce72c.mat

+ 1 - 1
data/erf/sub-005_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/Gv/Mq/MD5E-s12971485--aa8b6e411a586f7ad098955823073cb4.mat/MD5E-s12971485--aa8b6e411a586f7ad098955823073cb4.mat
+../../.git/annex/objects/7v/q7/MD5E-s25892424--974e7bc670920d309dfd8c1f2d01d1ee.mat/MD5E-s25892424--974e7bc670920d309dfd8c1f2d01d1ee.mat

+ 1 - 1
data/erf/sub-006_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/7F/1v/MD5E-s11851437--ee5c73c68a4fd1e7266b9ee6f7b482aa.mat/MD5E-s11851437--ee5c73c68a4fd1e7266b9ee6f7b482aa.mat
+../../.git/annex/objects/wk/Fq/MD5E-s23653512--017580e6a613613d305a6f87ce7bd8b4.mat/MD5E-s23653512--017580e6a613613d305a6f87ce7bd8b4.mat

+ 1 - 1
data/erf/sub-007_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/27/KV/MD5E-s12976161--dbfac87116f388a1067b137b9a97079a.mat/MD5E-s12976161--dbfac87116f388a1067b137b9a97079a.mat
+../../.git/annex/objects/VQ/Qx/MD5E-s25900205--cf08168c0af24728507fca3dafa236be.mat/MD5E-s25900205--cf08168c0af24728507fca3dafa236be.mat

+ 1 - 1
data/erf/sub-008_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/7k/m4/MD5E-s11847365--01bdb409bf9a904b16d37aaa25bad5ab.mat/MD5E-s11847365--01bdb409bf9a904b16d37aaa25bad5ab.mat
+../../.git/annex/objects/KQ/6z/MD5E-s23658963--c29628ee341d487608d859b9a6f29219.mat/MD5E-s23658963--c29628ee341d487608d859b9a6f29219.mat

+ 1 - 1
data/erf/sub-009_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/5X/05/MD5E-s12962734--9c372145748bec57182951ca23d8100c.mat/MD5E-s12962734--9c372145748bec57182951ca23d8100c.mat
+../../.git/annex/objects/kz/Kp/MD5E-s25874873--14cc24a013f5926da4d43b635cb4b51f.mat/MD5E-s25874873--14cc24a013f5926da4d43b635cb4b51f.mat

+ 1 - 1
data/erf/sub-010_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/vM/4g/MD5E-s12999530--16e890cc703e1d1473b9362019df83cd.mat/MD5E-s12999530--16e890cc703e1d1473b9362019df83cd.mat
+../../.git/annex/objects/pj/p7/MD5E-s25957213--27f5523c20264e1cc89b20d7b5d69b7f.mat/MD5E-s25957213--27f5523c20264e1cc89b20d7b5d69b7f.mat

+ 1 - 1
data/erf/sub-011_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/kg/Zf/MD5E-s11908825--8cffcf35aa0c30676ad8981dc111b527.mat/MD5E-s11908825--8cffcf35aa0c30676ad8981dc111b527.mat
+../../.git/annex/objects/Pp/ZV/MD5E-s23763301--a04575f217114c9e41c4cbbe023be617.mat/MD5E-s23763301--a04575f217114c9e41c4cbbe023be617.mat

+ 1 - 1
data/erf/sub-012_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/gW/j3/MD5E-s11887442--bdcc491df2b69c965b680e9694253b38.mat/MD5E-s11887442--bdcc491df2b69c965b680e9694253b38.mat
+../../.git/annex/objects/Km/KG/MD5E-s23745801--a63b678996434a57805a68fff361368c.mat/MD5E-s23745801--a63b678996434a57805a68fff361368c.mat

+ 1 - 1
data/erf/sub-013_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/qX/px/MD5E-s12961623--29065ac232af8402a2422c8b74a9607e.mat/MD5E-s12961623--29065ac232af8402a2422c8b74a9607e.mat
+../../.git/annex/objects/W9/1v/MD5E-s25868372--510b24ef57fd4c57d5eb93c13a11d164.mat/MD5E-s25868372--510b24ef57fd4c57d5eb93c13a11d164.mat

+ 1 - 1
data/erf/sub-014_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/0j/Kg/MD5E-s11913704--f2e99f18643c13cbb46fa99c2dfa4e8b.mat/MD5E-s11913704--f2e99f18643c13cbb46fa99c2dfa4e8b.mat
+../../.git/annex/objects/Km/5m/MD5E-s23782386--8073df9fb9a4e1d72950563860210a18.mat/MD5E-s23782386--8073df9fb9a4e1d72950563860210a18.mat

+ 1 - 1
data/erf/sub-015_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/zv/kM/MD5E-s11885215--be7983d8363359fb1b204cbd16610a91.mat/MD5E-s11885215--be7983d8363359fb1b204cbd16610a91.mat
+../../.git/annex/objects/m1/F7/MD5E-s23733319--cbb328ed0e710872db2497f77d8ca70d.mat/MD5E-s23733319--cbb328ed0e710872db2497f77d8ca70d.mat

+ 1 - 1
data/erf/sub-016_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/54/16/MD5E-s12963932--9f6bdf51c2ef40e036a323ce5f855d99.mat/MD5E-s12963932--9f6bdf51c2ef40e036a323ce5f855d99.mat
+../../.git/annex/objects/6p/8F/MD5E-s25851775--4bdee37830e0fdb5c945150840573deb.mat/MD5E-s25851775--4bdee37830e0fdb5c945150840573deb.mat

+ 1 - 1
data/erf/sub-017_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/w1/Gg/MD5E-s11914288--f674d39f6a7ef3cc0352649a857f35b5.mat/MD5E-s11914288--f674d39f6a7ef3cc0352649a857f35b5.mat
+../../.git/annex/objects/z5/6j/MD5E-s23783046--43769779c35b3725ccd5d01e5aa88d4b.mat/MD5E-s23783046--43769779c35b3725ccd5d01e5aa88d4b.mat

+ 1 - 1
data/erf/sub-018_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/4j/p9/MD5E-s12962243--198dc92256655e255cd0aad0a53f8963.mat/MD5E-s12962243--198dc92256655e255cd0aad0a53f8963.mat
+../../.git/annex/objects/9g/Zg/MD5E-s25882380--74a64dc7537c187c1cd967a9aebacea6.mat/MD5E-s25882380--74a64dc7537c187c1cd967a9aebacea6.mat

+ 1 - 1
data/erf/sub-019_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/1W/f2/MD5E-s12967756--7a8dcb024456c8cf25dab80f54b88074.mat/MD5E-s12967756--7a8dcb024456c8cf25dab80f54b88074.mat
+../../.git/annex/objects/Kx/8k/MD5E-s25911350--8ec427769c63d0d5135874125c5750e0.mat/MD5E-s25911350--8ec427769c63d0d5135874125c5750e0.mat

+ 1 - 1
data/erf/sub-020_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/PJ/8K/MD5E-s11915343--d300ec4cded166492669c07260629017.mat/MD5E-s11915343--d300ec4cded166492669c07260629017.mat
+../../.git/annex/objects/qJ/gQ/MD5E-s23841676--23921dd7be7eeb25fd6317de8cb47836.mat/MD5E-s23841676--23921dd7be7eeb25fd6317de8cb47836.mat

+ 1 - 1
data/erf/sub-021_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/q3/4m/MD5E-s12960339--058d843ae534ad32a647e5768c9afc4a.mat/MD5E-s12960339--058d843ae534ad32a647e5768c9afc4a.mat
+../../.git/annex/objects/V0/6Q/MD5E-s25914567--7d5fdc6d52b699d72c8736251893b9c8.mat/MD5E-s25914567--7d5fdc6d52b699d72c8736251893b9c8.mat

+ 1 - 1
data/erf/sub-022_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/m0/2Z/MD5E-s11834806--893da53041cbceddc15b23bf4db6f013.mat/MD5E-s11834806--893da53041cbceddc15b23bf4db6f013.mat
+../../.git/annex/objects/jx/qk/MD5E-s23630140--1a4f157fac1921a119787471952809e3.mat/MD5E-s23630140--1a4f157fac1921a119787471952809e3.mat

+ 1 - 1
data/erf/sub-023_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/wp/j6/MD5E-s12969754--7bf33fd675b5af9bf6f36f38f813b9d3.mat/MD5E-s12969754--7bf33fd675b5af9bf6f36f38f813b9d3.mat
+../../.git/annex/objects/V2/gX/MD5E-s25909644--26605a542ffaa1d8f001cb621d97b29e.mat/MD5E-s25909644--26605a542ffaa1d8f001cb621d97b29e.mat

+ 1 - 1
data/erf/sub-024_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/f0/7K/MD5E-s11891030--60f0817f17cae7f9e75ea7fa447d1f1b.mat/MD5E-s11891030--60f0817f17cae7f9e75ea7fa447d1f1b.mat
+../../.git/annex/objects/Wk/J5/MD5E-s23740098--4cc20d5531e643b3b30f5f99d84ab367.mat/MD5E-s23740098--4cc20d5531e643b3b30f5f99d84ab367.mat

+ 1 - 1
data/erf/sub-025_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/5k/jw/MD5E-s12986876--a4e76ba0bf4853f2ad30acd189d70e6e.mat/MD5E-s12986876--a4e76ba0bf4853f2ad30acd189d70e6e.mat
+../../.git/annex/objects/4w/j3/MD5E-s25945628--5b6d01b6d84425c8242b1fe135ebbd6c.mat/MD5E-s25945628--5b6d01b6d84425c8242b1fe135ebbd6c.mat

+ 1 - 1
data/erf/sub-026_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/0j/FJ/MD5E-s12976047--24299a8c737da252d56b97a6d8480f13.mat/MD5E-s12976047--24299a8c737da252d56b97a6d8480f13.mat
+../../.git/annex/objects/z1/gM/MD5E-s25938229--a643b58baccdbbcd92652525e31833f2.mat/MD5E-s25938229--a643b58baccdbbcd92652525e31833f2.mat

+ 1 - 1
data/erf/sub-027_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/K3/pF/MD5E-s12997497--026e54ce6f1e85b20414613bc9fa88f2.mat/MD5E-s12997497--026e54ce6f1e85b20414613bc9fa88f2.mat
+../../.git/annex/objects/Zm/q0/MD5E-s25970202--37364331e16212d9a130618b248480c7.mat/MD5E-s25970202--37364331e16212d9a130618b248480c7.mat

+ 1 - 1
data/erf/sub-028_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/Qp/Qx/MD5E-s12986598--73e61f013b38a3567aa8cc24a6bd2733.mat/MD5E-s12986598--73e61f013b38a3567aa8cc24a6bd2733.mat
+../../.git/annex/objects/75/28/MD5E-s25940419--03e8e976e9cb12e5cff9939346ea63f3.mat/MD5E-s25940419--03e8e976e9cb12e5cff9939346ea63f3.mat

+ 1 - 1
data/erf/sub-029_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/jV/Fj/MD5E-s12982199--6c29544a9b39c25ca855df0524ec07af.mat/MD5E-s12982199--6c29544a9b39c25ca855df0524ec07af.mat
+../../.git/annex/objects/gJ/6q/MD5E-s25915599--da02d306c00a711950089e6043693272.mat/MD5E-s25915599--da02d306c00a711950089e6043693272.mat

+ 1 - 1
data/erf/sub-030_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/89/MX/MD5E-s12962834--84c7ac2d0834f9f371ef980edcb543ae.mat/MD5E-s12962834--84c7ac2d0834f9f371ef980edcb543ae.mat
+../../.git/annex/objects/9V/f6/MD5E-s25882935--9147441e2364f2d138bf1f59a3ac6fcf.mat/MD5E-s25882935--9147441e2364f2d138bf1f59a3ac6fcf.mat

+ 1 - 1
data/erf/sub-031_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/4w/Mz/MD5E-s12981115--1691c4bddfeba645a9357a13df6d5dd9.mat/MD5E-s12981115--1691c4bddfeba645a9357a13df6d5dd9.mat
+../../.git/annex/objects/PJ/k8/MD5E-s25891755--b9ace4f0216568d0038a0f548f51ec46.mat/MD5E-s25891755--b9ace4f0216568d0038a0f548f51ec46.mat

+ 1 - 1
data/erf/sub-032_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/j3/pg/MD5E-s11835025--255092095f6c8a00aeee06bc08b7e5ba.mat/MD5E-s11835025--255092095f6c8a00aeee06bc08b7e5ba.mat
+../../.git/annex/objects/z2/0g/MD5E-s23603875--90dcd5018c3923b77c6548b203779a5c.mat/MD5E-s23603875--90dcd5018c3923b77c6548b203779a5c.mat

+ 1 - 1
data/erf/sub-033_erf.mat

@@ -1 +1 @@
-../../.git/annex/objects/G6/kF/MD5E-s11864811--188a6bed6fc0d89a63a459ded09bb149.mat/MD5E-s11864811--188a6bed6fc0d89a63a459ded09bb149.mat
+../../.git/annex/objects/k4/qx/MD5E-s23679316--c089c30a1967868b1c2ee99671839f2a.mat/MD5E-s23679316--c089c30a1967868b1c2ee99671839f2a.mat

+ 1 - 1
data/erp/sub-001_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/5Z/Q2/MD5E-s18856740--c86ecd68e17ee00a22976fcb19528038.mat/MD5E-s18856740--c86ecd68e17ee00a22976fcb19528038.mat
+../../.git/annex/objects/G7/73/MD5E-s18856858--80fb4f179b02a13cd2ef29c8c141084d.mat/MD5E-s18856858--80fb4f179b02a13cd2ef29c8c141084d.mat

+ 1 - 1
data/erp/sub-001_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/X4/m8/MD5E-s18850165--a512d0c843e81001e470c4cb21f82e2e.mat/MD5E-s18850165--a512d0c843e81001e470c4cb21f82e2e.mat
+../../.git/annex/objects/x0/Zw/MD5E-s18850313--522cfdd3a3c125e93877f6e4e0b11135.mat/MD5E-s18850313--522cfdd3a3c125e93877f6e4e0b11135.mat

+ 1 - 1
data/erp/sub-002_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/w3/59/MD5E-s17943384--02d3d81e912025a9f36836d895d11049.mat/MD5E-s17943384--02d3d81e912025a9f36836d895d11049.mat
+../../.git/annex/objects/94/3p/MD5E-s17943972--79b0ecb5727ffdb663e6a40ade3a6903.mat/MD5E-s17943972--79b0ecb5727ffdb663e6a40ade3a6903.mat

+ 1 - 1
data/erp/sub-002_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/QP/f7/MD5E-s17937290--687f3f7e543ce83fbc968d2201903b35.mat/MD5E-s17937290--687f3f7e543ce83fbc968d2201903b35.mat
+../../.git/annex/objects/f6/mz/MD5E-s17937451--03d55e1b8dcba6e20a8c677e05c6e531.mat/MD5E-s17937451--03d55e1b8dcba6e20a8c677e05c6e531.mat

+ 1 - 1
data/erp/sub-003_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/J6/4j/MD5E-s17977217--0e849452fd478ffe97e8e4e9baf66be4.mat/MD5E-s17977217--0e849452fd478ffe97e8e4e9baf66be4.mat
+../../.git/annex/objects/6q/mW/MD5E-s17977030--cc5f3a948f0d82149e7edc87070b2ea2.mat/MD5E-s17977030--cc5f3a948f0d82149e7edc87070b2ea2.mat

+ 1 - 1
data/erp/sub-003_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/xv/0Q/MD5E-s17975600--c29e1d75533cede6665ca1b92e4febe8.mat/MD5E-s17975600--c29e1d75533cede6665ca1b92e4febe8.mat
+../../.git/annex/objects/k2/f7/MD5E-s17975992--363d517c2cb11a16c3df5dc4e6a19962.mat/MD5E-s17975992--363d517c2cb11a16c3df5dc4e6a19962.mat

+ 1 - 1
data/erp/sub-004_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/4w/p2/MD5E-s18867198--1b2f1439953d4e0101916c5a278abadd.mat/MD5E-s18867198--1b2f1439953d4e0101916c5a278abadd.mat
+../../.git/annex/objects/3k/kp/MD5E-s18867310--91bfca595b6431450365bd5c52924890.mat/MD5E-s18867310--91bfca595b6431450365bd5c52924890.mat

+ 1 - 1
data/erp/sub-004_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/7q/8j/MD5E-s18868863--b1e494af08c030b0f9f6bb2ae0ded6bb.mat/MD5E-s18868863--b1e494af08c030b0f9f6bb2ae0ded6bb.mat
+../../.git/annex/objects/9j/6z/MD5E-s18869346--43214e51f11909b4305880c88fa4af71.mat/MD5E-s18869346--43214e51f11909b4305880c88fa4af71.mat

+ 1 - 1
data/erp/sub-005_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/8Q/jF/MD5E-s18858655--2bde988ba7774f9ecb3d198fb5819a34.mat/MD5E-s18858655--2bde988ba7774f9ecb3d198fb5819a34.mat
+../../.git/annex/objects/83/z4/MD5E-s18859050--a75b9e9d57f74c0318da54ffa2b126d9.mat/MD5E-s18859050--a75b9e9d57f74c0318da54ffa2b126d9.mat

+ 1 - 1
data/erp/sub-005_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/GZ/Jz/MD5E-s18842612--db23f809166f3d959c96ce1b06e29ce6.mat/MD5E-s18842612--db23f809166f3d959c96ce1b06e29ce6.mat
+../../.git/annex/objects/wM/fM/MD5E-s18843674--b589004cdaadee3c2814d947f34d6556.mat/MD5E-s18843674--b589004cdaadee3c2814d947f34d6556.mat

+ 1 - 1
data/erp/sub-006_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/kk/2p/MD5E-s17940517--18f70987afbfe7db807c3e6f89eb2b32.mat/MD5E-s17940517--18f70987afbfe7db807c3e6f89eb2b32.mat
+../../.git/annex/objects/Xg/0w/MD5E-s17941060--5d682071fb82bfe8bbc330d96596d59b.mat/MD5E-s17941060--5d682071fb82bfe8bbc330d96596d59b.mat

+ 1 - 1
data/erp/sub-006_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/VG/41/MD5E-s17925532--b4aee9072123bf98a3065d1f5ee4ceff.mat/MD5E-s17925532--b4aee9072123bf98a3065d1f5ee4ceff.mat
+../../.git/annex/objects/0z/vq/MD5E-s17925782--3b779935183213530816ddb44ee51ee3.mat/MD5E-s17925782--3b779935183213530816ddb44ee51ee3.mat

+ 1 - 1
data/erp/sub-007_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/0X/M2/MD5E-s19566600--b3c9e27f4fe6be145994e900c0f17075.mat/MD5E-s19566600--b3c9e27f4fe6be145994e900c0f17075.mat
+../../.git/annex/objects/Gf/wJ/MD5E-s19567079--d8432ac2abe9930f25a7f2a48ecff6c7.mat/MD5E-s19567079--d8432ac2abe9930f25a7f2a48ecff6c7.mat

+ 1 - 1
data/erp/sub-007_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/50/f1/MD5E-s19571255--19d50cad20d2714eefa98bd3a09090d1.mat/MD5E-s19571255--19d50cad20d2714eefa98bd3a09090d1.mat
+../../.git/annex/objects/Pw/G4/MD5E-s19571480--6647bbcdbe8d1e77c2f222fa9a21441c.mat/MD5E-s19571480--6647bbcdbe8d1e77c2f222fa9a21441c.mat

+ 1 - 1
data/erp/sub-008_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/j0/G5/MD5E-s17939745--7eddf80c85c043fbda01dacc3c141583.mat/MD5E-s17939745--7eddf80c85c043fbda01dacc3c141583.mat
+../../.git/annex/objects/2V/xx/MD5E-s17940101--768732fd1aea53c733c7815b5ca61759.mat/MD5E-s17940101--768732fd1aea53c733c7815b5ca61759.mat

+ 1 - 1
data/erp/sub-008_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/Mm/Fm/MD5E-s17932101--7c3deebbead27909ac4a3ce026e37e68.mat/MD5E-s17932101--7c3deebbead27909ac4a3ce026e37e68.mat
+../../.git/annex/objects/gV/vq/MD5E-s17932576--ee364bf7cb3bbaecf03ff9c8fba55f6a.mat/MD5E-s17932576--ee364bf7cb3bbaecf03ff9c8fba55f6a.mat

+ 1 - 1
data/erp/sub-009_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/6g/m1/MD5E-s19586555--66ce978ff4be02b290b906ea2745379d.mat/MD5E-s19586555--66ce978ff4be02b290b906ea2745379d.mat
+../../.git/annex/objects/5X/M4/MD5E-s19586421--a9735a35f2a9411e37e0c873e79e1f5b.mat/MD5E-s19586421--a9735a35f2a9411e37e0c873e79e1f5b.mat

+ 1 - 1
data/erp/sub-009_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/pV/jV/MD5E-s19571289--059591711ef9242201875fcb76a72fa8.mat/MD5E-s19571289--059591711ef9242201875fcb76a72fa8.mat
+../../.git/annex/objects/Qm/Kw/MD5E-s19570785--f1ee80bacf09621e29d75e9afa0e94a6.mat/MD5E-s19570785--f1ee80bacf09621e29d75e9afa0e94a6.mat

+ 1 - 1
data/erp/sub-010_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/6F/P4/MD5E-s18857427--788631d31df8cddccf9c96e01a205934.mat/MD5E-s18857427--788631d31df8cddccf9c96e01a205934.mat
+../../.git/annex/objects/mg/xV/MD5E-s18858038--f7b3e466a9fd5426e6e31d31908b70fc.mat/MD5E-s18858038--f7b3e466a9fd5426e6e31d31908b70fc.mat

+ 1 - 1
data/erp/sub-010_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/JG/gp/MD5E-s18855910--4a2ad0f3bb399b38c3cd9fca8a54da62.mat/MD5E-s18855910--4a2ad0f3bb399b38c3cd9fca8a54da62.mat
+../../.git/annex/objects/MJ/ZQ/MD5E-s18856822--f0abe75e1dbdd7a532aa84c34e9ab0b2.mat/MD5E-s18856822--f0abe75e1dbdd7a532aa84c34e9ab0b2.mat

+ 1 - 1
data/erp/sub-011_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/W3/Zk/MD5E-s17944934--8d9ee244f63d42b27f9f34e057a0daae.mat/MD5E-s17944934--8d9ee244f63d42b27f9f34e057a0daae.mat
+../../.git/annex/objects/xQ/z1/MD5E-s17944899--5bac574571be9f40036cdb247883bbc1.mat/MD5E-s17944899--5bac574571be9f40036cdb247883bbc1.mat

+ 1 - 1
data/erp/sub-011_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/8g/68/MD5E-s17942065--4346be1a8596203dd163212b9f06aee5.mat/MD5E-s17942065--4346be1a8596203dd163212b9f06aee5.mat
+../../.git/annex/objects/wq/PZ/MD5E-s17942264--6e004af92befcdb2e8b6f1f3a37543d7.mat/MD5E-s17942264--6e004af92befcdb2e8b6f1f3a37543d7.mat

+ 1 - 1
data/erp/sub-012_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/Fj/5x/MD5E-s17971931--82eaf726be0400442e2bf901f4518837.mat/MD5E-s17971931--82eaf726be0400442e2bf901f4518837.mat
+../../.git/annex/objects/vV/7j/MD5E-s17972043--a10c461923ba6221568dc7182e234cd6.mat/MD5E-s17972043--a10c461923ba6221568dc7182e234cd6.mat

+ 1 - 1
data/erp/sub-012_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/Zz/8g/MD5E-s17963130--8b8e9fc9ffc62aede4ec6c6c4b5231e7.mat/MD5E-s17963130--8b8e9fc9ffc62aede4ec6c6c4b5231e7.mat
+../../.git/annex/objects/QG/P2/MD5E-s17962934--2e76e841c9ce9f41b302e0023c476e48.mat/MD5E-s17962934--2e76e841c9ce9f41b302e0023c476e48.mat

+ 1 - 1
data/erp/sub-013_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/pm/M1/MD5E-s19580130--1bda614c700b7c9d7e7bdeaffae2e495.mat/MD5E-s19580130--1bda614c700b7c9d7e7bdeaffae2e495.mat
+../../.git/annex/objects/p6/80/MD5E-s19580400--c9ca493f0ea6a2d6f62c3629f4676d6f.mat/MD5E-s19580400--c9ca493f0ea6a2d6f62c3629f4676d6f.mat

+ 1 - 1
data/erp/sub-013_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/Qq/WW/MD5E-s19583510--57643bfda3091f2b245a2b4cc1cb0516.mat/MD5E-s19583510--57643bfda3091f2b245a2b4cc1cb0516.mat
+../../.git/annex/objects/wv/gx/MD5E-s19584074--d0082012a01e5bb9810beda03436bf10.mat/MD5E-s19584074--d0082012a01e5bb9810beda03436bf10.mat

+ 1 - 1
data/erp/sub-014_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/FG/VQ/MD5E-s17970794--5e106e74f403ca5f163a5d3a28871433.mat/MD5E-s17970794--5e106e74f403ca5f163a5d3a28871433.mat
+../../.git/annex/objects/pp/fJ/MD5E-s17971338--0e764514101fcf96b5e7e62c2cb562e2.mat/MD5E-s17971338--0e764514101fcf96b5e7e62c2cb562e2.mat

+ 1 - 1
data/erp/sub-014_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/wM/km/MD5E-s17966722--d18a02249d1324ad9cc1cb5f4d3fb68f.mat/MD5E-s17966722--d18a02249d1324ad9cc1cb5f4d3fb68f.mat
+../../.git/annex/objects/pk/vM/MD5E-s17966819--4092db10126c6b81f02d8d7ceee3d35e.mat/MD5E-s17966819--4092db10126c6b81f02d8d7ceee3d35e.mat

+ 1 - 1
data/erp/sub-015_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/ZJ/gV/MD5E-s17965313--03b16fb2b682a048af6bb40ff10b6a4c.mat/MD5E-s17965313--03b16fb2b682a048af6bb40ff10b6a4c.mat
+../../.git/annex/objects/xK/V1/MD5E-s17965983--0cdede9fa07891d413d30ed7b1336c0c.mat/MD5E-s17965983--0cdede9fa07891d413d30ed7b1336c0c.mat

+ 1 - 1
data/erp/sub-015_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/53/j0/MD5E-s17958084--7f59057057f79bb170a5e07e17d2e4ca.mat/MD5E-s17958084--7f59057057f79bb170a5e07e17d2e4ca.mat
+../../.git/annex/objects/MK/V0/MD5E-s17958235--cf8eac1ca2ac013890b98dbfd9f88da1.mat/MD5E-s17958235--cf8eac1ca2ac013890b98dbfd9f88da1.mat

+ 1 - 1
data/erp/sub-016_erp.mat

@@ -1 +1 @@
-../../.git/annex/objects/kZ/vg/MD5E-s19575544--5b7580b7304377e2781ee43974a41365.mat/MD5E-s19575544--5b7580b7304377e2781ee43974a41365.mat
+../../.git/annex/objects/1p/gQ/MD5E-s19575412--bd41b217221447b5964ab8221414aa31.mat/MD5E-s19575412--bd41b217221447b5964ab8221414aa31.mat

+ 1 - 1
data/erp/sub-016_erp_bl.mat

@@ -1 +1 @@
-../../.git/annex/objects/W4/5k/MD5E-s19580731--e6e61604a87da32b39b61e3a26f95e06.mat/MD5E-s19580731--e6e61604a87da32b39b61e3a26f95e06.mat
+../../.git/annex/objects/Qf/30/MD5E-s19580838--fc851ffaf163903dd700aa3254f96bcc.mat/MD5E-s19580838--fc851ffaf163903dd700aa3254f96bcc.mat

+ 0 - 0
data/erp/sub-017_erp.mat


Some files were not shown because too many files changed in this diff