-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpsth_panel.m
124 lines (116 loc) · 5.19 KB
/
psth_panel.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
% GUI window to select parameters for PSTH plot
% Function gets input nwb file object and plot with given parameters
function psth_panel(nwb)
% gui window
f = figure('Position',[100 100 320 550]);
f.Units = 'normalized';
ha.Units = 'normalized';
%%
y_offset = 500;
pad_height = 50;
header = uicontrol('Style', 'text', ...
'String', 'PSTH panel', ...
'Position', [120, y_offset-30, 80, 50], ...
'fontsize', 10);
%%
valid_groups = [];
groups_available = nwb.intervals_trials.vectordata.keys();
for i = 1:length(groups_available)
grp_data = nwb.intervals_trials.vectordata.get(...
groups_available(i)).data.load;
unq_count = unique(grp_data);
if(unq_count <= 5)
valid_groups = [groups_available(i), valid_groups];
end
end
valid_groups = ['no-condition', valid_groups];
%%
groupBymenu = uicontrol('Style', 'text', ...
'String', 'Condition:', ...
'Position', ...
[30, y_offset-2*pad_height, 80, 50]);
groupByTextBox = uicontrol('Style','popupmenu', ...
'Position', ...
[160, y_offset-2*pad_height+30, 120, 30], ...
'String', valid_groups);
%%
unitIdText = uicontrol('Style', 'text', ...
'String', 'Unit Id:', ...
'Position', ...
[30, y_offset - 3*pad_height, 80, 50]);
unitIdTextBox = uicontrol('Style','edit',...
'String','1', ...
'Position', ...
[160, y_offset - 3*pad_height+30, 70, 30]);
%%
nbinsText = uicontrol('Style', 'text', ...
'String', 'Num. bins:', ...
'Position', ...
[30, y_offset - 4*pad_height, 80, 50]);
nbinsTextBox = uicontrol('Style','edit', ...
'Position', ...
[160, y_offset - 4*pad_height+30, 70, 30], ...
'String', 30);
%%
beforeTimeText = uicontrol('Style', 'text', ...
'String', 'Before time:', ...
'Position', ...
[30, y_offset - 5*pad_height, 80, 50]);
beforeTimeTextBox = uicontrol('Style','edit', ...
'Position', ...
[160, y_offset - 5*pad_height+30, 70, 30], ...
'String', -0.5);
%%
afterTimeText = uicontrol('Style', 'text', ...
'String', 'After time:', ...
'Position', ...
[30, y_offset - 6*pad_height, 80, 50]);
afterTimeTextBox = uicontrol('Style','edit', ...
'Position', ...
[160, y_offset - 6*pad_height+30, 70, 30], ...
'String', 1.0);
%%
plotOptions = {'histogram', 'gaussian'};
plotOptionmenu = uicontrol('Style', 'text', ...
'String', 'PSTH plot type:', ...
'Position', ...
[30, y_offset - 7*pad_height, 80, 50]);
plotOptionTextBox = uicontrol('Style','popupmenu', ...
'Position', ...
[160, y_offset - 7*pad_height+25, 120, 30], ...
'String', plotOptions);
%%
stdText = uicontrol('Style', 'text', ...
'String', 'Standard dev.:', ...
'Position', [30, y_offset - 8*pad_height, 80, 50]);
stdTextBox = uicontrol('Style','edit', ...
'Position', ...
[160, y_offset - 8*pad_height+30, 70, 30], ...
'String', 0.05);
%%
plot_button = uicontrol('Style','pushbutton',...
'String','Plot', ...
'Position',[100,20,100,30],...
'Callback',@plotbutton_Callback);
f.Name = 'PSTH panel';
movegui(f,'center');
%% callback function to plot
function plotbutton_Callback(source, eventdata)
input_unit_id = str2num(get(unitIdTextBox, 'string'));
val = groupByTextBox.Value;
str = groupByTextBox.String;
input_group_by = str{val};
input_before_time = str2num(get(beforeTimeTextBox, 'string'));
input_after_time = str2num(get(afterTimeTextBox, 'string'));
input_n_bins = str2num(get(nbinsTextBox, 'string'));
val = plotOptionTextBox.Value;
str = plotOptionTextBox.String;
input_plot_option = str{val};
input_std = str2num(get(stdTextBox, 'string'));
psth(nwb, unit_id = input_unit_id, ...
group_by = input_group_by, ...
before_time = input_before_time, ...
after_time = input_after_time, n_bins = input_n_bins, ...
psth_plot_option = input_plot_option, std = input_std);
end
end