ET_PDToolkit/PDToolkit/@PDExperiment/plot.m

155 lines
5.1 KiB
Matlab

function[e] = plot(e)
plotwindow = figure;
set(plotwindow, 'Color', [1 1 1]);
e.handle = plotwindow;
options.raw = 0;
options.logtransformed = 0;
options.interpolated = 0;
options.filtered = 0;
options.blinks = 0;
options.markers = 0;
options.labels = 0;
options.baseline = 0;
options.baseline_corrected = 0;
options.deconvolution = 0;
options.drawing = options;
options.drawing.raw = {'-', [1 0 0], 3};
options.drawing.logtransformed = {'-', [0 0 1], 3};
options.drawing.interpolated = {'-', [0.5 0 0], 3};
options.drawing.filtered= {'--', [0 0.5 0], 3};
options.drawing.markers = {'--', [0.5 0 0], 3};
options.drawing.baseline= {'--', [0 0 1], 3};
options.drawing.baseline_corrected= {'--', [0 0 0], 3};
set(plotwindow, 'UserData', options);
subj_pop = uicontrol('Style','popupmenu');
sess_pop = uicontrol('Style','popupmenu');
subj_pop_string = ''; subj_pop_vals =[];
sess_pop_string = ''; sess_pop_vals =[];
for s = 1:length(e.subjects)
if s > 1
subj_pop_string = [subj_pop_string '|' e.subjects(s).name];
else
subj_pop_string = [e.subjects(s).name];
end
subj_pop_vals = [subj_pop_vals s];
end
set(subj_pop, 'Position', [20 20 150 20]);
set(subj_pop, 'String', subj_pop_string);
set(subj_pop, 'Value', 1);
set(subj_pop, 'Callback', 'e.set_plot_subject');
set(subj_pop, 'FontName', 'Verdana');
set(subj_pop, 'FontWeight', 'bold');
set(subj_pop, 'FontSize', 11);
sel=get(subj_pop, 'Value');
for s = 1:length(e.subjects(sel).sessions);
if s > 1
sess_pop_string = [sess_pop_string '|' e.subjects(sel).sessions(s).name];
else
sess_pop_string = [e.subjects(sel).sessions(s).name];
end
sess_pop_vals = [sess_pop_vals s];
end
set(sess_pop, 'Position', [175 20 150 20]);
set(sess_pop, 'String', sess_pop_string);
set(sess_pop, 'Value', 1);
set(sess_pop, 'Callback', 'e.set_plot_sess');
set(sess_pop, 'FontName', 'Verdana');
set(sess_pop, 'FontWeight', 'bold');
set(sess_pop, 'FontSize', 11);
selsess = get(sess_pop, 'Value');
trial_slider = uicontrol('Style','slider');
trial_edit = uicontrol('Style','edit');
set(trial_slider, 'Position', [335 20 150 20]);
set(trial_slider, 'Min', 1);
set(trial_slider, 'Max', length(e.subjects(sel).sessions(selsess).trials));
set(trial_slider, 'Value', 1);
set(trial_slider, 'Callback', 'e.set_plot_trial_slider');
set(trial_slider, 'SliderStep',[1/length(e.subjects(sel).sessions(selsess).trials) 5/length(e.subjects(sel).sessions(selsess).trials)]);
set(trial_edit, 'Position', [ 495 20 60 20]);
set(trial_edit, 'String', 1);
set(trial_edit, 'Callback', 'e.set_plot_trial_edit');
set(trial_edit, 'FontName', 'Verdana');
set(trial_edit, 'FontWeight', 'bold');
set(trial_edit, 'FontSize', 11);
options_toggle = uicontrol('Style', 'toggle')
set(options_toggle, 'Position', [480 390 70 30]);
set(options_toggle, 'String', 'Options');
set(options_toggle', 'Callback', 'e.togglePlotOptions');
bl_type = e.bl_types{e.settings.BaselineCorrection};
jList = java.util.ArrayList;
i=0;
jList.add(i,'<html><font name="Verdana" size=1><b>Raw trial</b></font></html>'); i = i+1;
jList.add(i,'<html><font name="Verdana" size=1><b>Logtransformed trial</b></font></html>'); i = i+1;
jList.add(i,'<html><font name="Verdana" size=1><b>Interpolated trial</b></font></html>'); i = i+1;
jList.add(i,'<html><font name="Verdana" size=1><b>Filtered trial</b></font></html>');i = i+1;
jList.add(i,'<html><font name="Verdana" size=1><b>Blinks</b></font></html>'); i = i+1;
jList.add(i,'<html><font name="Verdana" size=1><b>Markers</b></font></html>'); i = i+1;
jList.add(i,'<html><font name="Verdana" size=1><b>Labels</b></font></html>'); i = i+1;
jList.add(i,['<html><font name="Verdana" size=1><b>Baseline (' bl_type ')</b></font></html>']); i = i+1;
jList.add(i,'<html><font name="Verdana" size=1><b>Baseline corrected</b></font></html>'); i = i+1;
jList.add(i,'<html><font name="Verdana" size=1><b>Deconvolved modelfit</b></font></html>'); i = i+1;
jCBList = com.mathworks.mwswing.checkboxlist.CheckBoxList(jList);
jScrollPane = com.mathworks.mwswing.MJScrollPane(jCBList);
posfig = get(gcf, 'Position');
%center = [((posfig(3) /2) - 75) ((posfig(4) /2) - 100)];
[jhCBList,hContainer] = javacomponent(jScrollPane,[400 270 150,110],gcf);
set(jCBList, 'ValueChangedCallback', @e.setPlotOptions);
jCBModel = jCBList.getCheckModel;
jCBModel.uncheckAll;
jCBModel.checkIndex(1);
%% set Tags
plotwindow_id = get_plotwindow_id(gcf);
set(subj_pop, 'Tag', ['subj_pop.' plotwindow_id]);
set(sess_pop, 'Tag', ['sess_pop.' plotwindow_id]);
set(trial_edit, 'Tag', ['trial_edit.' plotwindow_id]);
set(trial_slider, 'Tag', ['trial_slider.' plotwindow_id]);
set(options_toggle, 'Tag', ['options_toggle.' plotwindow_id]);
plot(e.subjects(1).sessions(1).trials(1));
pos = get(gca, 'Position');
set(gca, 'Position', [.1 .2 .8 .7]);
set(gca, 'FontName', 'Verdana');
set(gca, 'FontWeight', 'bold');
set(gca, 'FontSize', 10);
set(gca, 'Box', 'on');
%trial_slider = uicontrol('Style', 'slider')
%fig_pos = get(gcf,'Position');
%set(h, 'Position', [20 20 (fig_pos(3) - 20) 20]);
%set(h, 'Min', 1); set(h, 'Max',
set(gca,'ButtonDownFcn',@e.onClickPlotAxes);
dcm = datacursormode(gcf);
set(dcm, 'UpdateFcn', @e.onDataPointClick);
datacursormode on;