function varargout = PBC(varargin) % PBC M-file for PBC.fig % PBC, by itself, creates a new PBC or raises the existing % singleton*. % % H = PBC returns the handle to a new PBC or the handle to % the existing singleton*. % % PBC('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in PBC.M with the given input arguments. % % PBC('Property','Value',...) creates a new PBC or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before PBC_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to PBC_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help PBC % Last Modified by GUIDE v2.5 08-Oct-2003 14:19:46 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @PBC_OpeningFcn, ... 'gui_OutputFcn', @PBC_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin & isstr(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 % End initialization code - DO NOT EDIT % --- Executes just before PBC is made visible. function PBC_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to PBC (see VARARGIN) % Choose default command line output for PBC handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes PBC wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = PBC_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in togglebutton1. function togglebutton1_Callback(hObject, eventdata, handles) % hObject handle to togglebutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of togglebutton1 % --- Executes on button press in checkbox1. function checkbox1_Callback(hObject, eventdata, handles) % hObject handle to checkbox1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hint: get(hObject,'Value') returns toggle state of checkbox1 % --- Executes during object creation, after setting all properties. function number_CreateFcn(hObject, eventdata, handles) % hObject handle to number (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function number_Callback(hObject, eventdata, handles) % hObject handle to number (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of number as text % str2double(get(hObject,'String')) returns contents of number as a double I=str2double(get(hObject, 'String')); handles.num_data = I; guidata(hObject, handles); % --- Executes during object creation, after setting all properties. function File_name_CreateFcn(hObject, eventdata, handles) % hObject handle to File_name (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function File_name_Callback(hObject, eventdata, handles) % hObject handle to File_name (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of File_name as text % str2double(get(hObject,'String')) returns contents of File_name as a double fname=get(hObject, 'String'); handles.fname = fname; guidata(hObject, handles); % --- Executes during object creation, after setting all properties. function PB_name_CreateFcn(hObject, eventdata, handles) % hObject handle to PB_name (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function PB_name_Callback(hObject, eventdata, handles) % hObject handle to PB_name (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of PB_name as text % str2double(get(hObject,'String')) returns contents of PB_name as a double dname=get(hObject, 'String'); handles.dname = dname; guidata(hObject, handles); % --- Executes on button press in Fitting. function Fitting_Callback(hObject, eventdata, handles) % hObject handle to Fitting (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) dname=handles.dname; I=handles.num_data; DNAMEIN=sprintf('%s.xls', dname); data_all = xlsread(DNAMEIN); Plane_initial = data_all(1:I); % Plane array goes from 1 to I num_Int = data_all(I+1:2*I); % absolute value intensities for the numerator denom_Int = data_all(2*I+1:3*I); % absolute value intensities for the denominator num_Int_norm = num_Int ./ num_Int(1); % calculates normalized intensity values for numerator, normalized to t=0 denom_Int_norm = denom_Int ./ denom_Int(1); % calculates normalized intensity values for denominator, normalized to t=0 Plane = (Plane_initial - 1).'; % makes plane array start from zero instead of 1 for data fitting purposes Ratio = (num_Int_norm ./ denom_Int_norm).'; % calculates the ratio of the normalized instensities outliers = ~excludedata(Plane, Ratio, 'range', [0 0.1]); % sets fit exclusion range in Y values [fresult,gof] = fit(Plane, Ratio, 'exp2', 'exclude', outliers); % double exponential fit, Plane numbers as X and normalized Ratio as Y % display (fresult); % displays fitted parameters and coefficients % display (gof); % displays goodness of fit parameters Fit_ratio = fresult(Plane); % producing fitted curve using the plane numbers CF = 1 ./ Fit_ratio; % correction factor is 1 over the ratio decay function a=num2str(fresult.a); b=num2str(fresult.b); c=num2str(fresult.c); d=num2str(fresult.d); rsq=num2str(gof.rsquare); coef=sprintf('a = %s ; b = %s', a, b); coef2=sprintf('c = %s ; d = %s', c, d); coef3=sprintf('r^2 = %s', rsq); plot(Plane, Ratio,'rd', Plane, fresult(0:I-1),'b-'); % Plots results title('Double exponential fit to Photobleach data'); xlabel('Plane Number'); ylabel('Normalized Ratio Decay'); legend('Data', 'Fit'); axis([0, I, 0, 1.2]); text (2, 0.4, 'y = a exp(b*x) + c exp(d*x)'); text (2, 0.33, coef); text (2, 0.26, coef2); text (2, 0.19, coef3); set(gcf,'PaperUnits','inches'); width = 7.5; % Initialize a variable for width. height = 9.6; % Initialize a varible for height. myfiguresize = [0.5, 0.7, width, height]; set(gcf, 'PaperPosition', myfiguresize); % PRINT; % prints graph handles.CF=CF; guidata(hObject, handles); % --- Executes on button press in Image_process. function Image_process_Callback(hObject, eventdata, handles) % hObject handle to Image_process (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) CF=handles.CF; fname=handles.fname; I=handles.num_data %% Image processing starting at this point, using the CF as the correction if I < 100; if I < 10; for mult_rep=1:I; counter=mult_rep; FNAMEIN=sprintf('%s%i.tif', fname, counter); ratio=imread(FNAMEIN,'tif'); R=double(ratio); CR=R .* CF(counter); %Array element by element multiplication CR_out=uint16(CR); FNAMEOUT=sprintf('out_%i.tif',counter); imwrite(CR_out, FNAMEOUT, 'tif','compression','none'); % write output file end; else; for mult_rep=1:I; counter=mult_rep; if counter < 10; FNAMEIN=sprintf('%s0%i.tif', fname, counter); else; FNAMEIN=sprintf('%s%i.tif', fname, counter); end; ratio=imread(FNAMEIN,'tif'); R=double(ratio); CR=R .* CF(counter); %Array element by element multiplication CR_out=uint16(CR); if counter < 10; FNAMEOUT=sprintf('out_0%i.tif',counter); else; FNAMEOUT=sprintf('out_%i.tif',counter); end; imwrite(CR_out, FNAMEOUT, 'tif','compression','none'); % write output file end; end; elseif I >= 100; for mult_rep=1:I; counter=mult_rep; if counter < 10; FNAMEIN=sprintf('%s00%i.tif', fname, counter); ratio=imread(FNAMEIN,'tif'); R=double(ratio); CR=R .* CF(counter); %Array element by element multiplication CR_out=uint16(CR); FNAMEOUT=sprintf('out_00%i.tif',counter); imwrite(CR_out, FNAMEOUT, 'tif','compression','none'); % write output file elseif counter < 100; FNAMEIN=sprintf('%s0%i.tif', fname, counter); ratio=imread(FNAMEIN,'tif'); R=double(ratio); CR=R .* CF(counter); %Array element by element multiplication CR_out=uint16(CR); FNAMEOUT=sprintf('out_0%i.tif',counter); imwrite(CR_out, FNAMEOUT, 'tif','compression','none'); % write output file elseif counter >= 100; FNAMEIN=sprintf('%s%i.tif', fname, counter); ratio=imread(FNAMEIN,'tif'); R=double(ratio); CR=R .* CF(counter); %Array element by element multiplication CR_out=uint16(CR); FNAMEOUT=sprintf('out_%i.tif',counter); imwrite(CR_out, FNAMEOUT, 'tif','compression','none'); % write output file end; end; end; % --- Executes on button press in quit. function quit_Callback(hObject, eventdata, handles) % hObject handle to quit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA delete(handles.output);