Contents
INITIALIZE GUI
back to top
function varargout = EditEvents(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @EditEvents_OpeningFcn, ...
'gui_OutputFcn', @EditEvents_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function EditEvents_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
evalin('base','clear all; clc')
evalin('base','mydirChoose = pwd;');
cla(handles.axes1,'reset');
set(handles.axes1,'visible','off')
axis off;
cla(handles.axes2,'reset');
set(handles.axes2,'visible','off')
axis off;
cla(handles.axes3,'reset');
set(handles.axes3,'visible','off')
axis off;
rawDataPaths
function varargout = EditEvents_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
SLIDER SELECTION
back to top
function slider1_Callback(hObject, eventdata, handles)
slider1pos = round(get(handles.slider1,'Value'));
k = slider1pos;
iptPointerManager(handles.figure1);
set(handles.figure1,'Pointer','watch');
pause(0.2);
y2 = evalin('base','y2');
myEvents = evalin('base','myEvents');
myEventsFlag = evalin('base','myEventsFlag');
si = evalin('base','si');
Eventplot = y2(myEvents(k,1):myEvents(k,3));
mintemp = min(Eventplot);
Eventplot = Eventplot - mintemp;
assignin('base','Eventplot',Eventplot);
if myEventsFlag(k) == 1
xRD = (1:length(Eventplot))*si;
plot(handles.axes1,xRD,Eventplot,'r.')
set(handles.figure1,'Pointer','arrow');
iptPointerManager(handles.figure1, 'disable')
set(handles.axes1,'visible','off')
axis off;
cla(handles.axes2,'reset');
set(handles.axes2,'visible','off')
axis off;
cla(handles.axes3,'reset');
set(handles.axes3,'visible','off')
axis off;
set(handles.text1,'String',['Event ',num2str(NaN)])
else
[yRis yDec yRes siNew] = myResample_simple_extend(y2,myEvents(k,1),myEvents(k,3),si,(si/0.0001));
mintemp = min(yRis);
yRis = yRis - mintemp;
mintemp = min(yDec);
yDec = yDec - mintemp;
xR = (1:length(yRis))*siNew;
xD = (1:length(yDec))*siNew;
xRD = (1:length(Eventplot))*si;
handles.axes1_plot1 = plot(handles.axes1,xRD,Eventplot,'k.');
handles.axes2_plot1 = plot(handles.axes2,xR,yRis,'k.');
handles.axes3_plot1 = plot(handles.axes3,xD,yDec,'k.');
cgE = ~myEventsFlag(1:k);
cbE = length(cgE); cgE = sum(cgE);
set(handles.text1,'String',['Event (Good/Total): ',num2str(cgE), ' / ', num2str(cbE)])
set(handles.figure1,'Pointer','arrow');
axes1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1,'ButtonDownFcn',axes1_buttonDownFcn_String);
axes1_plot1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_plot1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1_plot1,'ButtonDownFcn',axes1_plot1_buttonDownFcn_String);
iptSetPointerBehavior(handles.axes1, @axes1_pointer_Fcn)
iptSetPointerBehavior(handles.axes1_plot1, @axes1_plot1_pointer_Fcn)
end
OPEN FOLDER
back to top
function pushbutton1_Callback(hObject, eventdata, handles)
mydircheck = evalin('base','exist(''mydirChoose'',''var'');');
if mydircheck == 0
mydirChoose = pwd;
else
mydirChoose = evalin('base','mydirChoose');
end
mydirChoose = uigetdir(mydirChoose);
if mydirChoose == 0
msgbox('Select a folder')
return;
end
assignin('base','mydirChoose',mydirChoose);
parsemypath = strfind(mydirChoose,'\');
myfolder = mydirChoose(parsemypath(end)+1:end);
set(handles.text2,'string',myfolder);
set(handles.pushbutton2,'Enable','on');
cla(handles.axes1,'reset');
set(handles.axes1,'visible','off')
axis off;
cla(handles.axes2,'reset');
set(handles.axes2,'visible','off')
axis off;
cla(handles.axes3,'reset');
set(handles.axes3,'visible','off')
axis off;
OPEN FILE
back to top
function pushbutton2_Callback(hObject, eventdata, handles)
mypwd = evalin('base','pwd');
mydirChoose = evalin('base','mydirChoose');
Eventsfile = uigetfile({'*autoEventStats.mat', 'autoEventStats Files (*autoEventStats.mat)'},...
'Select Electrophys AutoEventDataStats File', [mydirChoose,'/']);
if isempty(strfind(Eventsfile,'autoEventStats.mat'))
if Eventsfile == 0
msgbox('Select autoEventStats.mat file')
end
return;
end
cla(handles.axes1,'reset')
set(handles.axes1,'Visible','off')
iptPointerManager(handles.figure1);
set(handles.figure1,'Pointer','watch');
axes1_h_obj = handle(handles.axes1);
moveptr(axes1_h_obj,'init')
moveptr(axes1_h_obj,'move',0.4,0.6)
axes(handles.axes1);
h_text = text(0.5,0.5,' Busy ','FontSize',14,'HorizontalAlignment','center',...
'BackgroundColor',[.8 .3 .05]);
pause(.2)
assignin('base','Eventsfile',Eventsfile);
cellnameidx = strfind(Eventsfile,'_autoEventStats.mat');
cellname = Eventsfile(1:cellnameidx(end)-1);
abfFile = [cellname,'.abf'];
copyfile([mydirChoose,'\',Eventsfile],Eventsfile)
evalin('base','load([pwd, ''\'', Eventsfile])');
delete([mypwd, '\', Eventsfile])
fileCorrupt = evalin('base','exist(''fileCorrupt'',''var'')');
if fileCorrupt == 1
msgbox('File Corrupt, no events')
evalin('base','clear fileCorrupt');
set(h_text,'string','Complete','BackgroundColor',[.7 .9 .7])
set(handles.figure1,'Pointer','arrow');
return;
end
evalin('base','myEvents_copy = myEvents;');
evalin('base','myEventsFlag_copy = myEventsFlag;');
set(handles.text3,'string',cellname);
[mycell si] = abfload(abfFile);
si = si/1e6;
mycell = myFilter(mycell);
limitsCrop = evalin('base','limitsCrop');
if isempty(limitsCrop)
y1 = mycell;
else
y1 = mycell(limitsCrop(1):limitsCrop(2));
end
y2 = y1;
assignin('base','y2',y2);
myEvents = evalin('base','myEvents');
myEventsFlag = evalin('base','myEventsFlag');
Eventplot = y2(myEvents(1,1):myEvents(1,3));
mintemp = min(Eventplot);
Eventplot = Eventplot - mintemp;
xRD = (1:length(Eventplot))*si;
if myEventsFlag(1) == 1
set(h_text,'string','Complete','BackgroundColor',[.7 .9 .7])
set(handles.figure1,'Pointer','arrow');
plot(handles.axes1,xRD,Eventplot,'r.')
iptPointerManager(handles.figure1, 'disable')
set(handles.axes1,'visible','off')
axis off;
cla(handles.axes2,'reset');
set(handles.axes2,'visible','off')
axis off;
cla(handles.axes3,'reset');
set(handles.axes3,'visible','off')
axis off;
set(handles.text1,'String',['Event ',num2str(NaN)])
else
[yRis yDec yRes siNew] = myResample_simple_extend(y2,myEvents(1,1),myEvents(1,3),si,(si/0.0001));
mintemp = min(yRis);
yRis = yRis - mintemp;
mintemp = min(yDec);
yDec = yDec - mintemp;
set(h_text,'string','Complete','BackgroundColor',[.7 .9 .7])
set(handles.figure1,'Pointer','arrow');
xR = (1:length(yRis))*siNew;
xD = (1:length(yDec))*siNew;
xRD = (1:length(Eventplot))*si;
handles.axes1_plot1 = plot(handles.axes1,xRD,Eventplot,'k.');
handles.axes2_plot1 = plot(handles.axes2,xR,yRis,'k.');
handles.axes3_plot1 = plot(handles.axes3,xD,yDec,'k.');
axes1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1,'ButtonDownFcn',axes1_buttonDownFcn_String);
axes1_plot1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_plot1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1_plot1,'ButtonDownFcn',axes1_plot1_buttonDownFcn_String);
iptPointerManager(handles.figure1);
axes1_pointer_Fcn_String = @(hObject,eventdata)EditEvents('axes1_pointer_Fcn',hObject,eventdata,guidata(hObject));
iptSetPointerBehavior(handles.axes1, axes1_pointer_Fcn_String)
axes1_plot1_pointer_Fcn_String = @(hObject,eventdata)EditEvents('axes1_plot1_pointer_Fcn',hObject,eventdata,guidata(hObject));
iptSetPointerBehavior(handles.axes1_plot1, axes1_plot1_pointer_Fcn_String)
cgE = ~myEventsFlag(1);
cbE = length(cgE); cgE = sum(cgE);
set(handles.text1,'String',['Event (Good/Total): ',num2str(cgE), ' / ', num2str(cbE)])
end
mymax = size(myEvents,1); mymin = 1;
mystep = [1, 0.2*(mymax-mymin)]*1/(mymax-mymin);
set(handles.slider1,'Min',mymin);
set(handles.slider1,'Max',(mymax));
set(handles.slider1,'SliderStep', mystep);
set(handles.slider1,'Value',1);
set(handles.slider1,'interruptible','off');
set(handles.slider1,'Enable','on')
SAVE
back to top
function pushbutton3_Callback(hObject, eventdata, handles)
q_save = questdlg('Verify Save ', ...
'Saving', ...
'Yes' ,'No' ,'Cancel' ,'Yes');
if strcmp(q_save,'Yes')
mydirChoose = evalin('base','mydirChoose');
Eventsfile = evalin('base','Eventsfile');
evalin('base',...
'save(Eventsfile,''EventDataStats'', ''limitsCrop'', ''myEvents'',''myEventsFlag'', ''peakSet'', ''peakThreshold'', ''si'');');
movefile(Eventsfile,mydirChoose);
msgbox('File Saved','EventStats','help');
else return
end
FLAG
back to top
function pushbutton4_Callback(hObject, eventdata, handles)
myEventsFlag = evalin('base','myEventsFlag');
slider1pos = round(get(handles.slider1,'Value'));
k = slider1pos;
myEventsFlag(k) = 1;
assignin('base','myEventsFlag',myEventsFlag);
y2 = evalin('base','y2');
myEvents = evalin('base','myEvents');
si = evalin('base','si');
Eventplot = y2(myEvents(k,1):myEvents(k,3));
xRD = (1:length(Eventplot))*si;
if myEventsFlag(k) == 1
plot(handles.axes1,xRD,Eventplot,'r.')
iptPointerManager(handles.figure1, 'disable')
set(handles.axes1,'visible','off')
axis off;
cla(handles.axes2,'reset');
set(handles.axes2,'visible','off')
axis off;
cla(handles.axes3,'reset');
set(handles.axes3,'visible','off')
axis off;
set(handles.text1,'String',['Event ',num2str(NaN)])
end
UNFLAG
back to top
function pushbutton5_Callback(hObject, eventdata, handles)
myEventsFlag = evalin('base','myEventsFlag');
slider1pos = round(get(handles.slider1,'Value'));
k = slider1pos;
myEventsFlag(k) = 0;
assignin('base','myEventsFlag',myEventsFlag);
y2 = evalin('base','y2');
myEvents = evalin('base','myEvents');
si = evalin('base','si');
[yRis yDec yRes siNew] = myResample_simple_extend(y2,myEvents(k,1),myEvents(k,3),si,(si/0.0001));
Eventplot = y2(myEvents(k,1):myEvents(k,3));
mintemp = min(Eventplot);
Eventplot = Eventplot - mintemp;
mintemp = min(yRis);
yRis = yRis - mintemp;
mintemp = min(yDec);
yDec = yDec - mintemp;
xR = (1:length(yRis))*siNew;
xD = (1:length(yDec))*siNew;
xRD = (1:length(Eventplot))*si;
handles.axes1_plot1 = plot(handles.axes1,xRD,Eventplot,'k.');
handles.axes2_plot1 = plot(handles.axes2,xR,yRis,'k.');
handles.axes3_plot1 = plot(handles.axes3,xD,yDec,'k.');
axes1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1,'ButtonDownFcn',axes1_buttonDownFcn_String);
axes1_plot1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_plot1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1_plot1,'ButtonDownFcn',axes1_plot1_buttonDownFcn_String);
iptPointerManager(handles.figure1);
axes1_pointer_Fcn_String = @(hObject,eventdata)EditEvents('axes1_pointer_Fcn',hObject,eventdata,guidata(hObject));
iptSetPointerBehavior(handles.axes1, axes1_pointer_Fcn_String)
axes1_plot1_pointer_Fcn_String = @(hObject,eventdata)EditEvents('axes1_plot1_pointer_Fcn',hObject,eventdata,guidata(hObject));
iptSetPointerBehavior(handles.axes1_plot1, axes1_plot1_pointer_Fcn_String)
cgE = ~myEventsFlag(1:k);
cbE = length(cgE); cgE = sum(cgE);
set(handles.text1,'String',['Event (Good/Total): ',num2str(cgE), ' / ', num2str(cbE)])
HOVER OVER AXES
back to top
function axes1_pointer_Fcn(hObject, eventdata, handles)
set(hObject,'Pointer','fullcross');
HOVER OVER OBJECT1 IN AXES
back to top
function axes1_plot1_pointer_Fcn(hObject, eventdata, handles)
set(hObject,'Pointer','fullcrosshair');
CLICK ON OBJECT IN AXES
back to top
function axes1_plot1_ButtonDownFcn(hObject, eventdata, handles)
axes_Units = get(get(hObject,'Parent'),'Units');
set(get(hObject,'Parent'),'Units','Pixels')
axes_pos = get(get(hObject,'Parent'),'Position');
set(get(hObject,'Parent'),'Units',axes_Units);
Fig1_Units = get(handles.figure1,'Units');
set(handles.figure1,'Units','Pixels')
Fig1_cp = get(handles.figure1,'CurrentPoint');
set(handles.figure1,'Units',Fig1_Units);
axes_xL = get(get(hObject,'Parent'),'XLim');
axes_yL = get(get(hObject,'Parent'),'YLim');
plot1_xD = get(hObject,'XData');
cp_pos_temp = ( (Fig1_cp(1) - axes_pos(1) +1) * (axes_xL(2)/axes_pos(3)) );
[~,cp_pos] = min( (plot1_xD - cp_pos_temp).^2 );
cp_pos = cp_pos(1);
npt_x = plot1_xD(cp_pos);
hold all;
axes(get(hObject,'Parent'))
line('XData',[npt_x npt_x],'YData',axes_yL,'Color','r');
hold off;
pause(0.2)
myEvents = evalin('base','myEvents');
slider1pos = round(get(handles.slider1,'Value'));
k = slider1pos;
if cp_pos < myEvents(k,2)-myEvents(k,1)+1
myEvents(k,1) = myEvents(k,1) + cp_pos - 1;
else
myEvents(k,3) = myEvents(k,1) + cp_pos - 1;
end
assignin('base','myEvents',myEvents);
y2 = evalin('base','y2');
myEvents = evalin('base','myEvents');
myEventsFlag = evalin('base','myEventsFlag');
si = evalin('base','si');
[yRis yDec yRes siNew] = myResample_simple_extend(y2,myEvents(k,1),myEvents(k,3),si,(si/0.0001));
Eventplot = y2(myEvents(k,1):myEvents(k,3));
mintemp = min(Eventplot);
Eventplot = Eventplot - mintemp;
mintemp = min(yRis);
yRis = yRis - mintemp;
mintemp = min(yDec);
yDec = yDec - mintemp;
xR = (1:length(yRis))*siNew;
xD = (1:length(yDec))*siNew;
xRD = (1:length(Eventplot))*si;
handles.axes1_plot1 = plot(handles.axes1,xRD,Eventplot,'k.');
handles.axes2_plot1 = plot(handles.axes2,xR,yRis,'k.');
handles.axes3_plot1 = plot(handles.axes3,xD,yDec,'k.');
axes1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1,'ButtonDownFcn',axes1_buttonDownFcn_String);
axes1_plot1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_plot1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1_plot1,'ButtonDownFcn',axes1_plot1_buttonDownFcn_String);
iptPointerManager(handles.figure1);
axes1_pointer_Fcn_String = @(hObject,eventdata)EditEvents('axes1_pointer_Fcn',hObject,eventdata,guidata(hObject));
iptSetPointerBehavior(handles.axes1, axes1_pointer_Fcn_String)
axes1_plot1_pointer_Fcn_String = @(hObject,eventdata)EditEvents('axes1_plot1_pointer_Fcn',hObject,eventdata,guidata(hObject));
iptSetPointerBehavior(handles.axes1_plot1, axes1_plot1_pointer_Fcn_String)
cgE = ~myEventsFlag(1:k);
cbE = length(cgE); cgE = sum(cgE);
set(handles.text1,'String',['Event (Good/Total): ',num2str(cgE), ' / ', num2str(cbE)])
CLICK IN AXES
back to top
function axes1_ButtonDownFcn(hObject, eventdata, handles)
axes_Units = get(hObject,'Units');
set(hObject,'Units','Pixels')
axes_pos = get(hObject,'Position');
set(hObject,'Units',axes_Units);
Fig1_Units = get(handles.figure1,'Units');
set(handles.figure1,'Units','Pixels')
Fig1_cp = get(handles.figure1,'CurrentPoint');
set(handles.figure1,'Units',Fig1_Units);
axes_xL = get(hObject,'Xlim');
axes_yL = get(hObject,'YLim');
axes_Children = get(hObject,'Children');
plot1_xD = get(axes_Children(end),'Xdata');
cp_pos_temp = ( (Fig1_cp(1) - axes_pos(1) +1) * (axes_xL(2)/axes_pos(3)) );
[~,cp_pos] = min( (plot1_xD - cp_pos_temp).^2 );
cp_pos = cp_pos(1);
npt_x = plot1_xD(cp_pos);
hold all;
axes(hObject)
line('XData',[npt_x npt_x],'YData',axes_yL,'Color','r');
hold off;
pause(0.2)
myEvents = evalin('base','myEvents');
slider1pos = round(get(handles.slider1,'Value'));
k = slider1pos;
if cp_pos < myEvents(k,2)-myEvents(k,1)+1
myEvents(k,1) = myEvents(k,1) + cp_pos - 1;
else
myEvents(k,3) = myEvents(k,1) + cp_pos - 1;
end
assignin('base','myEvents',myEvents);
y2 = evalin('base','y2');
myEvents = evalin('base','myEvents');
myEventsFlag = evalin('base','myEventsFlag');
si = evalin('base','si');
[yRis yDec yRes siNew] = myResample_simple_extend(y2,myEvents(k,1),myEvents(k,3),si,(si/0.0001));
Eventplot = y2(myEvents(k,1):myEvents(k,3));
mintemp = min(Eventplot);
Eventplot = Eventplot - mintemp;
mintemp = min(yRis);
yRis = yRis - mintemp;
mintemp = min(yDec);
yDec = yDec - mintemp;
xR = (1:length(yRis))*siNew;
xD = (1:length(yDec))*siNew;
xRD = (1:length(Eventplot))*si;
handles.axes1_plot1 = plot(handles.axes1,xRD,Eventplot,'k.');
handles.axes2_plot1 = plot(handles.axes2,xR,yRis,'k.');
handles.axes3_plot1 = plot(handles.axes3,xD,yDec,'k.');
axes1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1,'ButtonDownFcn',axes1_buttonDownFcn_String);
axes1_plot1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_plot1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1_plot1,'ButtonDownFcn',axes1_plot1_buttonDownFcn_String);
iptPointerManager(handles.figure1);
iptSetPointerBehavior(handles.axes1, @axes1_pointer_Fcn)
iptSetPointerBehavior(handles.axes1_plot1, @axes1_plot1_pointer_Fcn)
cgE = ~myEventsFlag(1:k);
cbE = length(cgE); cgE = sum(cgE);
set(handles.text1,'String',['Event (Good/Total): ',num2str(cgE), ' / ', num2str(cbE)])
FIT CURVES
back to top
function pushbutton6_Callback(hObject, eventdata, handles)
slider1pos = round(get(handles.slider1,'Value'));
y2 = evalin('base','y2');
myEvents = evalin('base','myEvents');
myEventsFlag = evalin('base','myEventsFlag');
k = slider1pos;
si = evalin('base','si');
if myEventsFlag(k) == 1
return;
else
iptPointerManager(handles.figure1);
set(handles.figure1,'Pointer','watch');
pause(0.1);
Eventplot = y2(myEvents(k,1):myEvents(k,3));
mintemp = min(Eventplot);
Eventplot = Eventplot - mintemp;
[yRis yDec yRes siNew] = myResample_simple_extend(y2,myEvents(k,1),myEvents(k,3),si,(si/0.0001));
mintemp = min(yRis);
yRis = yRis - mintemp;
mintemp = min(yDec);
yDec = yDec - mintemp;
xR = (1:length(yRis))*siNew;
xD = (1:length(yDec))*siNew;
xRD = (1:length(Eventplot))*si;
[yR_fit_obj yR_stat] = myfity2(yRis,'n',siNew,'');
[yD_fit_obj yD_stat] = myfity1(yDec,'n',siNew,'');
yR_alpha = yR_fit_obj.alpha;
yR_beta = yR_fit_obj.beta;
yD_alpha = yD_fit_obj.alpha;
yD_beta = yD_fit_obj.beta;
yR_fit = yR_alpha*(1-exp(-yR_beta*(xR)));
yD_fit = yD_alpha*(exp(-yD_beta*(xD)));
handles.axes1_plot1 = plot(handles.axes1,xRD,Eventplot,'k.');
handles.axes2_plot1 = plot(handles.axes2,xR,yRis,'k.');
handles.axes3_plot1 = plot(handles.axes3,xD,yDec,'k.');
hold(handles.axes2,'on');
plot(handles.axes2,xR,yR_fit,'b','LineWidth',3); hold(handles.axes2,'off');
hold(handles.axes3,'on');
plot(handles.axes3,xD,yD_fit,'b','LineWidth',3); hold(handles.axes3,'off');
axes1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1,'ButtonDownFcn',axes1_buttonDownFcn_String);
axes1_plot1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_plot1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1_plot1,'ButtonDownFcn',axes1_plot1_buttonDownFcn_String);
iptSetPointerBehavior(handles.axes1, @axes1_pointer_Fcn)
iptSetPointerBehavior(handles.axes1_plot1, @axes1_plot1_pointer_Fcn)
axes_Units = get(handles.axes1,'Units');
set(handles.axes1,'Units','Pixels')
axes_pos = get(handles.axes1,'Position');
set(handles.axes1,'Units',axes_Units);
Fig1_Units = get(handles.figure1,'Units');
set(handles.figure1,'Units','Pixels')
Fig1_pos = get(handles.figure1,'Position');
set(handles.figure1,'Units',Fig1_Units);
cp = get(0,'PointerLocation');
cp = cp-Fig1_pos(1:2)+1;
if axes_pos(1) <= cp(1) && cp(1) <= axes_pos(1) + axes_pos(3) && ...
axes_pos(2) <= cp(2) && cp(2) <= axes_pos(2) + axes_pos(4)
set(handles.figure1,'Pointer','fullcrosshair');
else
set(handles.figure1,'Pointer','arrow');
end
end
KEYBOARD INPUT
back to top
function figure1_WindowKeyReleaseFcn(hObject, eventdata, handles)
rk = eventdata.Key;
rm = eventdata.Modifier;
data = guidata(hObject);
switch rk
case 'q'
hgfeval({@pushbutton1_Callback,[],[],data});
case 'e'
hgfeval({@pushbutton2_Callback,[],[],data});
case 'c'
hgfeval({@pushbutton6_Callback,[],[],data});
case 'f'
hgfeval({@pushbutton4_Callback,[],[],data});
case 'g'
hgfeval({@pushbutton5_Callback,[],[],data});
case 'a'
s_min = round(get(handles.slider1,'Min'));
s_cp = round(get(handles.slider1,'Value'));
if s_cp > s_min
set(handles.slider1,'Value',s_cp-1)
hgfeval({@slider1_Callback,[],[],data});
end
case 'd'
s_max = round(get(handles.slider1,'Max'));
s_cp = round(get(handles.slider1,'Value'));
if s_cp < s_max
set(handles.slider1,'Value',s_cp+1)
hgfeval({@slider1_Callback,[],[],data});
end
case 's'
if strcmp(rm,'shift')
hgfeval({@pushbutton3_Callback,[],[],data});
end
case 'r'
if strcmp(rm,'shift')
hgfeval({@pushbutton7_Callback,[],[],data});
end
otherwise; return
end
RESET
back to top
function pushbutton7_Callback(hObject, eventdata, handles)
iptPointerManager(handles.figure1);
set(handles.figure1,'Pointer','watch');
pause(0.1);
slider1pos = round(get(handles.slider1,'Value'));
k = slider1pos;
myEvents = evalin('base','myEvents');
myEvents_copy = evalin('base','myEvents_copy');
myEvents(k,:) = myEvents_copy(k,:);
assignin('base','myEvents',myEvents);
myEventsFlag = evalin('base','myEventsFlag');
y2 = evalin('base','y2');
si = evalin('base','si');
[yRis yDec yRes siNew] = myResample_simple_extend(y2,myEvents(k,1),myEvents(k,3),si,(si/0.0001));
Eventplot = y2(myEvents(k,1):myEvents(k,3));
mintemp = min(Eventplot);
Eventplot = Eventplot - mintemp;
mintemp = min(yRis);
yRis = yRis - mintemp;
mintemp = min(yDec);
yDec = yDec - mintemp;
xR = (1:length(yRis))*siNew;
xD = (1:length(yDec))*siNew;
xRD = (1:length(Eventplot))*si;
handles.axes1_plot1 = plot(handles.axes1,xRD,Eventplot,'k.');
handles.axes2_plot1 = plot(handles.axes2,xR,yRis,'k.');
handles.axes3_plot1 = plot(handles.axes3,xD,yDec,'k.');
axes1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1,'ButtonDownFcn',axes1_buttonDownFcn_String);
axes1_plot1_buttonDownFcn_String = @(hObject,eventdata)EditEvents('axes1_plot1_ButtonDownFcn',hObject,eventdata,guidata(hObject));
set(handles.axes1_plot1,'ButtonDownFcn',axes1_plot1_buttonDownFcn_String);
iptPointerManager(handles.figure1);
axes1_pointer_Fcn_String = @(hObject,eventdata)EditEvents('axes1_pointer_Fcn',hObject,eventdata,guidata(hObject));
iptSetPointerBehavior(handles.axes1, axes1_pointer_Fcn_String)
axes1_plot1_pointer_Fcn_String = @(hObject,eventdata)EditEvents('axes1_plot1_pointer_Fcn',hObject,eventdata,guidata(hObject));
iptSetPointerBehavior(handles.axes1_plot1, axes1_plot1_pointer_Fcn_String)
axes_Units = get(handles.axes1,'Units');
set(handles.axes1,'Units','Pixels')
axes_pos = get(handles.axes1,'Position');
set(handles.axes1,'Units',axes_Units);
Fig1_Units = get(handles.figure1,'Units');
set(handles.figure1,'Units','Pixels')
Fig1_pos = get(handles.figure1,'Position');
set(handles.figure1,'Units',Fig1_Units);
cp = get(0,'PointerLocation');
cp = cp-Fig1_pos(1:2)+1;
if axes_pos(1) <= cp(1) && cp(1) <= axes_pos(1) + axes_pos(3) && ...
axes_pos(2) <= cp(2) && cp(2) <= axes_pos(2) + axes_pos(4)
set(handles.figure1,'Pointer','fullcrosshair');
else
set(handles.figure1,'Pointer','arrow');
end
function slider1_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
MAKE PLOT
back to top
function makePlot_ClickedCallback(hObject, eventdata, handles)
slider1pos = round(get(handles.slider1,'Value'));
y2 = evalin('base','y2');
myEvents = evalin('base','myEvents');
myEventsFlag = evalin('base','myEventsFlag');
k = slider1pos;
si = evalin('base','si');
if myEventsFlag(k) == 1
return;
else
Eventplot = y2(myEvents(k,1):myEvents(k,3));
mintemp = min(Eventplot);
Eventplot = Eventplot - mintemp;
[yRis yDec yRes siNew] = myResample_simple_extend(y2,myEvents(k,1),myEvents(k,3),si,(si/0.0001));
mintemp = min(yRis);
yRis = yRis - mintemp;
mintemp = min(yDec);
yDec = yDec - mintemp;
xR = (1:length(yRis))*siNew;
xD = (1:length(yDec))*siNew;
xRD = (1:length(Eventplot))*si;
[yR_fit_obj yR_stat] = myfity2(yRis,'n',siNew,'');
[yD_fit_obj yD_stat] = myfity1(yDec,'n',siNew,'');
yR_alpha = yR_fit_obj.alpha;
yR_beta = yR_fit_obj.beta;
yD_alpha = yD_fit_obj.alpha;
yD_beta = yD_fit_obj.beta;
yR_fit = yR_alpha*(1-exp(-yR_beta*(xR)));
yD_fit = yD_alpha*(exp(-yD_beta*(xD)));
mydircheck = evalin('base','exist(''mydirSave'',''var'');');
if mydircheck == 0
mydirChoose = pwd;
else
mydirChoose = evalin('base','mydirSave');
end
mydirChoose = uigetdir(mydirChoose);
if mydirChoose == 0
msgbox('Select a folder')
return;
end
assignin('base','mydirSave',mydirChoose);
Eventsfile = evalin('base','Eventsfile');
fileName = regexprep(Eventsfile, '_autoEventStats.mat', '');
analysisfilePath = evalin('base','mydirChoose');
recordType = regexp(analysisfilePath, '(MEP|MEPPs|EPC|EPCs)', 'match');
recordType = char(recordType);
if strcmp(recordType, 'MEP') || strcmp(recordType, 'MEPPs')
unitsY = 'mV';
else
unitsY = 'nA';
end
abfFile = [fileName, '.abf'];
myfileN = abfFile;
fid = fopen(myfileN,'r','ieee-le');
sz=1;
numType = 'float';
myGainfileoffset = 268;
fseek(fid,myGainfileoffset,'bof');
cellGain = fread(fid,sz,numType);
fclose(fid);
Eventplot = Eventplot/cellGain;
yRis = yRis/cellGain;
yR_fit = yR_fit/cellGain;
yDec = yDec/cellGain;
yD_fit = yD_fit/cellGain;
hf_curve = figure; ha_curve = axes; plot(xRD,Eventplot,'k','LineWidth',10,'MarkerSize',15); set(gca,'Box','off');
hf_yRis = figure; ha_yRis = axes; plot(xR,yRis,'k','LineWidth', 10,'MarkerSize',15); set(gca,'Box','off');
hf_yDec = figure; ha_yDec = axes; plot(xD,yDec,'k','LineWidth', 10,'MarkerSize',15); set(gca,'Box','off');
hold(ha_yRis,'on');
plot(ha_yRis,xR,yR_fit,'b','LineWidth',3); hold(ha_yRis,'off');
hold(ha_yDec,'on');
plot(ha_yDec,xD,yD_fit,'b','LineWidth',3); hold(ha_yDec,'off');
cgE = ~myEventsFlag(1:k);
cgE = sum(cgE);
Event = num2str(cgE);
fileNamePrint = regexprep(fileName,'_','\\_');
AxisFont = 18;
figure(hf_curve)
gcf; title({[recordType, ' ', fileNamePrint, '\_', 'Event\_', Event]},'FontSize',AxisFont);
saveas(gcf,[mydirChoose, '\', recordType, '_', fileName, '_', Event, '.pdf'], 'pdf');
close gcf;
figure(hf_yRis)
gcf; title({[recordType, ' ', fileNamePrint, '\_', 'Event\_', Event, ' Rising']},'FontSize',AxisFont);
legend('Data', 'Fit Curve','Location','SouthEast')
xlabel('Time(seconds)','FontSize',20)
ylabel(['Amplitude (', unitsY, ')'], 'FontSize',20)
xpos = get(ha_yRis,'XLim');
ypos = get(ha_yRis,'Ylim');
strn1 = '$y={\alpha}\left(1-\exp({-\beta}{x})\right)$';
strn2 = sprintf('$y={%0.4f}\\left(1-\\exp({-%0.g}{x})\\right)$',yR_fit_obj.alpha, yR_fit_obj.beta);
strn3 = sprintf('$R^2={%0.4f}$',abs(yR_stat.rsquare));
strn4 = sprintf('$\\beta=\\frac{1}{\\tau}={%0.4g}\\left( seconds \\right)$',(1/yR_fit_obj.beta));
text('Interpreter','latex','string',...
{strn1;strn2;strn3;strn4},...
'Position',[xpos(2),0.5*ypos(2)],...
'HorizontalAlignment','Right','VerticalAlignment','Middle','FontSize',16)
saveas(gcf,[mydirChoose, '\', recordType, '_', fileName, '_', Event, '_Rise', '.pdf'], 'pdf');
close gcf;
figure(hf_yDec)
gcf; title({[recordType, ' ', fileNamePrint, '\_', 'Event\_', Event, ' Decay']},'FontSize',AxisFont);
legend('Data', 'Fit Curve','Location','SouthWest')
xlabel('Time(seconds)','FontSize',20)
ylabel(['Amplitude (', unitsY, ')'], 'FontSize',20)
xpos = get(ha_yDec,'XLim');
ypos = get(ha_yDec,'Ylim');
strn1 = '$y={\alpha}\left(1-\exp({-\beta}{x})\right)$';
strn2 = sprintf('$y={%0.4f}\\left(1-\\exp({-%0.g}{x})\\right)$',yD_fit_obj.alpha, yD_fit_obj.beta);
strn3 = sprintf('$R^2={%0.4f}$',abs(yD_stat.rsquare));
strn4 = sprintf('$\\beta=\\frac{1}{\\tau}={%0.4g}\\left( seconds \\right)$',(1/yD_fit_obj.beta));
text('Interpreter','latex','string',...
{strn1;strn2;strn3;strn4},...
'Position',[xpos(2),ypos(2)],...
'HorizontalAlignment','Right','VerticalAlignment','Top','FontSize',16)
saveas(gcf,[mydirChoose, '\', recordType, '_', fileName, '_', Event, '_Decay', '.pdf'], 'pdf');
close gcf;
end
Error using ==> load
Unable to read file EditEvents_publish.fig: No such file or directory.
Error in ==> hgload>localLoadFile at 177
AllVars = load(filename, '-mat');
Error in ==> hgload at 59
[FigVersion, FigData, VerNum] = localLoadFile(filename);
Error in ==> openfig at 72
[fig, savedvisible] = hgload(filename, struct('Visible','off'));
Error in ==> gui_mainfcn>local_openfig at 286
gui_hFigure = openfig(name, singleton, visible);
Error in ==> gui_mainfcn at 159
gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
Error in ==> EditEvents_publish at 44
gui_mainfcn(gui_State, varargin{:});