Browse Source

harmonize naming for MATLAB

kosciessa 2 years ago
parent
commit
3b33343b1d
27 changed files with 3 additions and 189 deletions
  1. 0 0
      CHANGELOG.md
  2. 0 189
      code/01_prepare_preprocessing.m
  3. 3 0
      code/README.md
  4. 0 0
      code/a2_visual_inspection.m
  5. 0 0
      code/a3_ica/E_STSW_ica1_180108.m
  6. 0 0
      code/a3_ica/E_STSW_ica1_180108_START.sh
  7. 0 0
      code/a3_ica/E_STSW_ica1_180108_START_repeat.sh
  8. 0 0
      code/a3_ica/E_STSW_ica1_180108_START_repeat2.sh
  9. 0 0
      code/a3_ica/E_STSW_ica1_180108_prepare.sh
  10. 0 0
      code/a3_ica/E_STSW_ica1_180108_run.sh
  11. 0 0
      code/a3_ica/mccExcludedFiles.log
  12. 0 0
      code/a4_ica_labeling.m
  13. 0 0
      code/a5_segmentation_raw_data/G_STSW_segmentation_raw_data_180111.m
  14. 0 0
      code/a5_segmentation_raw_data/G_STSW_segmentation_raw_data_180111_START.sh
  15. 0 0
      code/a5_segmentation_raw_data/G_STSW_segmentation_raw_data_180111_noTardis.m
  16. 0 0
      code/a5_segmentation_raw_data/G_STSW_segmentation_raw_data_180111_prepare.sh
  17. 0 0
      code/a5_segmentation_raw_data/G_STSW_segmentation_raw_data_180111_run.sh
  18. 0 0
      code/a5_segmentation_raw_data/mccExcludedFiles.log
  19. 0 0
      code/a6_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123.m
  20. 0 0
      code/a6_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_START.sh
  21. 0 0
      code/a6_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_START_rerun.sh
  22. 0 0
      code/a6_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_noTardis.m
  23. 0 0
      code/a6_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_prepare.sh
  24. 0 0
      code/a6_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_run.sh
  25. 0 0
      code/a6_automatic_artifact_correction/mccExcludedFiles.log
  26. 0 0
      code/a7_prep_data_for_analysis.m
  27. 0 0
      code/a8_assign_conditions_to_data.m

+ 0 - 0
CHANGELOG.md


+ 0 - 189
code/01_prepare_preprocessing.m

