-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeleteNonSpikeExprFiles.m
86 lines (54 loc) · 1.51 KB
/
DeleteNonSpikeExprFiles.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
function [ ] = DeleteNonSpikeExprFiles(expType)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
if expType
expFold = 'E:\DBS_Spike_Analysis_Plenary\P50_Data\RawNeurophysiology\';
cd(expFold)
else
expFold = 'E:\DBS_Spike_Analysis_Plenary\SNr_EyeTrack\RawNeurophysiology\';
cd(expFold)
end
% Get folder list
rawFold1 = dir;
rawFold1 = rawFold1(3,end);
rawFoldNa = {rawFold1.name};
for rfi = 1:length(rawFoldNa)
% CD to each folder
tempFold = rawFoldNa{rfi};
tempDir = strcat(expFold,tempFold);
cd(tempDir)
[checkFlag] = checkDone(tempDir);
if checkFlag
continue
end
% Get file list of depths
rawList1 = dir('*.mat');
rawListNa = {rawList1.name};
% Determine which files to delete
for rli = 1:length(rawListNa)
tempFname = rawListNa{rli};
% load(tempFname)
tTLMatobj = matfile(tempFname);
tTLMatinfo = whos(tTLMatobj);
tTLNames = {tTLMatinfo.name};
% Check for TTL file names
ttlCheck = cellfun(@(x) ~isempty(strfind(x,'C1_DI00')), tTLNames);
if any(ttlCheck)
continue
else
delete(tempFname)
end
end
save('Done.txt')
end
end % End of main function
function [checkFlag] = checkDone(fileLoc)
cd(fileLoc);
fileListtxt = dir('*.txt');
fileCheck = {fileListtxt.name};
if isempty(fileCheck)
checkFlag = 0;
else
checkFlag = 1;
end
end