-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworking_w_Kofi_motion_corrected.m
116 lines (93 loc) · 4.09 KB
/
working_w_Kofi_motion_corrected.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
load('F:\Keck Medicine of USC\Mice_MotionCorrected_Hippocampi_Data.mat')
figure; plot(hippoL_m3_1_0mg)
data=[hippoL_m1_1_0mg, hippoL_m2_1_0mg, hippoL_m3_1_0mg, hippoL_m4_1_0mg, hippoL_m5_1_0mg, hippoL_m7_1_0mg, hippoL_m8_1_0mg, hippoL_m9_1_0mg,...
hippoL_m1_saline, hippoL_m2_saline, hippoL_m3_saline, hippoL_m4_saline, hippoL_m5_saline, hippoL_m7_saline, hippoL_m8_saline, hippoL_m9_saline];
MG1IX=logical([ones(8,1);zeros(8,1)]');
MG0IX=logical([zeros(8,1);ones(8,1)]');
d1=smoothdata(data,1,'movmedian');
std_thresh=2.5*std(d1,1);
baseix=5*60;
for imouse=1:Cols(data)
badix=d1(:,imouse)>mean(d1(:,imouse))+std_thresh(imouse) | d1(:,imouse) < mean(d1(:,imouse))-std_thresh(imouse);
d1(badix,imouse)=nan;
d1(1:20,:)=nan;
d1(3500:end,:)=nan;
base(imouse)=nanmedian(d1(20:baseix,imouse));
bl_norm(:,imouse)=((d1(20:3500,imouse)-base(imouse))./base(imouse)).*100;
end
%bl_norm col 7 is nuts- removing...
bl_norm(:,7)=nan;
%so is 12
bl_norm(:,12)=nan;
figure; plot_confidence_intervals(bl_norm(:,MG0IX)',[],[],[0 0 1]); hold on; plot_confidence_intervals(bl_norm(:,MG1IX)',[],[],[1 0 0]);
ylabel('% Change from BL')
xlabel('Time (s)')
pubify_figure_axis_robust
drugix=5*60+20*60;
changeix=2250;
bar_plot_with_p(nanmedian(bl_norm(drugix:end,:)),MG0IX,MG1IX, 'Av. change from basline, post 20 min injection')
xticklabels({'Saline' 'MK-801'})
ylabel('Median Change from BL 20min post injection')
bar_plot_with_p(nanmedian(bl_norm(changeix:end,:)),MG0IX,MG1IX, 'Av. change from basline')
xticklabels({'Saline' 'MK-801'})
ylabel('Median Change from BL 20min post injection')
%% try the ones that had no iso changes
%mouse 7,8,9 of 1 mg/kg had isochanges
%mouse 7 and 8 of saline had changes
data=[hippoL_m1_1_0mg, hippoL_m2_1_0mg, hippoL_m3_1_0mg, hippoL_m4_1_0mg, hippoL_m5_1_0mg,...
hippoL_m1_saline, hippoL_m2_saline, hippoL_m3_saline, hippoL_m5_saline, hippoL_m9_saline];
MG1IX=logical([ones(5,1);zeros(5,1)]');
MG0IX=logical([zeros(5,1);ones(5,1)]');
% d1=data;
d1=smoothdata(data,1,'movmedian');
% std_thresh=2.5*nanstd(d1,1);
baseix=5*60;
for imouse=1:Cols(data)
% badix=d1(:,imouse)>mean(d1(:,imouse))+std_thresh(imouse) | d1(:,imouse) < mean(d1(:,imouse))-std_thresh(imouse);
% d1(badix,imouse)=nan;
d1(1:20,:)=nan;
d1(3500:end,:)=nan;
base(imouse)=nanmedian(d1(20:baseix,imouse));
bl_norm(:,imouse)=((d1(20:3500,imouse)-base(imouse))./base(imouse)).*100;
end
%bl_norm col 7 is nuts- removing...
% bl_norm(:,7)=nan;
figure; plot_confidence_intervals(bl_norm(:,MG0IX)',[],[],[0 0 1]); hold on; plot_confidence_intervals(bl_norm(:,MG1IX)',[],[],[1 0 0]);
ylabel('% Change from BL')
xlabel('Time (s)')
pubify_figure_axis_robust
drugix=5*60+20*60;
changeix=2250;
bar_plot_with_p(nanmean(bl_norm(end-(60*5):end,:)),MG0IX,MG1IX, 'Av. change from basline')
xticklabels({'Saline' 'MK-801'})
ylabel('Median Change from BL 20min post injection')
%% now trying a low pass filter
%mouse 7,8,9 of 1 mg/kg had isochanges
%mouse 7 and 8 of saline had changes
data=[hippoL_m1_1_0mg, hippoL_m2_1_0mg, hippoL_m3_1_0mg, hippoL_m4_1_0mg, hippoL_m5_1_0mg,...
hippoL_m1_saline, hippoL_m2_saline, hippoL_m3_saline, hippoL_m5_saline, hippoL_m9_saline];
MG1IX=logical([ones(5,1);zeros(5,1)]');
MG0IX=logical([zeros(5,1);ones(5,1)]');
% d1=data;
d1=smoothdata(data,1,'movmedian');
% std_thresh=2.5*nanstd(d1,1);
baseix=5*60;
for imouse=1:Cols(data)
% badix=d1(:,imouse)>mean(d1(:,imouse))+std_thresh(imouse) | d1(:,imouse) < mean(d1(:,imouse))-std_thresh(imouse);
% d1(badix,imouse)=nan;
d1(1:20,:)=nan;
d1(3500:end,:)=nan;
base(imouse)=nanmedian(d1(20:baseix,imouse));
bl_norm(:,imouse)=((d1(20:3500,imouse)-base(imouse))./base(imouse)).*100;
end
%bl_norm col 7 is nuts- removing...
% bl_norm(:,7)=nan;
figure; plot_confidence_intervals(bl_norm(:,MG0IX)',[],[],[0 0 1]); hold on; plot_confidence_intervals(bl_norm(:,MG1IX)',[],[],[1 0 0]);
ylabel('% Change from BL')
xlabel('Time (s)')
pubify_figure_axis_robust
drugix=5*60+20*60;
changeix=2250;
bar_plot_with_p(nanmean(bl_norm(end-(60*5):end,:)),MG0IX,MG1IX, 'Av. change from basline')
xticklabels({'Saline' 'MK-801'})
ylabel('Median Change from BL 20min post injection')