@@ -1,189 +0,0 @@
-%% A_prepare_preprocessing_StateSwitch_170913
-
-% prepare (i.e. filter + downsample data for ICA1)
-
-% INPUT: eeglab structures: EEG data, merged with eye tracking data
-
-% 170913 | JQK adapted function from MD's LC-NE scripts
-% 180205 | added OA IDs, corrected paths
-% 180207 | 2227 changed channels
-
-%% initialize
-
-restoredefaultpath;
-clear all; close all; pack; clc;
-
-%% pathdef
-
-%pn.eeg_root     = '/Users/kosciessa/Desktop/mountpoint_tardis_LNDG/LNDG/StateSwitch/WIP_eeg/SA_preproc_study_YA/';
-pn.study        = '/Volumes/LNDG/Projects/StateSwitch/';
-pn.eeg_root     = [pn.study, 'dynamic/data/eeg/task/A_preproc/SA_preproc_study/'];
-pn.dynamic_In   = [pn.eeg_root, 'B_data/B_EEG_ET_ByRun/'];
-pn.eyePlots     = [pn.eeg_root, 'C_figures/B_EyeChannels/']; mkdir(pn.eyePlots);
-pn.EEG_out      = [pn.eeg_root, 'B_data/C_EEG_FT/']; mkdir(pn.EEG_out);
-pn.History_out  = [pn.eeg_root, 'B_data/D_History/']; mkdir(pn.History_out);
-        
-%% add ConMemEEG tools
-
-pn.MWBtools     = [pn.eeg_root, 'T_tools/fnct_MWB'];            addpath(genpath(pn.MWBtools));
-pn.THGtools     = [pn.eeg_root, 'T_tools/fnct_THG'];            addpath(genpath(pn.THGtools));
-pn.commontools  = [pn.eeg_root, 'T_tools/fnct_common'];         addpath(genpath(pn.commontools));
-pn.fnct_JQK     = [pn.eeg_root, 'T_tools/fnct_JQK/'];           addpath(genpath(pn.fnct_JQK));
-pn.FT           = [pn.eeg_root, 'T_tools/fieldtrip-20170904/']; addpath(pn.FT); ft_defaults;
-pn.scripts      = [pn.eeg_root, 'A_scripts/helper/']; addpath(pn.scripts);
-
-%% datadef
-
-condEEG = 'dynamic';
-
-%% define IDs for preprocessing
-
-% % N = 47 (1213 excluded);
-% IDs = {'1117';'1118';'1120';'1124';'1126';'1131';'1132';'1135';'1136';'1138';'1144';'1151';'1158';'1160';'1163';'1164';'1167';'1169';'1172';'1173';'1178';'1182';'1215';'1216';'1219';'1221';'1223';'1227';'1228';'1233';'1234';'1237';'1239';'1240';'1243';'1245';'1247';'1250';'1252';'1257';'1261';'1265';'1266';'1268';'1270';'1276';'1281'};
-
-% N = 53 OAs;
-IDs = {'2104';'2107';'2108';'2112';'2118';'2120';'2121';'2123';'2125';'2129';'2130';'2131';'2132';'2133';'2134';'2135';'2139';'2140';'2145';'2147';'2149';'2157';'2160';'2201';'2202';'2203';'2205';'2206';'2209';'2210';'2211';'2213';'2214';'2215';'2216';'2217';'2219';'2222';'2224';'2226';'2227';'2236';'2237';'2238';'2241';'2244';'2246';'2248';'2250';'2251';'2252';'2258';'2261'};
-
-%% loop IDs
-for id = 1:length(IDs)
-
-%%  preprocessing
-%if ~exist([pdat.analyses.EEG_dat '\' num2str(ID(id)) '\raw_eeg\' num2str(ID(id)) '_' condEEG '_EEG_Raw_Rlm_Flh_Res.mat'],'file')
-
-%     try
-    
-    for indRun = 1:4
-    
-        display(['processing ID ' IDs{id}, ' Run ', num2str(indRun)]);
-        
-        file = [pn.([condEEG, '_In']), IDs{id} ,'_r',num2str(indRun), '_', condEEG, '_eyeEEG.set'];
-
-    %%  load data
-
-        cfg_preprocessing           = [];
-        cfg_preprocessing.datafile  = file;
-
-        % load header & event information
-        config              = ft_read_header(cfg_preprocessing.datafile);
-        config.data_file    = cfg_preprocessing.datafile;
-        config.mrk          = ft_read_event(cfg_preprocessing.datafile);
-
-        % define reading & preprocessing parameters
-        cfg_preprocessing.channel     = {'all'};
-        cfg_preprocessing.implicitref = 'REF'; % recover implicit reference
-        
-        % get all data first, then apply specific steps only for subsets
-        data_eyeEEG = ft_preprocessing(cfg_preprocessing);
-
-        %% SWITCH CHANNELS ACCORDING TO ARRANGEMENT!
-        
-%         if max(strcmp(IDs{id}, {'1213'}))==1
-%             data_eyeEEG = SS_switchChannels_Pilot_Study(data_eyeEEG);
-        if max(strcmp(IDs{id}, {'1126'; '2227'}))==1
-            data_eyeEEG = SS_switchChannels_GreenYellow(data_eyeEEG);       % green and yellow boxes exchanged
-            data_eyeEEG = SS_switchChannels_Study_noA1(data_eyeEEG);        % TP9 and TP10 exchanged manually
-        elseif max(strcmp(IDs{id}, {'1216'}))==1
-            data_eyeEEG = SS_switchChannels_GreenYellow(data_eyeEEG);       % green and yellow boxes exchanged
-            data_eyeEEG = SS_switchChannels_Study(data_eyeEEG);             % TP9(A1) and TP10(FCz) wrongly ordered in workspace
-        elseif max(strcmp(IDs{id}, {'1118'; '1215'; '1124'}))==1
-            data_eyeEEG = SS_switchChannels_Study_noA1(data_eyeEEG);        % TP9 and TP10 exchanged manually
-        else 
-            data_eyeEEG = SS_switchChannels_Study(data_eyeEEG);             % TP9(A1) and TP10(FCz) wrongly ordered in workspace
-        end
-        data_eyeEEG = SS_changeChannels(data_eyeEEG);
-        
-        %% Plot excerpt from eye channels
-        
-        h = figure;
-        subplot(3,1,1);
-        plot(zscore(data_eyeEEG.trial{1,1}(63,5000:15000),[],2)); % LHEOG
-        hold on; plot(zscore(data_eyeEEG.trial{1,1}(64,5000:15000),[],2)); % RHEOG
-        xlim([0 10000]); legend({'LHEOG'; 'RHEOG'});
-        subplot(3,1,2);
-        %hold on; plot(zscore(data_eyeEEG.trial{1,1}(65,5000:15000),[],2)); % ECG
-        hold on; plot(zscore(data_eyeEEG.trial{1,1}(62,5000:15000),[],2)); % IOR
-        hold on; plot(zscore(data_eyeEEG.trial{1,1}(24,5000:15000),[],2)); % FT8
-        xlim([0 10000]); legend({'IOR'; 'FT8'});
-        subplot(3,1,3);
-        if size(data_eyeEEG.trial{1,1},1)>66
-            hold on; plot(zscore(data_eyeEEG.trial{1,1}(67,5000:15000),[],2)); % left Gaze X
-            hold on; plot(zscore(data_eyeEEG.trial{1,1}(68,5000:15000),[],2)); % left Gaze Y
-            xlim([0 10000]);legend({'left X'; 'left Y'});
-        end
-        pn.plotFolder = pn.eyePlots;
-        figureName = [IDs{id} ,'_r',num2str(indRun), '_', condEEG, '_eyeChannels'];
-        saveas(h, [pn.plotFolder, figureName], 'png');
-        close(h);
-
-        %% continue preprocessing
-        
-        % spare ECG from reref!
-        tmp.data_ECG = data_eyeEEG;
-
-        cfg_ECG                 = [];
-        cfg_ECG.channel         = {'ECG'};
-        cfg_ECG.bsfilter        = 'yes';
-        cfg_ECG.bsfiltord       = 4;
-        cfg_ECG.bsfreq          = [48 52];
-        tmp.data_ECG            = ft_preprocessing(cfg_ECG, tmp.data_ECG);
-
-        % exclude ET, ECG channel (and others) here?
-
-        cfg_preprocessing               = [];                                 
-        cfg_preprocessing.channel       = {'all','-TIME','-L-GAZE-X','-L-GAZE-Y','-L-AREA','-L-VEL-X','-L-VEL-Y','-RES-X','-RES-Y','-INPUT'};
-
-        cfg_preprocessing.continuous  = 'yes';
-        cfg_preprocessing.demean      = 'yes';
-
-        cfg_preprocessing.reref       = 'yes';
-        cfg_preprocessing.refchannel  = {'A1', 'A2'};
-        cfg_preprocessing.implicitref = 'A2';
-
-        cfg_preprocessing.hpfilter    = 'yes';
-        cfg_preprocessing.hpfreq      = 1;
-        cfg_preprocessing.hpfiltord   = 4;
-        cfg_preprocessing.hpfilttype  = 'but';
-
-        cfg_preprocessing.lpfilter    = 'yes';
-        cfg_preprocessing.lpfreq      = 100;
-        cfg_preprocessing.lpfiltord   = 4;
-        cfg_preprocessing.lpfilttype  = 'but';
-
-    %     cfg_preprocessing.bsfilter        = 'yes';
-    %     cfg_preprocessing.bsfiltord       = 4;
-    %     cfg_preprocessing.bsfreq          = [48 52];
-
-        % define settings for resampling
-        cfg_resample.resamplefs = 250;
-        cfg_resample.detrend    = 'no';
-        cfg_resample.feedback   = 'no';
-        cfg_resample.trials     = 'all';
-
-        % get data
-        % load complete data at once & resample afterwards
-        data_EEG = ft_preprocessing(cfg_preprocessing, data_eyeEEG);
-
-        % after reref, copy original ECG (we don't want it rerefed)
-        data_EEG.trial{1,1}(find(strcmp(data_EEG.label , 'ECG')),:) = tmp.data_ECG.trial{1,1};
-        clear tmp;
-
-        data_EEG = ft_resampledata(cfg_resample,data_EEG);
-        % change data precision to single
-        for t = 1:length(data_EEG.trial)
-            data_EEG.trial{t} = single(data_EEG.trial{t});
-        end; clear t
-
-    %%  remove data at edges
-        % not implemented & maybe not necessary
-    %%  save data
-
-        save([pn.EEG_out, IDs{id}, '_r',num2str(indRun), '_', condEEG, '_EEG_Raw_Rlm_Flh_Res.mat'],'data_EEG', '-v7.3');
-        save([pn.EEG_out, IDs{id}, '_r',num2str(indRun), '_', condEEG, '_eyeEEG_Raw.mat'],'data_eyeEEG', '-v7.3');
-        % save config
-        save([pn.History_out, IDs{id}, '_r',num2str(indRun), '_', condEEG, '_config.mat'],'config');
-        % clear variables
-        clear cfg_* config data_EEG data_eyeEEG file
-    
-    end % run loop
-
-end; clear id;

+ 3 - 0
code/README.md

@@ -4,6 +4,9 @@ Steps 1-4 create filters (e.g., from the ICA, segment labeling), which later get
 
 All steps use FieldTrip and were executed within MATLAB 2020a.
 
+Deviations from the standard pipeline:
+- no ECG available, whcih would normally guide heart component labeling
+
 ---
 
 ### **01_prepare_preprocessing**

code/02_visual_inspection.m → code/a2_visual_inspection.m


code/03_ica/E_STSW_ica1_180108.m → code/a3_ica/E_STSW_ica1_180108.m


code/03_ica/E_STSW_ica1_180108_START.sh → code/a3_ica/E_STSW_ica1_180108_START.sh


code/03_ica/E_STSW_ica1_180108_START_repeat.sh → code/a3_ica/E_STSW_ica1_180108_START_repeat.sh


code/03_ica/E_STSW_ica1_180108_START_repeat2.sh → code/a3_ica/E_STSW_ica1_180108_START_repeat2.sh


code/03_ica/E_STSW_ica1_180108_prepare.sh → code/a3_ica/E_STSW_ica1_180108_prepare.sh


code/03_ica/E_STSW_ica1_180108_run.sh → code/a3_ica/E_STSW_ica1_180108_run.sh


code/03_ica/mccExcludedFiles.log → code/a3_ica/mccExcludedFiles.log


code/04_ica_labeling.m → code/a4_ica_labeling.m


code/05_segmentation_raw_data/G_STSW_segmentation_raw_data_180111.m → code/a5_segmentation_raw_data/G_STSW_segmentation_raw_data_180111.m


code/05_segmentation_raw_data/G_STSW_segmentation_raw_data_180111_START.sh → code/a5_segmentation_raw_data/G_STSW_segmentation_raw_data_180111_START.sh


code/05_segmentation_raw_data/G_STSW_segmentation_raw_data_180111_noTardis.m → code/a5_segmentation_raw_data/G_STSW_segmentation_raw_data_180111_noTardis.m


code/05_segmentation_raw_data/G_STSW_segmentation_raw_data_180111_prepare.sh → code/a5_segmentation_raw_data/G_STSW_segmentation_raw_data_180111_prepare.sh


code/05_segmentation_raw_data/G_STSW_segmentation_raw_data_180111_run.sh → code/a5_segmentation_raw_data/G_STSW_segmentation_raw_data_180111_run.sh


code/05_segmentation_raw_data/mccExcludedFiles.log → code/a5_segmentation_raw_data/mccExcludedFiles.log


code/06_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123.m → code/a6_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123.m


code/06_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_START.sh → code/a6_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_START.sh


code/06_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_START_rerun.sh → code/a6_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_START_rerun.sh


code/06_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_noTardis.m → code/a6_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_noTardis.m


code/06_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_prepare.sh → code/a6_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_prepare.sh


code/06_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_run.sh → code/a6_automatic_artifact_correction/H_STSW_automatic_artifact_correction_180123_run.sh


code/06_automatic_artifact_correction/mccExcludedFiles.log → code/a6_automatic_artifact_correction/mccExcludedFiles.log


code/07_prep_data_for_analysis.m → code/a7_prep_data_for_analysis.m


code/08_assignConditionsToData.m → code/a8_assign_conditions_to_data.m