-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathantennalMovementFromRecImages.m
executable file
·83 lines (69 loc) · 2.64 KB
/
antennalMovementFromRecImages.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
load('/Users/galileo/Dropbox (HMS)/p2/dataTable_p2.mat', 'T')
for t = 9
clc
flyNum = T.flynum(t);
if 1000-flyNum>0
cellNum = 1;
flyNum3digits = flyNum;
else
cellNum = mod(flyNum, 10);
flyNum3digits = floor(flyNum/10);
end
disp(T.metadatafiles{t})
metadataFiles = dir(sprintf('/Users/galileo/Dropbox (HMS)/p2/fly%3d_PP/fly%3d_cell%02d/metadata_*.mat', flyNum3digits, flyNum3digits, cellNum));
cellFolder = metadataFiles(1).folder;
metadataFiles = {metadataFiles(:).name};
antRecFiles = dir(sprintf('/Users/galileo/Dropbox (HMS)/p2/fly%3d_PP/piezosDispl_fly%3d*.mat', flyNum3digits, flyNum3digits));
flyFolder = antRecFiles(1).folder;
antRecFiles = {antRecFiles(:).name};
chronoFiles = cat(2, metadataFiles, antRecFiles); %not as important!!
for c = 1:length(chronoFiles)
cx = strfind(chronoFiles{c}, '_201');
numFiles{c} = chronoFiles{c}(cx+1:end);
end
[~, I] = sort(numFiles);
clear numFiles c cx
disp('chronologically sorted files:')
chronoFiles = chronoFiles(I);
disp(chronoFiles')
calibrationI = false(size(antRecFiles));
calibrationData = [];
clear A
for i = 1:length(antRecFiles)
a = load(fullfile(flyFolder, antRecFiles{i}));
if isfield(a, 'dispFrames')
calibrationI(i) = true;
calibrationData(i).savedCalData = a;
calibrationData(i).armL = nanmedian(calibrationData(i).savedCalData.armL_um);
calibrationData(i).armR = nanmedian(calibrationData(i).savedCalData.armR_um);
end
A{i} = a.allFr;
end
save(sprintf('/Users/galileo/Dropbox (HMS)/p2/antImages_fly%d.mat', flyNum), 'A', 'calibrationI', 'calibrationData', ...
'chronoFiles', 'antRecFiles')
end
% save(sprintf('/Users/galileo/Dropbox (HMS)/p2/antImages_fly%3d.mat', flyNum), 'A', 'calibrationI', 'calibrationData', ...
% 'chronoFiles', 'antRecFiles')
%% %% mostra uno stesso frame over time (across all recs)
offsetFig = 10;
warning('off')
cam = 2; % 2 is bottom camera
fr = 9; % 3 6 9 are rest, piezo-on
% cab(1)
for i = 1:length(A)
figure(i+offsetFig)
imshow(A{i}(cam).frames(:,:,fr));
title(sprintf('frame %d -- rec %d: %s',fr, i, antRecFiles{i}), 'Interpreter', 'none')
end
%% %% mostra tutti i frames di uno stesso recording
offsetFig = 10;
warning('off')
cam = 3; % 2 is bottom camera
% length(A)
i = 4;
% cab(1)
for fr = 1:9 % 3 6 9 are rest, piezo-on - 7 is biggest PULL
figure(fr+offsetFig)
imshow(A{i}(cam).frames(:,:,fr));
title(sprintf('frame %d -- rec %d: %s',fr, i, antRecFiles{i}), 'Interpreter', 'none')
end