-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmergeMetaCalls.m
61 lines (53 loc) · 1.89 KB
/
mergeMetaCalls.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
%mergeMetaCalls
%% so first you need to load the metadata, and then you need to designate
% the call folder
load('C:\Users\Jadhavlab\Downloads\USVmetadata2021-10-15.mat');
callFolder='G:\USV data\Detections';
allCallFiles=cellfun(@(a) string(a), getAllFiles(callFolder,'.mat'));
%% attach the calls to each session
missingfiles=[];
for i=1:height(USVSession)
fileName= USVSession.FileName(i);
mymatch=find(contains(allCallFiles,append(fileName, " ")));
fprintf('File pattern is %s \n', fileName);
fprintf(' Match File: %s \n',allCallFiles(mymatch));
% try to fix
if length(mymatch)~=1
fprintf( ' ***NO MATCH FILE FOR %s \n', fileName);
mymatch=input(sprintf('Match Filename in AllCallFiles with %s \n',...
fileName));
end
% if fixed
if length(mymatch)==1
sessdat=load(allCallFiles(mymatch));
USVSession.Calls{i}=sessdat.Calls;
USVSession.audiodata{i}=sessdat.audiodata;
else
missingfiles=[missingfiles; fileName];
end
fprintf('\n');
end
%% attach stats to each session
statFolder='G:\USV data\CallStats2021-10-15';
allStatFiles=cellfun(@(a) string(a), getAllFiles(statFolder,'.xlsx'));
missingfiles=[];
for i=1:height(USVSession)
fileName= USVSession.FileName(i);
% add following space
mymatch=find(contains(allStatFiles,append(fileName, " ")));
fprintf('File pattern is %s \n', fileName);
fprintf(' Match File: %s \n',allStatFiles(mymatch));
% try to fix
if length(mymatch)~=1
fprintf( ' ***NO MATCH FILE FOR %s \n', fileName);
mymatch=input(sprintf('Match Filename in AllCallFiles with %s \n',...
fileName));
end
% if fixed
if length(mymatch)==1
callStats = importCallStats(allStatFiles(mymatch));
USVSession.CallStats{i}=callStats;
else
missingfiles=[missingfiles; fileName];
end
end