This repository has been archived by the owner on Jul 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
step06_cell_database.m
147 lines (130 loc) · 5.1 KB
/
step06_cell_database.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
clear all
clc
header_script
animal_ID='AH05';
plot_it=0;
save_data=1;
TH=2.5; % for z-scored values=nr of standard deviations from the mean
offset_correction=[0 0];
switch animal_ID
case 'AH02'
calibration_file_name='/Users/benvermaercke/CoxLab/MotionGUI/Calibrations/AH02_20150803.mat';
im_name='/Users/benvermaercke/CoxLab/MotionGUI/Images/2015-08-10_AH02_resaved_im.png';
case 'AH03'
if ispc
calibration_file_name='C:\Users\LBP\Documents\GitHub\MotionGUI\Calibrations\AH03_20150807.mat';
im_name='C:\Users\LBP\Documents\GitHub\MotionGUI\Images\2015-08-10_AH03_im.png';
else
calibration_file_name='/Users/benvermaercke/CoxLab/MotionGUI/Calibrations/AH03_20150807.mat';
im_name='/Users/benvermaercke/CoxLab/MotionGUI/Images/2015-08-10_AH03_im.png';
end
%offset_correction=[-.4 .5];
case 'AH05'
offset_correction_conditional=[-.4 .5];
if ispc
calibration_file_name='C:\Users\LBP\Documents\GitHub\MotionGUI\Calibrations\AH05_20150901.mat';
im_name='C:\Users\LBP\Documents\GitHub\MotionGUI\Images\2015-09-01_AH05_im.png';
else
calibration_file_name='/Users/benvermaercke/CoxLab/MotionGUI/Calibrations/AH05_20150901.mat';
im_name='/Users/benvermaercke/CoxLab/MotionGUI/Images/2015-09-01_AH05_im.png';
end
end
dataset_folder=fullfile(dataset_root,animal_ID);
dataset_files=scandir(dataset_folder,'mat');
nFiles=length(dataset_files);
switch plot_it
case 0
case 1
case 2
%%
resize_factor=.1;
BG=double(imread(im_name))/256;
%BG=imresize(BG,resize_factor);
BG=flipud(BG);
figure(333)
clf
imshow(BG,[])
colormap(green)
hold on
axis equal
axis xy
drawnow
otherwise
end
%%
t0=clock;
for iFile=1:nFiles
load_name=fullfile(dataset_folder,dataset_files(iFile).name);
save_name=fullfile(dataset_folder,'cell_data_files',['cell_data_' dataset_files(iFile).name]);
if exist(load_name,'file')
load(load_name,'dataset')
var=4;
ROI_definitions=dataset.ROI_definitions;
nROIs=length(ROI_definitions);
for iROI=1:nROIs
%%% Create a cell object based on the cell_data class, to hold
%%% all data and perform all subsequent analyses.
cell_data(iROI)=cell_processor(iROI,dataset);
%if load_name
% cell_data(iROI).set_coordinate_frame(calibration_file_name,offset_correction_conditional)
%else
%cell_data(iROI).set_coordinate_frame(calibration_file_name,offset_correction)
%end
cell_data(iROI).set_coordinate_frame(calibration_file_name,offset_correction)
cell_data(iROI).get_cell_location()
cell_data(iROI).get_cell_size()
%%% Build condition matrix
cell_data(iROI).build_condition_matrix(dataset.STIM)
%trace=dataset.RESP(:,iROI);
trace=dataset.SPIKE(:,iROI);
cell_data(iROI).add_trace(trace)
%%% Get RF field maps and do stats
cell_data(iROI).do_RF_analysis()
cell_data(iROI).do_RF_analysis_shuffled()
cell_data(iROI).do_threshold(TH)
%cell_data(iROI).show_RF_map(cell_data(iROI).RF_map_TH)
%%
cell_data(iROI).do_stimSelect_analysis()
cell_data(iROI).get_sparseness()
cell_data(iROI).calc_invariance()
%% special methods
% find full map for most responsive stimulus, or any stim if
% argument is provided
cell_data(iROI).calc_invariance_single_stimulus()
end
%% evaluation
switch plot_it
case 0
case 1
%%
subplot(121)
INV=cat(1,cell_data.invariance_avg);
hist(INV)
%%
subplot(122)
RF_all=cat(3,cell_data.RF_map_TH);
imagesc(mean(RF_all,3))
colormap parula
axis equal
axis tight
axis xy
drawnow
case 2
%%
window_center=cell_data(1).offset*resize_factor;
FOV_center_abs=(window_center+cell_data(1).FOV_info.center*resize_factor) - offset_correction*100;
plot(window_center(1),window_center(2),'wo')
plot(FOV_center_abs(1),FOV_center_abs(2),'ms')
aperture=2.5e3*resize_factor;
set(gca,'Xlim',[window_center(1)-aperture window_center(2)+aperture],'Ylim',[window_center(1)-aperture window_center(2)+aperture])
drawnow
end
%%
if save_data==1 %% overwrite without warning
savec(save_name)
save(save_name,'cell_data')
end
clear cell_data
end
progress(iFile,nFiles,t0)
end