forked from psiwex/altaircode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathartReport3.m
101 lines (88 loc) · 3.23 KB
/
artReport3.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
% Artifact Rejection: EEG Processing Summary Script for Gorka lab, James Glazer 3/7/23: glazerja1@gmail.com
%
% Description: Loads fully processed ERPsets and saves artifact rejection information for each subject
% Output file includes: accepted and rejected trial count for each bin in your Binlister
%
% How to use:
% 1. Run AFTER full preprocessing using EEG_Processing_Gorka.m
% 2. Enter the erpset folder location path for .erp files saved after completing preprocessing
% 3. Enter the file names for each subject erpset in the subName list
% 4. Click Run.
clear all; close all; clc;
file_name = 'summaryNpuArtifactRejections0.txt';
%dataset_loadpath = 'C:\Users\glaze\Desktop\GorkaScripts\data\datasets\Processing\';
dataset_loadpath = 'C:\Users\John\Documents\MATLAB\soarData\';
%channelLocationFile = 'C:\Users\glaze\Documents\MatLabPrograms\eeglab2020_0\plugins\dipfit\standard_BESA\standard-10-5-cap385.elp';
channelLocationFile = 'C:\Users\John\Documents\MATLAB\eeglab2021.1\plugins\dipfit\standard_BESA\standard-10-5-cap385.elp';
erpset_savepath = 'C:\Users\John\Documents\MATLAB\soarData\erpLabs\';
load('erpHeader','ERPheader');
% Enter subject IDs here
subName = {'TRY100a_ERN', 'TRY101a_ERN','TRY102a_ERN'};
dirName = 'C:\Users\John\Documents\MATLAB\soarData\';
%subName='OSU-00001-04B-01-ERN.bdf';
%[sub] = subdir(dirName);
%metaData=struct2table(sub);
%fileList=metaData.name;
load('erpnpuNames.mat','erpnpuNames');
%load('erpernNames.mat','erpernNames');
%load('erpernsFiles.mat','erpernsFiles');
%fileList=erpernsFiles;
%ii=fileList(1);
subst='_erpset.erp';
outEx='_kukri_npu.mat';
%load EEGlab
%[ALLEEG EEG CURRENTSET ALLCOM] = eeglab;
for iSubject = 1:length(erpnpuNames)
fName=erpnpuNames{iSubject};
fOut=strcat(fName,outEx);
load(fOut);
ERP=EEG;
ERP.bindescr=ERPheader;
%ERP=erperns{iSubject};
index = strfind(fName, '\');
fName=fName((index(end)+1):end);
% ii=fileList(iSubject);
% fName=ii{1};
% tf = endsWith(fName,subst);
%
% if tf ~= (0)
% try
% load fully processed .erp erpset files
% ERP = pop_loaderp('filename', [fName],...
% 'filepath', erpset_savepath);
% if first subject, save the bin labels at header
if iSubject == 1
% save headers
fid = fopen(file_name, 'a');
header = 'subject, ';
fprintf(fid, header);
% populate accepted bin labels
binz=min([ERP.nbin; length(ERP.bindescr)]);
for bin = 1:binz
fprintf(fid, [char(ERP.bindescr(bin)) ' accepted, ']);
end
% populate rejected bin labels
for bin = 1:binz
fprintf(fid, [char(ERP.bindescr(bin)) ' rejected, ']);
end
fclose(fid);
end
% open file to append
fid = fopen(file_name, 'a');
% save subject
fprintf(fid, ['\n' fName ', ']);
% save accepted trial count per bin
binz=min([ERP.nbin; length(ERP.bindescr)]);
for bin = 1:binz
fprintf(fid, [char(string(ERP.ntrials.accepted(bin))) ', ']);
end
% save rejected trial count per bin
for bin = 1:binz
fprintf(fid, [char(string(ERP.ntrials.rejected(bin))) ', ']);
end
fclose(fid);
% catch
% end
% end
end
%eeglab redraw