Tag Archives: matlab
Matlab code for calculating characteristics equation
I have the code below to obtain the characteristic equation of a 6by6 matrix but it giving me an error of sym
% Define a symbolic 6×6 matrix with entries as a mixture of alphabet letters and zeros
syms a b c d e f g h i j k l m n p q r s t I v w x y z
A = [-a 0 b -c d e; f -g 0 0 h 0; 0 0 -i c 0 e; 0 0 j -k 0 0; 0 0 0 l -m 0; 0 0 0 n 0 -p];
% Calculate the characteristic polynomial of the matrix A
char_eqn = charpoly(A);
disp(‘The characteristic equation of the matrix A is:’)
disp(char_eqn)I have the code below to obtain the characteristic equation of a 6by6 matrix but it giving me an error of sym
% Define a symbolic 6×6 matrix with entries as a mixture of alphabet letters and zeros
syms a b c d e f g h i j k l m n p q r s t I v w x y z
A = [-a 0 b -c d e; f -g 0 0 h 0; 0 0 -i c 0 e; 0 0 j -k 0 0; 0 0 0 l -m 0; 0 0 0 n 0 -p];
% Calculate the characteristic polynomial of the matrix A
char_eqn = charpoly(A);
disp(‘The characteristic equation of the matrix A is:’)
disp(char_eqn) I have the code below to obtain the characteristic equation of a 6by6 matrix but it giving me an error of sym
% Define a symbolic 6×6 matrix with entries as a mixture of alphabet letters and zeros
syms a b c d e f g h i j k l m n p q r s t I v w x y z
A = [-a 0 b -c d e; f -g 0 0 h 0; 0 0 -i c 0 e; 0 0 j -k 0 0; 0 0 0 l -m 0; 0 0 0 n 0 -p];
% Calculate the characteristic polynomial of the matrix A
char_eqn = charpoly(A);
disp(‘The characteristic equation of the matrix A is:’)
disp(char_eqn) syms, symbolic MATLAB Answers — New Questions
Fastest Way of Opening and Reading .csv Files (Currently using xlsread)
I am currently trying to convert 100,000+ csv files (all the same size, with the same data structuring on the inside) to mat files, and I am running into the issue that it takes an extremely long time, and sometimes Excel stops responding. Are there any other functions that could cut down on the read time of these .csv files?
I read something about trying the COM server that runs Excel, but I am not sure how to implement it. Any thoughts?I am currently trying to convert 100,000+ csv files (all the same size, with the same data structuring on the inside) to mat files, and I am running into the issue that it takes an extremely long time, and sometimes Excel stops responding. Are there any other functions that could cut down on the read time of these .csv files?
I read something about trying the COM server that runs Excel, but I am not sure how to implement it. Any thoughts? I am currently trying to convert 100,000+ csv files (all the same size, with the same data structuring on the inside) to mat files, and I am running into the issue that it takes an extremely long time, and sometimes Excel stops responding. Are there any other functions that could cut down on the read time of these .csv files?
I read something about trying the COM server that runs Excel, but I am not sure how to implement it. Any thoughts? excel, m, .mat, conversion, xlsread, csvread MATLAB Answers — New Questions
How can I create an impulse (delta) signal in Simulink?
How can I create an impulse (delta) signal in Simulink? I looked for it in "Sources" library but there is not.How can I create an impulse (delta) signal in Simulink? I looked for it in "Sources" library but there is not. How can I create an impulse (delta) signal in Simulink? I looked for it in "Sources" library but there is not. #simulink MATLAB Answers — New Questions
How reduce data from 3917×2 to 1868×2 without change the entire of graph?
I have zdata.mat contains data 3917×2 I need a way to reduce data to 1868×2 , (hint: first column refers to x axis, second column refers to y axis)I have zdata.mat contains data 3917×2 I need a way to reduce data to 1868×2 , (hint: first column refers to x axis, second column refers to y axis) I have zdata.mat contains data 3917×2 I need a way to reduce data to 1868×2 , (hint: first column refers to x axis, second column refers to y axis) reduce, size MATLAB Answers — New Questions
I am using a GUI already made, it is giving error of input argument is unused. I cannot run this code due the multiple error message like this. error highlights these variable
function varargout = FLIM_processing(varargin)
% FLIM_PROCESSING MATLAB code for FLIM_processing.fig
% FLIM_PROCESSING, by itself, creates a new FLIM_PROCESSING or raises the existing
% singleton*.
%
% H = FLIM_PROCESSING returns the handle to a new FLIM_PROCESSING or the handle to
% the existing singleton*.
%
% FLIM_processing(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in FLIM_processing.M with the given input arguments.
%
% FLIM_processing(‘Property’,’Value’,…) creates a new FLIM_processing or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before FLIM_processing_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to FLIM_processing_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 FLIM_processing
% Last Modified by GUIDE v2.5 13-Apr-2021 19:57:16
% Begin initialization code – DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @FLIM_processing_OpeningFcn, …
‘gui_OutputFcn’, @FLIM_processing_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
% End initialization code – DO NOT EDIT
% — Executes just before FLIM_processing is made visible.
function FLIM_processing_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 FLIM_processing (see VARARGIN)
% Choose default command line output for FLIM_processing
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes FLIM_processing wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% — Outputs from this function are returned to the command line.
function varargout = FLIM_processing_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;
%% Get the NADH Image Button
% — Executes on button press in pushbutton1.
function read_NADH_intensity_Callback(~, ~, 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)
global nadhTextImage;
global maskShowImage;
global nadhImageName;
global nadhFileName;
global nadhPathName;
% Get the location of the image
[nadhFileName, nadhPathName] = uigetfile(‘*.asc’,’Pick an Image’);
nadhTextImage = importdata(strcat(nadhPathName,nadhFileName));
nadhTextImage(nadhTextImage > 1000) = 0;
nadhTextImage(:,245:256)=0;
maskShowImage = nadhTextImage;
nadhImageName = {nadhFileName,’NADH’};
% display the NADH image in axes1
maxIntensityValue = max(nadhTextImage(:));
minIntensityValue = min(nadhTextImage(:));
set(handles.slider3,’Max’,maxIntensityValue);
set(handles.slider3,’Min’,minIntensityValue);
set(handles.text19,’String’,num2str(minIntensityValue));
set(handles.text20,’String’,num2str(maxIntensityValue));
set(handles.text23,’String’,nadhFileName);
axes(handles.axes1);
imagesc(nadhTextImage)
colormap(gray)
colorbar
axes(handles.axes4);
imagesc(maskShowImage)
colormap(gray)
colorbar
%% Get the Mask Image Button
% — Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhTextImage;
global maskImage;
global nadhThreshold;
% get the image mask
maskImage = nadhTextImage;
nadhThreshold = get(handles.edit1,’String’);
nadhThreshold = str2double( nadhThreshold );
maskImage(maskImage < nadhThreshold) = 0;
maskImage(maskImage~=0) = 1;
% display the mask Image axes4
axes(handles.axes4);
imagesc(maskImage)
colormap(gray)
colorbar
%% read FAD intensity image
% — Executes on button press in readFADIntensity.
function read_FAD_intensity_Callback(hObject, eventdata, handles)
% hObject handle to readFADIntensity (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadTextImage
% Get the location of the image
global fadImageName;
global fadFileName;
global fadPathName;
[fadFileName, fadPathName] = uigetfile(‘*.asc’,’Pick an Image’);
fadImageName = {fadFileName,’FAD’};
fadTextImage = importdata(strcat(fadPathName,fadFileName));
fadTextImage(fadTextImage > 1000) = 0;
fadTextImage(:,245:256)=0;
% display the NADH image in axes1
set(handles.text24,’String’,fadFileName);
axes(handles.axes2);
imagesc(fadTextImage)
colormap(gray)
colorbar
%% Read NADH T1 Image
% — Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhT1Image;
% Get the location of the image
[nadhT1FileName, nadhT1PathName] = uigetfile(‘*.asc’,’Pick an Image’);
nadhT1Image = importdata(strcat(nadhT1PathName,nadhT1FileName));
nadhT1Image(nadhT1Image > 8000) = 0;
nadhT1Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes7);
imagesc(nadhT1Image)
colormap(gray)
colorbar
set(handles.text7 , ‘String’, nadhT1FileName);
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,’String’)) returns contents of edit1 as a double
% — Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
% — Executes during object deletion, before destroying properties.
function edit1_DeleteFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% Calculate Redox Ratio Button
% — Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhTextImage;
global fadTextImage;
global redoxRatioImage;
redoxRatioImage = nadhTextImage./(nadhTextImage + fadTextImage);
axes(handles.axes6);
imagesc(redoxRatioImage)
colormap(gray)
colorbar
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (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 edit2 as text
% str2double(get(hObject,’String’)) returns contents of edit2 as a double
% — Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
% — Executes on button press in pushbutton6.
function pushbutton6_Callback(~, ~, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhTextImage;
global fadTextImage;
global redoxRatioImage;
global maskImage;
global redoxRatio;
nadhIntensityImage = nadhTextImage.* maskImage;
fadIntensityImage = fadTextImage.* maskImage;
axes(handles.axes1);
imagesc(nadhIntensityImage)
colormap(gray)
colorbar
axes(handles.axes2);
imagesc(fadIntensityImage)
colormap(gray)
colorbar
redoxRatioIntensityImage = redoxRatioImage.* maskImage;
axes(handles.axes6);
imagesc(redoxRatioIntensityImage)
colormap(gray)
colorbar
redoxRatio = mean(redoxRatioIntensityImage(redoxRatioIntensityImage~=0),’omitnan’);
set(handles.edit2 , ‘String’, num2str(redoxRatio));
%% Read NADH T2 Image and display
% — Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhT2Image;
% Get the location of the image
[nadhT2FileName, nadhT2PathName] = uigetfile(‘*.asc’,’Pick an Image’);
nadhT2Image = importdata(strcat(nadhT2PathName,nadhT2FileName));
nadhT2Image(nadhT2Image > 8000) = 0;
nadhT2Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes8);
imagesc(nadhT2Image)
colormap(gray)
colorbar
set(handles.text8 , ‘String’, nadhT2FileName);
%% Read NADH alpha Image and display
% — Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhAlphaImage;
% Get the location of the image
[nadhAlphaFileName, nadhAlphaPathName] = uigetfile(‘*.asc’,’Pick an Image’);
nadhAlphaImage = importdata(strcat(nadhAlphaPathName,nadhAlphaFileName));
nadhAlphaImage(nadhAlphaImage>100) = 0;
nadhAlphaImage(nadhAlphaImage<0) = 0;
nadhAlphaImage(:,245:256) = 0;
% display the NADH image in axes7 and show the image name
axes(handles.axes9);
imagesc(nadhAlphaImage)
colormap(gray)
colorbar
set(handles.text9 , ‘String’, nadhAlphaFileName);
%% Calculate NADH FLIM mean
% — Executes on button press in pushbutton9.
function pushbutton9_Callback(~, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhT1Image;
global nadhT2Image;
global nadhAlphaImage;
global maskImage;
global nadhT1Mean;
global nadhT2Mean;
global nadhAlphaMean;
global nadhFLIMMMean;
nadhFLIMMImage = (nadhT1Image.* nadhAlphaImage + nadhT2Image.*(100 – nadhAlphaImage))/100;
nadhFLIMMImageM = nadhFLIMMImage .* maskImage;
nadhAlphaImageM = nadhAlphaImage.* maskImage;
nadhT2ImageM = nadhT2Image .* maskImage;
nadhT1ImageM = nadhT1Image .* maskImage;
nadhAlphaMean = mean(nadhAlphaImageM(nadhAlphaImageM~=0),’omitnan’);
nadhT2Mean = mean(nadhT2ImageM(nadhT2ImageM~=0),’omitnan’);
nadhT1Mean = mean(nadhT1ImageM(nadhT1ImageM~=0),’omitnan’);
nadhFLIMMMean = mean(nadhFLIMMImageM(nadhFLIMMImageM~=0),’omitnan’);
set(handles.edit3 , ‘String’, num2str(nadhT1Mean));
set(handles.edit4 , ‘String’, num2str(nadhT2Mean));
set(handles.edit5 , ‘String’, num2str(nadhAlphaMean));
set(handles.edit6 , ‘String’, num2str(nadhFLIMMMean));
axes(handles.axes7);
imagesc(nadhT1ImageM)
colormap(gray)
colorbar
axes(handles.axes8);
imagesc(nadhT2ImageM)
colormap(gray)
colorbar
axes(handles.axes9);
imagesc(nadhAlphaImageM)
colormap(gray)
colorbar
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (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 edit3 as text
% str2double(get(hObject,’String’)) returns contents of edit3 as a double
% — Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit4_Callback(hObject, ~, handles)
% hObject handle to edit4 (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 edit4 as text
% str2double(get(hObject,’String’)) returns contents of edit4 as a double
% — Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (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 edit5 as text
% str2double(get(hObject,’String’)) returns contents of edit5 as a double
% — Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (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 edit6 as text
% str2double(get(hObject,’String’)) returns contents of edit6 as a double
% — Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
%% Read FAD T1 image and display
% — Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadT1Image;
% Get the location of the image
[fadT1FileName, fadT1PathName] = uigetfile(‘*.asc’,’Pick an Image’);
fadT1Image = importdata(strcat(fadT1PathName,fadT1FileName));
fadT1Image(fadT1Image > 8000) = 0;
fadT1Image(fadT1Image < 0) = 0;
fadT1Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes10);
imagesc(fadT1Image)
colormap(gray)
colorbar
set(handles.text10 , ‘String’, fadT1FileName);
% — Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, ~, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadT2Image;
% Get the location of the image
[fadT2FileName, fadT2PathName] = uigetfile(‘*.asc’,’Pick an Image’);
fadT2Image = importdata(strcat(fadT2PathName,fadT2FileName));
fadT2Image(fadT2Image>8000) = 0;
fadT2Image(fadT2Image < 0) = 0;
fadT2Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes11);
imagesc(fadT2Image)
colormap(gray)
colorbar
set(handles.text11 , ‘String’, fadT2FileName);
% — Executes on button press in pushbutton12.
function pushbutton12_Callback(~, ~, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadAlphaImage;
% Get the location of the image
[fadAplhaFileName, fadAlphaPathName] = uigetfile(‘*.asc’,’Pick an Image’);
fadAlphaImage = importdata(strcat(fadAlphaPathName,fadAplhaFileName));
fadAlphaImage(fadAlphaImage>100) = 0;
fadAlphaImage(fadAlphaImage<0) = 0;
fadAlphaImage(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes12);
imagesc(fadAlphaImage)
colormap(gray)
colorbar
set(handles.text12 , ‘String’, fadAplhaFileName);
% — Executes on button press in pushbutton13.
function pushbutton13_Callback(~, eventdata, handles)
% hObject handle to pushbutton13 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadT1Image;
global fadT2Image;
global fadAlphaImage;
global maskImage
global fadT1Mean;
global fadT2Mean;
global fadAlphaMean;
global fadFLIMMMean;
fadFLIMMImage = (fadT1Image.* fadAlphaImage + fadT2Image.*(100 – fadAlphaImage))/100;
fadFLIMMImageM = fadFLIMMImage .* maskImage;
fadAlphaImageM = fadAlphaImage.* maskImage;
fadT2ImageM = fadT2Image .* maskImage;
fadT1ImageM = fadT1Image .* maskImage;
fadAlphaMean = mean(fadAlphaImageM(fadAlphaImageM~=0),’omitnan’);
fadT2Mean = mean(fadT2ImageM(fadT2ImageM~=0),’omitnan’);
fadT1Mean = mean(fadT1ImageM(fadT1ImageM~=0),’omitnan’);
fadFLIMMMean = mean(fadFLIMMImageM(fadFLIMMImageM~=0),’omitnan’);
set(handles.edit7 , ‘String’, num2str(fadT1Mean));
set(handles.edit8 , ‘String’, num2str(fadT2Mean));
set(handles.edit9 , ‘String’, num2str(fadAlphaMean));
set(handles.edit10 , ‘String’, num2str(fadFLIMMMean));
axes(handles.axes10);
imagesc(fadT1ImageM)
colormap(gray)
colorbar
axes(handles.axes11);
imagesc(fadT2ImageM)
colormap(gray)
colorbar
axes(handles.axes12);
imagesc(fadAlphaImageM)
colormap(gray)
colorbar
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (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 edit7 as text
% str2double(get(hObject,’String’)) returns contents of edit7 as a double
% — Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit8_Callback(hObject, eventdata, handles)
% hObject handle to edit8 (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 edit8 as text
% str2double(get(hObject,’String’)) returns contents of edit8 as a double
% — Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit9_Callback(hObject, eventdata, handles)
% hObject handle to edit9 (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 edit9 as text
% str2double(get(hObject,’String’)) returns contents of edit9 as a double
% — Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit9 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit10_Callback(hObject, eventdata, handles)
% hObject handle to edit10 (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 edit10 as text
% str2double(get(hObject,’String’)) returns contents of edit10 as a double
% — Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit10 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit11_Callback(~, eventdata, handles)
% hObject handle to edit11 (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 edit11 as text
% str2double(get(hObject,’String’)) returns contents of edit11 as a double
% — Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit11 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit12_Callback(hObject, eventdata, handles)
% hObject handle to edit12 (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 edit12 as text
% str2double(get(hObject,’String’)) returns contents of edit12 as a double
% — Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit12 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit13_Callback(hObject, eventdata, handles)
% hObject handle to edit13 (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 edit13 as text
% str2double(get(hObject,’String’)) returns contents of edit13 as a double
% — Executes during object creation, after setting all properties.
function edit13_CreateFcn(hObject, ~, handles)
% hObject handle to edit13 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
%% Select the file to save
% — Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton15 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global saveExcelLocation;
[saveExcelName, saveExcelPath] = uigetfile(‘*.xlsx’,’Pick an excel file’);
saveExcelLocation = strcat(saveExcelPath,saveExcelName);
set(handles.edit14 , ‘String’, saveExcelLocation);
function edit14_Callback(hObject, eventdata, handles)
% hObject handle to edit14 (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 edit14 as text
% str2double(get(hObject,’String’)) returns contents of edit14 as a double
% — Executes during object creation, after setting all properties.
function edit14_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit14 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
%% Save the data to the excel file
% — Executes on button press in pushbutton16.
function pushbutton16_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton16 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhT1Mean;
global nadhT2Mean;
global nadhAlphaMean;
global nadhFLIMMMean;
global fadT1Mean;
global fadT2Mean;
global fadAlphaMean;
global fadFLIMMMean;
global redoxRatio;
global nadhThreshold;
global saveExcelLocation;
global nadhImageName ;
global fadImageName;
nadhFlimData = [nadhThreshold,redoxRatio,nadhT1Mean,nadhT2Mean,nadhAlphaMean,nadhFLIMMMean];
fadFlimData = [fadT1Mean,fadT2Mean,fadAlphaMean,fadFLIMMMean];
excelData = xlsread(saveExcelLocation,’Sheet1′,’E:E’); % read the column of interest
lastRowNumber = length(excelData)+ 2;
nadhWriteLoc = strcat(‘C’,num2str(lastRowNumber));
nadhNameWriteLoc = strcat(‘A’,num2str(lastRowNumber));
% save NADH data to the excel file
xlswrite(saveExcelLocation,nadhFlimData,’sheet1′,nadhWriteLoc);
xlswrite(saveExcelLocation,nadhImageName,’sheet1′,nadhNameWriteLoc);
% save FAD data to the excel file
lastRowNumber = lastRowNumber + 1;
fadWriteLoc = strcat(‘E’,num2str(lastRowNumber));
fadNameWriteLoc = strcat(‘A’,num2str(lastRowNumber));
xlswrite(saveExcelLocation,fadFlimData,’sheet1′,fadWriteLoc);
xlswrite(saveExcelLocation,fadImageName,’sheet1′,fadNameWriteLoc);
% — Executes on slider movement.
function slider3_Callback(hObject, eventdata, handles)
% hObject handle to slider3 (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,’Value’) returns position of slider
% get(hObject,’Min’) and get(hObject,’Max’) to determine range of slider
global nadhThreshold;
global maskShowImage;
global nadhTextImage
nadhThreshold = get(handles.slider3 ,’Value’);
% get the image mask
maskShowImage = nadhTextImage;
maskShowImage(maskShowImage < nadhThreshold) = 0;
set(handles.edit1 , ‘String’, num2str(nadhThreshold));
axes(handles.axes4);
imagesc(maskShowImage)
colormap(gray)
colorbar
% — Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider3 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,[.9 .9 .9]);
end
function slider3_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider3 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,[.9 .9 .9]);
end
% — Executes on button press in pushbutton17.
function pushbutton17_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton17 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhFileName;
global nadhPathName;
global nadhT1Image;
% Get the location of the image
nadhT1FileName = strrep(nadhFileName,’photons’,’t1′);
nadhT1PathName = nadhPathName;
nadhT1Image = importdata(strcat(nadhT1PathName,nadhT1FileName));
nadhT1Image(nadhT1Image > 8000) = 0;
nadhT1Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes7);
imagesc(nadhT1Image)
colormap(gray)
colorbar
set(handles.text7 , ‘String’, nadhT1FileName);
global nadhT2Image;
% Get the location of the image
nadhT2FileName = strrep(nadhFileName,’photons’,’t2′);
nadhT2PathName = nadhPathName;
nadhT2Image = importdata(strcat(nadhT2PathName,nadhT2FileName));
nadhT2Image(nadhT2Image > 8000) = 0;
nadhT2Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes8);
imagesc(nadhT2Image)
colormap(gray)
colorbar
set(handles.text8 , ‘String’, nadhT2FileName);
global nadhAlphaImage;
% Get the location of the image
nadhAlphaFileName = strrep(nadhFileName,’photons’,’a1[%]’);
nadhAlphaPathName = nadhPathName;
nadhAlphaImage = importdata(strcat(nadhAlphaPathName,nadhAlphaFileName));
nadhAlphaImage(nadhAlphaImage>100) = 0;
nadhAlphaImage(nadhAlphaImage<0) = 0;
nadhAlphaImage(:,245:256) = 0;
% display the NADH image in axes7 and show the image name
axes(handles.axes9);
imagesc(nadhAlphaImage)
colormap(gray)
colorbar
set(handles.text9 , ‘String’, nadhAlphaFileName);
global fadFileName;
global fadPathName;
global fadT1Image;
% Get the location of the image
fadT1FileName = strrep(fadFileName,’photons’,’t1′);
fadT1PathName = fadPathName;
fadT1Image = importdata(strcat(fadT1PathName,fadT1FileName));
fadT1Image(fadT1Image > 8000) = 0;
fadT1Image(fadT1Image < 0) = 0;
fadT1Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes10);
imagesc(fadT1Image)
colormap(gray)
colorbar
set(handles.text10 , ‘String’, fadT1FileName);
global fadT2Image;
% Get the location of the image
fadT2FileName = strrep(fadFileName,’photons’,’t2′);
fadT2PathName = fadPathName;
fadT2Image = importdata(strcat(fadT2PathName,fadT2FileName));
fadT2Image(fadT2Image>8000) = 0;
fadT2Image(fadT2Image < 0) = 0;
fadT2Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes11);
imagesc(fadT2Image)
colormap(gray)
colorbar
set(handles.text11 , ‘String’, fadT2FileName)
global fadAlphaImage;
% Get the location of the image
fadAplhaFileName = strrep(fadFileName,’photons’,’a1[%]’);
fadAlphaPathName = fadPathName;
fadAlphaImage = importdata(strcat(fadAlphaPathName,fadAplhaFileName));
fadAlphaImage(fadAlphaImage>100) = 0;
fadAlphaImage(fadAlphaImage<0) = 0;
fadAlphaImage(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes12);
imagesc(fadAlphaImage)
colormap(gray)
colorbar
set(handles.text12 , ‘String’, fadAplhaFileName);function varargout = FLIM_processing(varargin)
% FLIM_PROCESSING MATLAB code for FLIM_processing.fig
% FLIM_PROCESSING, by itself, creates a new FLIM_PROCESSING or raises the existing
% singleton*.
%
% H = FLIM_PROCESSING returns the handle to a new FLIM_PROCESSING or the handle to
% the existing singleton*.
%
% FLIM_processing(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in FLIM_processing.M with the given input arguments.
%
% FLIM_processing(‘Property’,’Value’,…) creates a new FLIM_processing or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before FLIM_processing_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to FLIM_processing_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 FLIM_processing
% Last Modified by GUIDE v2.5 13-Apr-2021 19:57:16
% Begin initialization code – DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @FLIM_processing_OpeningFcn, …
‘gui_OutputFcn’, @FLIM_processing_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
% End initialization code – DO NOT EDIT
% — Executes just before FLIM_processing is made visible.
function FLIM_processing_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 FLIM_processing (see VARARGIN)
% Choose default command line output for FLIM_processing
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes FLIM_processing wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% — Outputs from this function are returned to the command line.
function varargout = FLIM_processing_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;
%% Get the NADH Image Button
% — Executes on button press in pushbutton1.
function read_NADH_intensity_Callback(~, ~, 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)
global nadhTextImage;
global maskShowImage;
global nadhImageName;
global nadhFileName;
global nadhPathName;
% Get the location of the image
[nadhFileName, nadhPathName] = uigetfile(‘*.asc’,’Pick an Image’);
nadhTextImage = importdata(strcat(nadhPathName,nadhFileName));
nadhTextImage(nadhTextImage > 1000) = 0;
nadhTextImage(:,245:256)=0;
maskShowImage = nadhTextImage;
nadhImageName = {nadhFileName,’NADH’};
% display the NADH image in axes1
maxIntensityValue = max(nadhTextImage(:));
minIntensityValue = min(nadhTextImage(:));
set(handles.slider3,’Max’,maxIntensityValue);
set(handles.slider3,’Min’,minIntensityValue);
set(handles.text19,’String’,num2str(minIntensityValue));
set(handles.text20,’String’,num2str(maxIntensityValue));
set(handles.text23,’String’,nadhFileName);
axes(handles.axes1);
imagesc(nadhTextImage)
colormap(gray)
colorbar
axes(handles.axes4);
imagesc(maskShowImage)
colormap(gray)
colorbar
%% Get the Mask Image Button
% — Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhTextImage;
global maskImage;
global nadhThreshold;
% get the image mask
maskImage = nadhTextImage;
nadhThreshold = get(handles.edit1,’String’);
nadhThreshold = str2double( nadhThreshold );
maskImage(maskImage < nadhThreshold) = 0;
maskImage(maskImage~=0) = 1;
% display the mask Image axes4
axes(handles.axes4);
imagesc(maskImage)
colormap(gray)
colorbar
%% read FAD intensity image
% — Executes on button press in readFADIntensity.
function read_FAD_intensity_Callback(hObject, eventdata, handles)
% hObject handle to readFADIntensity (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadTextImage
% Get the location of the image
global fadImageName;
global fadFileName;
global fadPathName;
[fadFileName, fadPathName] = uigetfile(‘*.asc’,’Pick an Image’);
fadImageName = {fadFileName,’FAD’};
fadTextImage = importdata(strcat(fadPathName,fadFileName));
fadTextImage(fadTextImage > 1000) = 0;
fadTextImage(:,245:256)=0;
% display the NADH image in axes1
set(handles.text24,’String’,fadFileName);
axes(handles.axes2);
imagesc(fadTextImage)
colormap(gray)
colorbar
%% Read NADH T1 Image
% — Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhT1Image;
% Get the location of the image
[nadhT1FileName, nadhT1PathName] = uigetfile(‘*.asc’,’Pick an Image’);
nadhT1Image = importdata(strcat(nadhT1PathName,nadhT1FileName));
nadhT1Image(nadhT1Image > 8000) = 0;
nadhT1Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes7);
imagesc(nadhT1Image)
colormap(gray)
colorbar
set(handles.text7 , ‘String’, nadhT1FileName);
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,’String’)) returns contents of edit1 as a double
% — Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
% — Executes during object deletion, before destroying properties.
function edit1_DeleteFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% Calculate Redox Ratio Button
% — Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhTextImage;
global fadTextImage;
global redoxRatioImage;
redoxRatioImage = nadhTextImage./(nadhTextImage + fadTextImage);
axes(handles.axes6);
imagesc(redoxRatioImage)
colormap(gray)
colorbar
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (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 edit2 as text
% str2double(get(hObject,’String’)) returns contents of edit2 as a double
% — Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
% — Executes on button press in pushbutton6.
function pushbutton6_Callback(~, ~, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhTextImage;
global fadTextImage;
global redoxRatioImage;
global maskImage;
global redoxRatio;
nadhIntensityImage = nadhTextImage.* maskImage;
fadIntensityImage = fadTextImage.* maskImage;
axes(handles.axes1);
imagesc(nadhIntensityImage)
colormap(gray)
colorbar
axes(handles.axes2);
imagesc(fadIntensityImage)
colormap(gray)
colorbar
redoxRatioIntensityImage = redoxRatioImage.* maskImage;
axes(handles.axes6);
imagesc(redoxRatioIntensityImage)
colormap(gray)
colorbar
redoxRatio = mean(redoxRatioIntensityImage(redoxRatioIntensityImage~=0),’omitnan’);
set(handles.edit2 , ‘String’, num2str(redoxRatio));
%% Read NADH T2 Image and display
% — Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhT2Image;
% Get the location of the image
[nadhT2FileName, nadhT2PathName] = uigetfile(‘*.asc’,’Pick an Image’);
nadhT2Image = importdata(strcat(nadhT2PathName,nadhT2FileName));
nadhT2Image(nadhT2Image > 8000) = 0;
nadhT2Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes8);
imagesc(nadhT2Image)
colormap(gray)
colorbar
set(handles.text8 , ‘String’, nadhT2FileName);
%% Read NADH alpha Image and display
% — Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhAlphaImage;
% Get the location of the image
[nadhAlphaFileName, nadhAlphaPathName] = uigetfile(‘*.asc’,’Pick an Image’);
nadhAlphaImage = importdata(strcat(nadhAlphaPathName,nadhAlphaFileName));
nadhAlphaImage(nadhAlphaImage>100) = 0;
nadhAlphaImage(nadhAlphaImage<0) = 0;
nadhAlphaImage(:,245:256) = 0;
% display the NADH image in axes7 and show the image name
axes(handles.axes9);
imagesc(nadhAlphaImage)
colormap(gray)
colorbar
set(handles.text9 , ‘String’, nadhAlphaFileName);
%% Calculate NADH FLIM mean
% — Executes on button press in pushbutton9.
function pushbutton9_Callback(~, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhT1Image;
global nadhT2Image;
global nadhAlphaImage;
global maskImage;
global nadhT1Mean;
global nadhT2Mean;
global nadhAlphaMean;
global nadhFLIMMMean;
nadhFLIMMImage = (nadhT1Image.* nadhAlphaImage + nadhT2Image.*(100 – nadhAlphaImage))/100;
nadhFLIMMImageM = nadhFLIMMImage .* maskImage;
nadhAlphaImageM = nadhAlphaImage.* maskImage;
nadhT2ImageM = nadhT2Image .* maskImage;
nadhT1ImageM = nadhT1Image .* maskImage;
nadhAlphaMean = mean(nadhAlphaImageM(nadhAlphaImageM~=0),’omitnan’);
nadhT2Mean = mean(nadhT2ImageM(nadhT2ImageM~=0),’omitnan’);
nadhT1Mean = mean(nadhT1ImageM(nadhT1ImageM~=0),’omitnan’);
nadhFLIMMMean = mean(nadhFLIMMImageM(nadhFLIMMImageM~=0),’omitnan’);
set(handles.edit3 , ‘String’, num2str(nadhT1Mean));
set(handles.edit4 , ‘String’, num2str(nadhT2Mean));
set(handles.edit5 , ‘String’, num2str(nadhAlphaMean));
set(handles.edit6 , ‘String’, num2str(nadhFLIMMMean));
axes(handles.axes7);
imagesc(nadhT1ImageM)
colormap(gray)
colorbar
axes(handles.axes8);
imagesc(nadhT2ImageM)
colormap(gray)
colorbar
axes(handles.axes9);
imagesc(nadhAlphaImageM)
colormap(gray)
colorbar
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (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 edit3 as text
% str2double(get(hObject,’String’)) returns contents of edit3 as a double
% — Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit4_Callback(hObject, ~, handles)
% hObject handle to edit4 (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 edit4 as text
% str2double(get(hObject,’String’)) returns contents of edit4 as a double
% — Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (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 edit5 as text
% str2double(get(hObject,’String’)) returns contents of edit5 as a double
% — Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (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 edit6 as text
% str2double(get(hObject,’String’)) returns contents of edit6 as a double
% — Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
%% Read FAD T1 image and display
% — Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadT1Image;
% Get the location of the image
[fadT1FileName, fadT1PathName] = uigetfile(‘*.asc’,’Pick an Image’);
fadT1Image = importdata(strcat(fadT1PathName,fadT1FileName));
fadT1Image(fadT1Image > 8000) = 0;
fadT1Image(fadT1Image < 0) = 0;
fadT1Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes10);
imagesc(fadT1Image)
colormap(gray)
colorbar
set(handles.text10 , ‘String’, fadT1FileName);
% — Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, ~, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadT2Image;
% Get the location of the image
[fadT2FileName, fadT2PathName] = uigetfile(‘*.asc’,’Pick an Image’);
fadT2Image = importdata(strcat(fadT2PathName,fadT2FileName));
fadT2Image(fadT2Image>8000) = 0;
fadT2Image(fadT2Image < 0) = 0;
fadT2Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes11);
imagesc(fadT2Image)
colormap(gray)
colorbar
set(handles.text11 , ‘String’, fadT2FileName);
% — Executes on button press in pushbutton12.
function pushbutton12_Callback(~, ~, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadAlphaImage;
% Get the location of the image
[fadAplhaFileName, fadAlphaPathName] = uigetfile(‘*.asc’,’Pick an Image’);
fadAlphaImage = importdata(strcat(fadAlphaPathName,fadAplhaFileName));
fadAlphaImage(fadAlphaImage>100) = 0;
fadAlphaImage(fadAlphaImage<0) = 0;
fadAlphaImage(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes12);
imagesc(fadAlphaImage)
colormap(gray)
colorbar
set(handles.text12 , ‘String’, fadAplhaFileName);
% — Executes on button press in pushbutton13.
function pushbutton13_Callback(~, eventdata, handles)
% hObject handle to pushbutton13 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadT1Image;
global fadT2Image;
global fadAlphaImage;
global maskImage
global fadT1Mean;
global fadT2Mean;
global fadAlphaMean;
global fadFLIMMMean;
fadFLIMMImage = (fadT1Image.* fadAlphaImage + fadT2Image.*(100 – fadAlphaImage))/100;
fadFLIMMImageM = fadFLIMMImage .* maskImage;
fadAlphaImageM = fadAlphaImage.* maskImage;
fadT2ImageM = fadT2Image .* maskImage;
fadT1ImageM = fadT1Image .* maskImage;
fadAlphaMean = mean(fadAlphaImageM(fadAlphaImageM~=0),’omitnan’);
fadT2Mean = mean(fadT2ImageM(fadT2ImageM~=0),’omitnan’);
fadT1Mean = mean(fadT1ImageM(fadT1ImageM~=0),’omitnan’);
fadFLIMMMean = mean(fadFLIMMImageM(fadFLIMMImageM~=0),’omitnan’);
set(handles.edit7 , ‘String’, num2str(fadT1Mean));
set(handles.edit8 , ‘String’, num2str(fadT2Mean));
set(handles.edit9 , ‘String’, num2str(fadAlphaMean));
set(handles.edit10 , ‘String’, num2str(fadFLIMMMean));
axes(handles.axes10);
imagesc(fadT1ImageM)
colormap(gray)
colorbar
axes(handles.axes11);
imagesc(fadT2ImageM)
colormap(gray)
colorbar
axes(handles.axes12);
imagesc(fadAlphaImageM)
colormap(gray)
colorbar
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (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 edit7 as text
% str2double(get(hObject,’String’)) returns contents of edit7 as a double
% — Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit8_Callback(hObject, eventdata, handles)
% hObject handle to edit8 (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 edit8 as text
% str2double(get(hObject,’String’)) returns contents of edit8 as a double
% — Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit9_Callback(hObject, eventdata, handles)
% hObject handle to edit9 (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 edit9 as text
% str2double(get(hObject,’String’)) returns contents of edit9 as a double
% — Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit9 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit10_Callback(hObject, eventdata, handles)
% hObject handle to edit10 (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 edit10 as text
% str2double(get(hObject,’String’)) returns contents of edit10 as a double
% — Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit10 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit11_Callback(~, eventdata, handles)
% hObject handle to edit11 (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 edit11 as text
% str2double(get(hObject,’String’)) returns contents of edit11 as a double
% — Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit11 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit12_Callback(hObject, eventdata, handles)
% hObject handle to edit12 (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 edit12 as text
% str2double(get(hObject,’String’)) returns contents of edit12 as a double
% — Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit12 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit13_Callback(hObject, eventdata, handles)
% hObject handle to edit13 (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 edit13 as text
% str2double(get(hObject,’String’)) returns contents of edit13 as a double
% — Executes during object creation, after setting all properties.
function edit13_CreateFcn(hObject, ~, handles)
% hObject handle to edit13 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
%% Select the file to save
% — Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton15 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global saveExcelLocation;
[saveExcelName, saveExcelPath] = uigetfile(‘*.xlsx’,’Pick an excel file’);
saveExcelLocation = strcat(saveExcelPath,saveExcelName);
set(handles.edit14 , ‘String’, saveExcelLocation);
function edit14_Callback(hObject, eventdata, handles)
% hObject handle to edit14 (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 edit14 as text
% str2double(get(hObject,’String’)) returns contents of edit14 as a double
% — Executes during object creation, after setting all properties.
function edit14_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit14 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
%% Save the data to the excel file
% — Executes on button press in pushbutton16.
function pushbutton16_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton16 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhT1Mean;
global nadhT2Mean;
global nadhAlphaMean;
global nadhFLIMMMean;
global fadT1Mean;
global fadT2Mean;
global fadAlphaMean;
global fadFLIMMMean;
global redoxRatio;
global nadhThreshold;
global saveExcelLocation;
global nadhImageName ;
global fadImageName;
nadhFlimData = [nadhThreshold,redoxRatio,nadhT1Mean,nadhT2Mean,nadhAlphaMean,nadhFLIMMMean];
fadFlimData = [fadT1Mean,fadT2Mean,fadAlphaMean,fadFLIMMMean];
excelData = xlsread(saveExcelLocation,’Sheet1′,’E:E’); % read the column of interest
lastRowNumber = length(excelData)+ 2;
nadhWriteLoc = strcat(‘C’,num2str(lastRowNumber));
nadhNameWriteLoc = strcat(‘A’,num2str(lastRowNumber));
% save NADH data to the excel file
xlswrite(saveExcelLocation,nadhFlimData,’sheet1′,nadhWriteLoc);
xlswrite(saveExcelLocation,nadhImageName,’sheet1′,nadhNameWriteLoc);
% save FAD data to the excel file
lastRowNumber = lastRowNumber + 1;
fadWriteLoc = strcat(‘E’,num2str(lastRowNumber));
fadNameWriteLoc = strcat(‘A’,num2str(lastRowNumber));
xlswrite(saveExcelLocation,fadFlimData,’sheet1′,fadWriteLoc);
xlswrite(saveExcelLocation,fadImageName,’sheet1′,fadNameWriteLoc);
% — Executes on slider movement.
function slider3_Callback(hObject, eventdata, handles)
% hObject handle to slider3 (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,’Value’) returns position of slider
% get(hObject,’Min’) and get(hObject,’Max’) to determine range of slider
global nadhThreshold;
global maskShowImage;
global nadhTextImage
nadhThreshold = get(handles.slider3 ,’Value’);
% get the image mask
maskShowImage = nadhTextImage;
maskShowImage(maskShowImage < nadhThreshold) = 0;
set(handles.edit1 , ‘String’, num2str(nadhThreshold));
axes(handles.axes4);
imagesc(maskShowImage)
colormap(gray)
colorbar
% — Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider3 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,[.9 .9 .9]);
end
function slider3_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider3 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,[.9 .9 .9]);
end
% — Executes on button press in pushbutton17.
function pushbutton17_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton17 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhFileName;
global nadhPathName;
global nadhT1Image;
% Get the location of the image
nadhT1FileName = strrep(nadhFileName,’photons’,’t1′);
nadhT1PathName = nadhPathName;
nadhT1Image = importdata(strcat(nadhT1PathName,nadhT1FileName));
nadhT1Image(nadhT1Image > 8000) = 0;
nadhT1Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes7);
imagesc(nadhT1Image)
colormap(gray)
colorbar
set(handles.text7 , ‘String’, nadhT1FileName);
global nadhT2Image;
% Get the location of the image
nadhT2FileName = strrep(nadhFileName,’photons’,’t2′);
nadhT2PathName = nadhPathName;
nadhT2Image = importdata(strcat(nadhT2PathName,nadhT2FileName));
nadhT2Image(nadhT2Image > 8000) = 0;
nadhT2Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes8);
imagesc(nadhT2Image)
colormap(gray)
colorbar
set(handles.text8 , ‘String’, nadhT2FileName);
global nadhAlphaImage;
% Get the location of the image
nadhAlphaFileName = strrep(nadhFileName,’photons’,’a1[%]’);
nadhAlphaPathName = nadhPathName;
nadhAlphaImage = importdata(strcat(nadhAlphaPathName,nadhAlphaFileName));
nadhAlphaImage(nadhAlphaImage>100) = 0;
nadhAlphaImage(nadhAlphaImage<0) = 0;
nadhAlphaImage(:,245:256) = 0;
% display the NADH image in axes7 and show the image name
axes(handles.axes9);
imagesc(nadhAlphaImage)
colormap(gray)
colorbar
set(handles.text9 , ‘String’, nadhAlphaFileName);
global fadFileName;
global fadPathName;
global fadT1Image;
% Get the location of the image
fadT1FileName = strrep(fadFileName,’photons’,’t1′);
fadT1PathName = fadPathName;
fadT1Image = importdata(strcat(fadT1PathName,fadT1FileName));
fadT1Image(fadT1Image > 8000) = 0;
fadT1Image(fadT1Image < 0) = 0;
fadT1Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes10);
imagesc(fadT1Image)
colormap(gray)
colorbar
set(handles.text10 , ‘String’, fadT1FileName);
global fadT2Image;
% Get the location of the image
fadT2FileName = strrep(fadFileName,’photons’,’t2′);
fadT2PathName = fadPathName;
fadT2Image = importdata(strcat(fadT2PathName,fadT2FileName));
fadT2Image(fadT2Image>8000) = 0;
fadT2Image(fadT2Image < 0) = 0;
fadT2Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes11);
imagesc(fadT2Image)
colormap(gray)
colorbar
set(handles.text11 , ‘String’, fadT2FileName)
global fadAlphaImage;
% Get the location of the image
fadAplhaFileName = strrep(fadFileName,’photons’,’a1[%]’);
fadAlphaPathName = fadPathName;
fadAlphaImage = importdata(strcat(fadAlphaPathName,fadAplhaFileName));
fadAlphaImage(fadAlphaImage>100) = 0;
fadAlphaImage(fadAlphaImage<0) = 0;
fadAlphaImage(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes12);
imagesc(fadAlphaImage)
colormap(gray)
colorbar
set(handles.text12 , ‘String’, fadAplhaFileName); function varargout = FLIM_processing(varargin)
% FLIM_PROCESSING MATLAB code for FLIM_processing.fig
% FLIM_PROCESSING, by itself, creates a new FLIM_PROCESSING or raises the existing
% singleton*.
%
% H = FLIM_PROCESSING returns the handle to a new FLIM_PROCESSING or the handle to
% the existing singleton*.
%
% FLIM_processing(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in FLIM_processing.M with the given input arguments.
%
% FLIM_processing(‘Property’,’Value’,…) creates a new FLIM_processing or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before FLIM_processing_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to FLIM_processing_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 FLIM_processing
% Last Modified by GUIDE v2.5 13-Apr-2021 19:57:16
% Begin initialization code – DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @FLIM_processing_OpeningFcn, …
‘gui_OutputFcn’, @FLIM_processing_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
% End initialization code – DO NOT EDIT
% — Executes just before FLIM_processing is made visible.
function FLIM_processing_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 FLIM_processing (see VARARGIN)
% Choose default command line output for FLIM_processing
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes FLIM_processing wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% — Outputs from this function are returned to the command line.
function varargout = FLIM_processing_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;
%% Get the NADH Image Button
% — Executes on button press in pushbutton1.
function read_NADH_intensity_Callback(~, ~, 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)
global nadhTextImage;
global maskShowImage;
global nadhImageName;
global nadhFileName;
global nadhPathName;
% Get the location of the image
[nadhFileName, nadhPathName] = uigetfile(‘*.asc’,’Pick an Image’);
nadhTextImage = importdata(strcat(nadhPathName,nadhFileName));
nadhTextImage(nadhTextImage > 1000) = 0;
nadhTextImage(:,245:256)=0;
maskShowImage = nadhTextImage;
nadhImageName = {nadhFileName,’NADH’};
% display the NADH image in axes1
maxIntensityValue = max(nadhTextImage(:));
minIntensityValue = min(nadhTextImage(:));
set(handles.slider3,’Max’,maxIntensityValue);
set(handles.slider3,’Min’,minIntensityValue);
set(handles.text19,’String’,num2str(minIntensityValue));
set(handles.text20,’String’,num2str(maxIntensityValue));
set(handles.text23,’String’,nadhFileName);
axes(handles.axes1);
imagesc(nadhTextImage)
colormap(gray)
colorbar
axes(handles.axes4);
imagesc(maskShowImage)
colormap(gray)
colorbar
%% Get the Mask Image Button
% — Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhTextImage;
global maskImage;
global nadhThreshold;
% get the image mask
maskImage = nadhTextImage;
nadhThreshold = get(handles.edit1,’String’);
nadhThreshold = str2double( nadhThreshold );
maskImage(maskImage < nadhThreshold) = 0;
maskImage(maskImage~=0) = 1;
% display the mask Image axes4
axes(handles.axes4);
imagesc(maskImage)
colormap(gray)
colorbar
%% read FAD intensity image
% — Executes on button press in readFADIntensity.
function read_FAD_intensity_Callback(hObject, eventdata, handles)
% hObject handle to readFADIntensity (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadTextImage
% Get the location of the image
global fadImageName;
global fadFileName;
global fadPathName;
[fadFileName, fadPathName] = uigetfile(‘*.asc’,’Pick an Image’);
fadImageName = {fadFileName,’FAD’};
fadTextImage = importdata(strcat(fadPathName,fadFileName));
fadTextImage(fadTextImage > 1000) = 0;
fadTextImage(:,245:256)=0;
% display the NADH image in axes1
set(handles.text24,’String’,fadFileName);
axes(handles.axes2);
imagesc(fadTextImage)
colormap(gray)
colorbar
%% Read NADH T1 Image
% — Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhT1Image;
% Get the location of the image
[nadhT1FileName, nadhT1PathName] = uigetfile(‘*.asc’,’Pick an Image’);
nadhT1Image = importdata(strcat(nadhT1PathName,nadhT1FileName));
nadhT1Image(nadhT1Image > 8000) = 0;
nadhT1Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes7);
imagesc(nadhT1Image)
colormap(gray)
colorbar
set(handles.text7 , ‘String’, nadhT1FileName);
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,’String’)) returns contents of edit1 as a double
% — Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
% — Executes during object deletion, before destroying properties.
function edit1_DeleteFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%% Calculate Redox Ratio Button
% — Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhTextImage;
global fadTextImage;
global redoxRatioImage;
redoxRatioImage = nadhTextImage./(nadhTextImage + fadTextImage);
axes(handles.axes6);
imagesc(redoxRatioImage)
colormap(gray)
colorbar
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (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 edit2 as text
% str2double(get(hObject,’String’)) returns contents of edit2 as a double
% — Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
% — Executes on button press in pushbutton6.
function pushbutton6_Callback(~, ~, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhTextImage;
global fadTextImage;
global redoxRatioImage;
global maskImage;
global redoxRatio;
nadhIntensityImage = nadhTextImage.* maskImage;
fadIntensityImage = fadTextImage.* maskImage;
axes(handles.axes1);
imagesc(nadhIntensityImage)
colormap(gray)
colorbar
axes(handles.axes2);
imagesc(fadIntensityImage)
colormap(gray)
colorbar
redoxRatioIntensityImage = redoxRatioImage.* maskImage;
axes(handles.axes6);
imagesc(redoxRatioIntensityImage)
colormap(gray)
colorbar
redoxRatio = mean(redoxRatioIntensityImage(redoxRatioIntensityImage~=0),’omitnan’);
set(handles.edit2 , ‘String’, num2str(redoxRatio));
%% Read NADH T2 Image and display
% — Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhT2Image;
% Get the location of the image
[nadhT2FileName, nadhT2PathName] = uigetfile(‘*.asc’,’Pick an Image’);
nadhT2Image = importdata(strcat(nadhT2PathName,nadhT2FileName));
nadhT2Image(nadhT2Image > 8000) = 0;
nadhT2Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes8);
imagesc(nadhT2Image)
colormap(gray)
colorbar
set(handles.text8 , ‘String’, nadhT2FileName);
%% Read NADH alpha Image and display
% — Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhAlphaImage;
% Get the location of the image
[nadhAlphaFileName, nadhAlphaPathName] = uigetfile(‘*.asc’,’Pick an Image’);
nadhAlphaImage = importdata(strcat(nadhAlphaPathName,nadhAlphaFileName));
nadhAlphaImage(nadhAlphaImage>100) = 0;
nadhAlphaImage(nadhAlphaImage<0) = 0;
nadhAlphaImage(:,245:256) = 0;
% display the NADH image in axes7 and show the image name
axes(handles.axes9);
imagesc(nadhAlphaImage)
colormap(gray)
colorbar
set(handles.text9 , ‘String’, nadhAlphaFileName);
%% Calculate NADH FLIM mean
% — Executes on button press in pushbutton9.
function pushbutton9_Callback(~, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhT1Image;
global nadhT2Image;
global nadhAlphaImage;
global maskImage;
global nadhT1Mean;
global nadhT2Mean;
global nadhAlphaMean;
global nadhFLIMMMean;
nadhFLIMMImage = (nadhT1Image.* nadhAlphaImage + nadhT2Image.*(100 – nadhAlphaImage))/100;
nadhFLIMMImageM = nadhFLIMMImage .* maskImage;
nadhAlphaImageM = nadhAlphaImage.* maskImage;
nadhT2ImageM = nadhT2Image .* maskImage;
nadhT1ImageM = nadhT1Image .* maskImage;
nadhAlphaMean = mean(nadhAlphaImageM(nadhAlphaImageM~=0),’omitnan’);
nadhT2Mean = mean(nadhT2ImageM(nadhT2ImageM~=0),’omitnan’);
nadhT1Mean = mean(nadhT1ImageM(nadhT1ImageM~=0),’omitnan’);
nadhFLIMMMean = mean(nadhFLIMMImageM(nadhFLIMMImageM~=0),’omitnan’);
set(handles.edit3 , ‘String’, num2str(nadhT1Mean));
set(handles.edit4 , ‘String’, num2str(nadhT2Mean));
set(handles.edit5 , ‘String’, num2str(nadhAlphaMean));
set(handles.edit6 , ‘String’, num2str(nadhFLIMMMean));
axes(handles.axes7);
imagesc(nadhT1ImageM)
colormap(gray)
colorbar
axes(handles.axes8);
imagesc(nadhT2ImageM)
colormap(gray)
colorbar
axes(handles.axes9);
imagesc(nadhAlphaImageM)
colormap(gray)
colorbar
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (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 edit3 as text
% str2double(get(hObject,’String’)) returns contents of edit3 as a double
% — Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit4_Callback(hObject, ~, handles)
% hObject handle to edit4 (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 edit4 as text
% str2double(get(hObject,’String’)) returns contents of edit4 as a double
% — Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (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 edit5 as text
% str2double(get(hObject,’String’)) returns contents of edit5 as a double
% — Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (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 edit6 as text
% str2double(get(hObject,’String’)) returns contents of edit6 as a double
% — Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
%% Read FAD T1 image and display
% — Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadT1Image;
% Get the location of the image
[fadT1FileName, fadT1PathName] = uigetfile(‘*.asc’,’Pick an Image’);
fadT1Image = importdata(strcat(fadT1PathName,fadT1FileName));
fadT1Image(fadT1Image > 8000) = 0;
fadT1Image(fadT1Image < 0) = 0;
fadT1Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes10);
imagesc(fadT1Image)
colormap(gray)
colorbar
set(handles.text10 , ‘String’, fadT1FileName);
% — Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, ~, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadT2Image;
% Get the location of the image
[fadT2FileName, fadT2PathName] = uigetfile(‘*.asc’,’Pick an Image’);
fadT2Image = importdata(strcat(fadT2PathName,fadT2FileName));
fadT2Image(fadT2Image>8000) = 0;
fadT2Image(fadT2Image < 0) = 0;
fadT2Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes11);
imagesc(fadT2Image)
colormap(gray)
colorbar
set(handles.text11 , ‘String’, fadT2FileName);
% — Executes on button press in pushbutton12.
function pushbutton12_Callback(~, ~, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadAlphaImage;
% Get the location of the image
[fadAplhaFileName, fadAlphaPathName] = uigetfile(‘*.asc’,’Pick an Image’);
fadAlphaImage = importdata(strcat(fadAlphaPathName,fadAplhaFileName));
fadAlphaImage(fadAlphaImage>100) = 0;
fadAlphaImage(fadAlphaImage<0) = 0;
fadAlphaImage(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes12);
imagesc(fadAlphaImage)
colormap(gray)
colorbar
set(handles.text12 , ‘String’, fadAplhaFileName);
% — Executes on button press in pushbutton13.
function pushbutton13_Callback(~, eventdata, handles)
% hObject handle to pushbutton13 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global fadT1Image;
global fadT2Image;
global fadAlphaImage;
global maskImage
global fadT1Mean;
global fadT2Mean;
global fadAlphaMean;
global fadFLIMMMean;
fadFLIMMImage = (fadT1Image.* fadAlphaImage + fadT2Image.*(100 – fadAlphaImage))/100;
fadFLIMMImageM = fadFLIMMImage .* maskImage;
fadAlphaImageM = fadAlphaImage.* maskImage;
fadT2ImageM = fadT2Image .* maskImage;
fadT1ImageM = fadT1Image .* maskImage;
fadAlphaMean = mean(fadAlphaImageM(fadAlphaImageM~=0),’omitnan’);
fadT2Mean = mean(fadT2ImageM(fadT2ImageM~=0),’omitnan’);
fadT1Mean = mean(fadT1ImageM(fadT1ImageM~=0),’omitnan’);
fadFLIMMMean = mean(fadFLIMMImageM(fadFLIMMImageM~=0),’omitnan’);
set(handles.edit7 , ‘String’, num2str(fadT1Mean));
set(handles.edit8 , ‘String’, num2str(fadT2Mean));
set(handles.edit9 , ‘String’, num2str(fadAlphaMean));
set(handles.edit10 , ‘String’, num2str(fadFLIMMMean));
axes(handles.axes10);
imagesc(fadT1ImageM)
colormap(gray)
colorbar
axes(handles.axes11);
imagesc(fadT2ImageM)
colormap(gray)
colorbar
axes(handles.axes12);
imagesc(fadAlphaImageM)
colormap(gray)
colorbar
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (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 edit7 as text
% str2double(get(hObject,’String’)) returns contents of edit7 as a double
% — Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit8_Callback(hObject, eventdata, handles)
% hObject handle to edit8 (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 edit8 as text
% str2double(get(hObject,’String’)) returns contents of edit8 as a double
% — Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit9_Callback(hObject, eventdata, handles)
% hObject handle to edit9 (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 edit9 as text
% str2double(get(hObject,’String’)) returns contents of edit9 as a double
% — Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit9 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit10_Callback(hObject, eventdata, handles)
% hObject handle to edit10 (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 edit10 as text
% str2double(get(hObject,’String’)) returns contents of edit10 as a double
% — Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit10 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit11_Callback(~, eventdata, handles)
% hObject handle to edit11 (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 edit11 as text
% str2double(get(hObject,’String’)) returns contents of edit11 as a double
% — Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit11 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit12_Callback(hObject, eventdata, handles)
% hObject handle to edit12 (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 edit12 as text
% str2double(get(hObject,’String’)) returns contents of edit12 as a double
% — Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit12 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
function edit13_Callback(hObject, eventdata, handles)
% hObject handle to edit13 (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 edit13 as text
% str2double(get(hObject,’String’)) returns contents of edit13 as a double
% — Executes during object creation, after setting all properties.
function edit13_CreateFcn(hObject, ~, handles)
% hObject handle to edit13 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
%% Select the file to save
% — Executes on button press in pushbutton15.
function pushbutton15_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton15 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global saveExcelLocation;
[saveExcelName, saveExcelPath] = uigetfile(‘*.xlsx’,’Pick an excel file’);
saveExcelLocation = strcat(saveExcelPath,saveExcelName);
set(handles.edit14 , ‘String’, saveExcelLocation);
function edit14_Callback(hObject, eventdata, handles)
% hObject handle to edit14 (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 edit14 as text
% str2double(get(hObject,’String’)) returns contents of edit14 as a double
% — Executes during object creation, after setting all properties.
function edit14_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit14 (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 && isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,’white’);
end
%% Save the data to the excel file
% — Executes on button press in pushbutton16.
function pushbutton16_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton16 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhT1Mean;
global nadhT2Mean;
global nadhAlphaMean;
global nadhFLIMMMean;
global fadT1Mean;
global fadT2Mean;
global fadAlphaMean;
global fadFLIMMMean;
global redoxRatio;
global nadhThreshold;
global saveExcelLocation;
global nadhImageName ;
global fadImageName;
nadhFlimData = [nadhThreshold,redoxRatio,nadhT1Mean,nadhT2Mean,nadhAlphaMean,nadhFLIMMMean];
fadFlimData = [fadT1Mean,fadT2Mean,fadAlphaMean,fadFLIMMMean];
excelData = xlsread(saveExcelLocation,’Sheet1′,’E:E’); % read the column of interest
lastRowNumber = length(excelData)+ 2;
nadhWriteLoc = strcat(‘C’,num2str(lastRowNumber));
nadhNameWriteLoc = strcat(‘A’,num2str(lastRowNumber));
% save NADH data to the excel file
xlswrite(saveExcelLocation,nadhFlimData,’sheet1′,nadhWriteLoc);
xlswrite(saveExcelLocation,nadhImageName,’sheet1′,nadhNameWriteLoc);
% save FAD data to the excel file
lastRowNumber = lastRowNumber + 1;
fadWriteLoc = strcat(‘E’,num2str(lastRowNumber));
fadNameWriteLoc = strcat(‘A’,num2str(lastRowNumber));
xlswrite(saveExcelLocation,fadFlimData,’sheet1′,fadWriteLoc);
xlswrite(saveExcelLocation,fadImageName,’sheet1′,fadNameWriteLoc);
% — Executes on slider movement.
function slider3_Callback(hObject, eventdata, handles)
% hObject handle to slider3 (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,’Value’) returns position of slider
% get(hObject,’Min’) and get(hObject,’Max’) to determine range of slider
global nadhThreshold;
global maskShowImage;
global nadhTextImage
nadhThreshold = get(handles.slider3 ,’Value’);
% get the image mask
maskShowImage = nadhTextImage;
maskShowImage(maskShowImage < nadhThreshold) = 0;
set(handles.edit1 , ‘String’, num2str(nadhThreshold));
axes(handles.axes4);
imagesc(maskShowImage)
colormap(gray)
colorbar
% — Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider3 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,[.9 .9 .9]);
end
function slider3_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider3 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles empty – handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,’BackgroundColor’), get(0,’defaultUicontrolBackgroundColor’))
set(hObject,’BackgroundColor’,[.9 .9 .9]);
end
% — Executes on button press in pushbutton17.
function pushbutton17_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton17 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global nadhFileName;
global nadhPathName;
global nadhT1Image;
% Get the location of the image
nadhT1FileName = strrep(nadhFileName,’photons’,’t1′);
nadhT1PathName = nadhPathName;
nadhT1Image = importdata(strcat(nadhT1PathName,nadhT1FileName));
nadhT1Image(nadhT1Image > 8000) = 0;
nadhT1Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes7);
imagesc(nadhT1Image)
colormap(gray)
colorbar
set(handles.text7 , ‘String’, nadhT1FileName);
global nadhT2Image;
% Get the location of the image
nadhT2FileName = strrep(nadhFileName,’photons’,’t2′);
nadhT2PathName = nadhPathName;
nadhT2Image = importdata(strcat(nadhT2PathName,nadhT2FileName));
nadhT2Image(nadhT2Image > 8000) = 0;
nadhT2Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes8);
imagesc(nadhT2Image)
colormap(gray)
colorbar
set(handles.text8 , ‘String’, nadhT2FileName);
global nadhAlphaImage;
% Get the location of the image
nadhAlphaFileName = strrep(nadhFileName,’photons’,’a1[%]’);
nadhAlphaPathName = nadhPathName;
nadhAlphaImage = importdata(strcat(nadhAlphaPathName,nadhAlphaFileName));
nadhAlphaImage(nadhAlphaImage>100) = 0;
nadhAlphaImage(nadhAlphaImage<0) = 0;
nadhAlphaImage(:,245:256) = 0;
% display the NADH image in axes7 and show the image name
axes(handles.axes9);
imagesc(nadhAlphaImage)
colormap(gray)
colorbar
set(handles.text9 , ‘String’, nadhAlphaFileName);
global fadFileName;
global fadPathName;
global fadT1Image;
% Get the location of the image
fadT1FileName = strrep(fadFileName,’photons’,’t1′);
fadT1PathName = fadPathName;
fadT1Image = importdata(strcat(fadT1PathName,fadT1FileName));
fadT1Image(fadT1Image > 8000) = 0;
fadT1Image(fadT1Image < 0) = 0;
fadT1Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes10);
imagesc(fadT1Image)
colormap(gray)
colorbar
set(handles.text10 , ‘String’, fadT1FileName);
global fadT2Image;
% Get the location of the image
fadT2FileName = strrep(fadFileName,’photons’,’t2′);
fadT2PathName = fadPathName;
fadT2Image = importdata(strcat(fadT2PathName,fadT2FileName));
fadT2Image(fadT2Image>8000) = 0;
fadT2Image(fadT2Image < 0) = 0;
fadT2Image(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes11);
imagesc(fadT2Image)
colormap(gray)
colorbar
set(handles.text11 , ‘String’, fadT2FileName)
global fadAlphaImage;
% Get the location of the image
fadAplhaFileName = strrep(fadFileName,’photons’,’a1[%]’);
fadAlphaPathName = fadPathName;
fadAlphaImage = importdata(strcat(fadAlphaPathName,fadAplhaFileName));
fadAlphaImage(fadAlphaImage>100) = 0;
fadAlphaImage(fadAlphaImage<0) = 0;
fadAlphaImage(:,245:256)=0;
% display the NADH image in axes7 and show the image name
axes(handles.axes12);
imagesc(fadAlphaImage)
colormap(gray)
colorbar
set(handles.text12 , ‘String’, fadAplhaFileName); hobject, eventdata, handles MATLAB Answers — New Questions
Why am I getting different outputs between Matlab & SPSS?
I am running a 3-way mixed ANOVA (2*6*2).
The between variable is Consciousness with 2 levels (conscious/ subconscious)
The within variables are: Congruency with 6 levels (RH, RF, UH, UF, NH, NF) & Target with 2 levels (BodyPart, Object).
I have run this in Matlab and had assumed I had generated the correct output, Code:
%Within Design Table
WithinDesign=table(categorical({‘Related Hand’,’Related Foot’,’Unrelated Hand’,’Unrelated Foot’,’Neutral Hand’,’Neutral Foot’,’Related Hand’,’Related Foot’,’Unrelated Hand’,’Unrelated Foot’,’Neutral Hand’,’Neutral Foot’}’),categorical({‘BP’,’BP’,’BP’,’BP’,’BP’,’BP’,’O’,’O’,’O’,’O’,’O’,’O’}’),’VariableNames’,{‘Congruency’,’Target’});
%%
%3-Way Mixed Anova
OverallMixedANOVA=fitrm(OverallDataTable,’BP_RH_Con-O_NF_Sub~Consciousness’,WithinDesign=WithinDesign,WithinModel=’separatemeans’);
%Sphericity Calculation & Error Correction
OverallSphericity=mauchly(OverallMixedANOVA)
OverallErrorCorrect=epsilon(OverallMixedANOVA)
%Anova Table output
[OverallMixedANOVATable,A,C,D]=ranova(OverallMixedANOVA,"WithinModel",’Congruency*Target’)
%Corrections for significant sphericity
%CorrectedOverallMixedANOVATable=OverallMixedANOVATable;
%CorrectedOverallMixedANOVATable.DF=OverallMixedANOVATable.DF*OverallErrorCorrect.GreenhouseGeisser
Below is the Matlab Output:
The same data was used in SPSS to check my code. For all previous (2-way RM-) ANOVAs I have performed on Matlab the output has been the same, but in this case the output was different.
Here is the SPSS code pasted to the log:
GLM BP_RH O_RH BP_RF O_RF BP_UH O_UH BP_UF O_UF BP_NH O_NH BP_NF O_NF BY Consciousness
/WSFACTOR=Congruency 6 Polynomial Target 2 Polynomial
/MEASURE=Tradeoff
/METHOD=SSTYPE(3)
/PRINT=DESCRIPTIVE ETASQ OPOWER HOMOGENEITY
/CRITERIA=ALPHA(.05)
/WSDESIGN=Congruency Target Congruency*Target
/DESIGN=Consciousness.
Output from SPSS pasted below:
Different values are highlighted in blue.
I’d like to know why I am getting different values. I know that the p values are still signficant for both methods of analysis, but when looking for replicability this doesnt seem to be satisfactory.
My Questions are:
Have I input the factors correctly in the Matlab code?
Why are the values different between the two softwares?
Does it matter that Matlab and SPSS generate different statistics?
Do you have any reccomendations for what I can do to improve my code?
Thanks in advanceI am running a 3-way mixed ANOVA (2*6*2).
The between variable is Consciousness with 2 levels (conscious/ subconscious)
The within variables are: Congruency with 6 levels (RH, RF, UH, UF, NH, NF) & Target with 2 levels (BodyPart, Object).
I have run this in Matlab and had assumed I had generated the correct output, Code:
%Within Design Table
WithinDesign=table(categorical({‘Related Hand’,’Related Foot’,’Unrelated Hand’,’Unrelated Foot’,’Neutral Hand’,’Neutral Foot’,’Related Hand’,’Related Foot’,’Unrelated Hand’,’Unrelated Foot’,’Neutral Hand’,’Neutral Foot’}’),categorical({‘BP’,’BP’,’BP’,’BP’,’BP’,’BP’,’O’,’O’,’O’,’O’,’O’,’O’}’),’VariableNames’,{‘Congruency’,’Target’});
%%
%3-Way Mixed Anova
OverallMixedANOVA=fitrm(OverallDataTable,’BP_RH_Con-O_NF_Sub~Consciousness’,WithinDesign=WithinDesign,WithinModel=’separatemeans’);
%Sphericity Calculation & Error Correction
OverallSphericity=mauchly(OverallMixedANOVA)
OverallErrorCorrect=epsilon(OverallMixedANOVA)
%Anova Table output
[OverallMixedANOVATable,A,C,D]=ranova(OverallMixedANOVA,"WithinModel",’Congruency*Target’)
%Corrections for significant sphericity
%CorrectedOverallMixedANOVATable=OverallMixedANOVATable;
%CorrectedOverallMixedANOVATable.DF=OverallMixedANOVATable.DF*OverallErrorCorrect.GreenhouseGeisser
Below is the Matlab Output:
The same data was used in SPSS to check my code. For all previous (2-way RM-) ANOVAs I have performed on Matlab the output has been the same, but in this case the output was different.
Here is the SPSS code pasted to the log:
GLM BP_RH O_RH BP_RF O_RF BP_UH O_UH BP_UF O_UF BP_NH O_NH BP_NF O_NF BY Consciousness
/WSFACTOR=Congruency 6 Polynomial Target 2 Polynomial
/MEASURE=Tradeoff
/METHOD=SSTYPE(3)
/PRINT=DESCRIPTIVE ETASQ OPOWER HOMOGENEITY
/CRITERIA=ALPHA(.05)
/WSDESIGN=Congruency Target Congruency*Target
/DESIGN=Consciousness.
Output from SPSS pasted below:
Different values are highlighted in blue.
I’d like to know why I am getting different values. I know that the p values are still signficant for both methods of analysis, but when looking for replicability this doesnt seem to be satisfactory.
My Questions are:
Have I input the factors correctly in the Matlab code?
Why are the values different between the two softwares?
Does it matter that Matlab and SPSS generate different statistics?
Do you have any reccomendations for what I can do to improve my code?
Thanks in advance I am running a 3-way mixed ANOVA (2*6*2).
The between variable is Consciousness with 2 levels (conscious/ subconscious)
The within variables are: Congruency with 6 levels (RH, RF, UH, UF, NH, NF) & Target with 2 levels (BodyPart, Object).
I have run this in Matlab and had assumed I had generated the correct output, Code:
%Within Design Table
WithinDesign=table(categorical({‘Related Hand’,’Related Foot’,’Unrelated Hand’,’Unrelated Foot’,’Neutral Hand’,’Neutral Foot’,’Related Hand’,’Related Foot’,’Unrelated Hand’,’Unrelated Foot’,’Neutral Hand’,’Neutral Foot’}’),categorical({‘BP’,’BP’,’BP’,’BP’,’BP’,’BP’,’O’,’O’,’O’,’O’,’O’,’O’}’),’VariableNames’,{‘Congruency’,’Target’});
%%
%3-Way Mixed Anova
OverallMixedANOVA=fitrm(OverallDataTable,’BP_RH_Con-O_NF_Sub~Consciousness’,WithinDesign=WithinDesign,WithinModel=’separatemeans’);
%Sphericity Calculation & Error Correction
OverallSphericity=mauchly(OverallMixedANOVA)
OverallErrorCorrect=epsilon(OverallMixedANOVA)
%Anova Table output
[OverallMixedANOVATable,A,C,D]=ranova(OverallMixedANOVA,"WithinModel",’Congruency*Target’)
%Corrections for significant sphericity
%CorrectedOverallMixedANOVATable=OverallMixedANOVATable;
%CorrectedOverallMixedANOVATable.DF=OverallMixedANOVATable.DF*OverallErrorCorrect.GreenhouseGeisser
Below is the Matlab Output:
The same data was used in SPSS to check my code. For all previous (2-way RM-) ANOVAs I have performed on Matlab the output has been the same, but in this case the output was different.
Here is the SPSS code pasted to the log:
GLM BP_RH O_RH BP_RF O_RF BP_UH O_UH BP_UF O_UF BP_NH O_NH BP_NF O_NF BY Consciousness
/WSFACTOR=Congruency 6 Polynomial Target 2 Polynomial
/MEASURE=Tradeoff
/METHOD=SSTYPE(3)
/PRINT=DESCRIPTIVE ETASQ OPOWER HOMOGENEITY
/CRITERIA=ALPHA(.05)
/WSDESIGN=Congruency Target Congruency*Target
/DESIGN=Consciousness.
Output from SPSS pasted below:
Different values are highlighted in blue.
I’d like to know why I am getting different values. I know that the p values are still signficant for both methods of analysis, but when looking for replicability this doesnt seem to be satisfactory.
My Questions are:
Have I input the factors correctly in the Matlab code?
Why are the values different between the two softwares?
Does it matter that Matlab and SPSS generate different statistics?
Do you have any reccomendations for what I can do to improve my code?
Thanks in advance statistics, software differences MATLAB Answers — New Questions
Undocked Editor, ctrl+shift+0 doesn’t bring editor to front as active window
Hello,
I run a X11 forwarded instance of matlab 2017b (ran from a linux server) with a tabbed, undocked, editor on a windows machine. I love motion binds (vim user btw), and I often jump between the command window and editor with ctrl+0, ctrl+shift+0 respectfully.
I noticed that the undocked editor is not brought to the front as my active window despite my cursor being in that window and can still type. I then windows alt-tab to the editor to bring the window to the front and loose my cursor…. making me regrettably pick up my mouse.
Ex. I have a chat client open over my editor on my right monitor and I am working in the command window on my left monitor. I then open a script or ctrl+shift+0 over to the editor and the editor window is not brought to the front of the chat client.
Any Ideas on how I can tweak these settings to bring to front via matlab keybind? (Looking into X11 settings currently)Hello,
I run a X11 forwarded instance of matlab 2017b (ran from a linux server) with a tabbed, undocked, editor on a windows machine. I love motion binds (vim user btw), and I often jump between the command window and editor with ctrl+0, ctrl+shift+0 respectfully.
I noticed that the undocked editor is not brought to the front as my active window despite my cursor being in that window and can still type. I then windows alt-tab to the editor to bring the window to the front and loose my cursor…. making me regrettably pick up my mouse.
Ex. I have a chat client open over my editor on my right monitor and I am working in the command window on my left monitor. I then open a script or ctrl+shift+0 over to the editor and the editor window is not brought to the front of the chat client.
Any Ideas on how I can tweak these settings to bring to front via matlab keybind? (Looking into X11 settings currently) Hello,
I run a X11 forwarded instance of matlab 2017b (ran from a linux server) with a tabbed, undocked, editor on a windows machine. I love motion binds (vim user btw), and I often jump between the command window and editor with ctrl+0, ctrl+shift+0 respectfully.
I noticed that the undocked editor is not brought to the front as my active window despite my cursor being in that window and can still type. I then windows alt-tab to the editor to bring the window to the front and loose my cursor…. making me regrettably pick up my mouse.
Ex. I have a chat client open over my editor on my right monitor and I am working in the command window on my left monitor. I then open a script or ctrl+shift+0 over to the editor and the editor window is not brought to the front of the chat client.
Any Ideas on how I can tweak these settings to bring to front via matlab keybind? (Looking into X11 settings currently) editor, x11, ctrl+shift+0, keybind, window management MATLAB Answers — New Questions
Is it possible to have multiple releases of MATLAB and/or Polyspace on the same computer?
Is it possible to have multiple releases of MATLAB and/or Polyspace on the same computer?Is it possible to have multiple releases of MATLAB and/or Polyspace on the same computer? Is it possible to have multiple releases of MATLAB and/or Polyspace on the same computer? MATLAB Answers — New Questions
Maximum variable size allowed by the program is exceeded.
i have this problem
how can i resolve it plz !i have this problem
how can i resolve it plz ! i have this problem
how can i resolve it plz ! #variable, #size, matlab MATLAB Answers — New Questions
How does dlgradient handle two output layers?
I have a deep learning image analysis network with a custom training loop and loss function. In this loss function I take the output layer’s output and the second to last layer’s output from the net, perform mse (using the inbuilt function) on both, and sum the results. My output layer is a custom layer, so I have control over it’s backwards function, but I cannot see the automatic backwards in the other layers.
When I use dlgradient on this new loss, how does Matlab handle two simultaneous rounds of differentiation? Does it sum the gradients for each learnable, or does one gradient calculation override the other?
I have tried both adam and SGDM methods of updating gradients, but I am suspecting since my network is not learning as expected that I need to adjust my backwards function in my custom layer to ensure a proper gradient backpropagation.I have a deep learning image analysis network with a custom training loop and loss function. In this loss function I take the output layer’s output and the second to last layer’s output from the net, perform mse (using the inbuilt function) on both, and sum the results. My output layer is a custom layer, so I have control over it’s backwards function, but I cannot see the automatic backwards in the other layers.
When I use dlgradient on this new loss, how does Matlab handle two simultaneous rounds of differentiation? Does it sum the gradients for each learnable, or does one gradient calculation override the other?
I have tried both adam and SGDM methods of updating gradients, but I am suspecting since my network is not learning as expected that I need to adjust my backwards function in my custom layer to ensure a proper gradient backpropagation. I have a deep learning image analysis network with a custom training loop and loss function. In this loss function I take the output layer’s output and the second to last layer’s output from the net, perform mse (using the inbuilt function) on both, and sum the results. My output layer is a custom layer, so I have control over it’s backwards function, but I cannot see the automatic backwards in the other layers.
When I use dlgradient on this new loss, how does Matlab handle two simultaneous rounds of differentiation? Does it sum the gradients for each learnable, or does one gradient calculation override the other?
I have tried both adam and SGDM methods of updating gradients, but I am suspecting since my network is not learning as expected that I need to adjust my backwards function in my custom layer to ensure a proper gradient backpropagation. deep learning, neural network MATLAB Answers — New Questions
Replace NaN’s in table with zero
Hello, I have a 1501×7 table called ‘x’ and there appears to be NaN’s in the fourth and sixth column called "Age" and "height". I would like a way to replace NaN’s with zeros. Take note, that I have already tried:
k = find(isnan(x))’;
x(k) = 0;
% and
x(isnan(x)) = 0;
Yet, neither work because I am using a table, not a matrix. I have also tried converting my table into a cell array, and using these same functions, but they still do not work. They return:"Undefined function ‘isnan’ for input arguments of type ‘cell’"
ALSO, please note that the table has columns full of text. So, cell2mat does not work.Hello, I have a 1501×7 table called ‘x’ and there appears to be NaN’s in the fourth and sixth column called "Age" and "height". I would like a way to replace NaN’s with zeros. Take note, that I have already tried:
k = find(isnan(x))’;
x(k) = 0;
% and
x(isnan(x)) = 0;
Yet, neither work because I am using a table, not a matrix. I have also tried converting my table into a cell array, and using these same functions, but they still do not work. They return:"Undefined function ‘isnan’ for input arguments of type ‘cell’"
ALSO, please note that the table has columns full of text. So, cell2mat does not work. Hello, I have a 1501×7 table called ‘x’ and there appears to be NaN’s in the fourth and sixth column called "Age" and "height". I would like a way to replace NaN’s with zeros. Take note, that I have already tried:
k = find(isnan(x))’;
x(k) = 0;
% and
x(isnan(x)) = 0;
Yet, neither work because I am using a table, not a matrix. I have also tried converting my table into a cell array, and using these same functions, but they still do not work. They return:"Undefined function ‘isnan’ for input arguments of type ‘cell’"
ALSO, please note that the table has columns full of text. So, cell2mat does not work. nan, zeros, replace, matrix, cell, basic, beginner, replacement, remove, tables, format MATLAB Answers — New Questions
uigetfile MultiSelect does not work on Mac?
I use uigetfile with MultiSelect on in my code. It works fine on a PC but doesn’t allow selecting multiple files on a Mac. Is multiselect supported on Mac?
Here’s my code:
[file_list,PathName] = uigetfile(‘*.tif’,’Select the source images’,’MultiSelect’,’on’);I use uigetfile with MultiSelect on in my code. It works fine on a PC but doesn’t allow selecting multiple files on a Mac. Is multiselect supported on Mac?
Here’s my code:
[file_list,PathName] = uigetfile(‘*.tif’,’Select the source images’,’MultiSelect’,’on’); I use uigetfile with MultiSelect on in my code. It works fine on a PC but doesn’t allow selecting multiple files on a Mac. Is multiselect supported on Mac?
Here’s my code:
[file_list,PathName] = uigetfile(‘*.tif’,’Select the source images’,’MultiSelect’,’on’); uigetfile, multiselect, mac MATLAB Answers — New Questions
Adjusting table columns by a grouped value
When working with my dataset, I find that I need to adjust the data in ways that makes the plots more understandable. In this particular example, I’m trying to adjust the times in a table by finding the minimum value for every run, then subtracting the minimum value to every run so that each run in my dataset all start at t=0 on a plot.
I can find the mimium value, and have created a table with those values, however I am not sure how to apply these values to the main table, so that I can create an additional column with the adjusted time. I believe it has something to do with rowfun, but I can’t figure out how to get around the different sizes of the rows to get a proper calculation. I will be adding what I have so far in an attachment. Thank you.When working with my dataset, I find that I need to adjust the data in ways that makes the plots more understandable. In this particular example, I’m trying to adjust the times in a table by finding the minimum value for every run, then subtracting the minimum value to every run so that each run in my dataset all start at t=0 on a plot.
I can find the mimium value, and have created a table with those values, however I am not sure how to apply these values to the main table, so that I can create an additional column with the adjusted time. I believe it has something to do with rowfun, but I can’t figure out how to get around the different sizes of the rows to get a proper calculation. I will be adding what I have so far in an attachment. Thank you. When working with my dataset, I find that I need to adjust the data in ways that makes the plots more understandable. In this particular example, I’m trying to adjust the times in a table by finding the minimum value for every run, then subtracting the minimum value to every run so that each run in my dataset all start at t=0 on a plot.
I can find the mimium value, and have created a table with those values, however I am not sure how to apply these values to the main table, so that I can create an additional column with the adjusted time. I believe it has something to do with rowfun, but I can’t figure out how to get around the different sizes of the rows to get a proper calculation. I will be adding what I have so far in an attachment. Thank you. table, rowfun, groups, plot MATLAB Answers — New Questions
Variable Window Not Updating Automatically when code is executed
When I run some code which changes the contents of a class in my workspace, that change isn’t showing in the variables window unless I close this property and re-open it in the variables window. As you can see, when I quirry what this value is in the command prompt, I see that it doesn’t match the varibles window.
How is the "variables window" getting updated? Are there some settings in Matlab to adjust if the variables window automatically updates itselft on a perioidic basis, like once every 500mS or something? I don’t recall ever experiencing this before.
Please note that this array that I am looking at in the screenshot below, is an array of an enumeration class, where ‘SK1’ in the command window corelates to 1.0000 in the variables window.When I run some code which changes the contents of a class in my workspace, that change isn’t showing in the variables window unless I close this property and re-open it in the variables window. As you can see, when I quirry what this value is in the command prompt, I see that it doesn’t match the varibles window.
How is the "variables window" getting updated? Are there some settings in Matlab to adjust if the variables window automatically updates itselft on a perioidic basis, like once every 500mS or something? I don’t recall ever experiencing this before.
Please note that this array that I am looking at in the screenshot below, is an array of an enumeration class, where ‘SK1’ in the command window corelates to 1.0000 in the variables window. When I run some code which changes the contents of a class in my workspace, that change isn’t showing in the variables window unless I close this property and re-open it in the variables window. As you can see, when I quirry what this value is in the command prompt, I see that it doesn’t match the varibles window.
How is the "variables window" getting updated? Are there some settings in Matlab to adjust if the variables window automatically updates itselft on a perioidic basis, like once every 500mS or something? I don’t recall ever experiencing this before.
Please note that this array that I am looking at in the screenshot below, is an array of an enumeration class, where ‘SK1’ in the command window corelates to 1.0000 in the variables window. matlab, new desktop, variables window, enumeration MATLAB Answers — New Questions
Resolving array indices must be positive integers or logical values error?
I am running this piece of code:
fold_name=pwd; a=regexp(fold_name,’/’); fold_name=fold_name(a(end)+1:end);
my pwd is the following: ‘C:testsamples’
when running the first two pieces of code, I do not get any error. When running the third piece I get this error:
"Array indices must be positive integers or logical values."
Any ideas as to why?I am running this piece of code:
fold_name=pwd; a=regexp(fold_name,’/’); fold_name=fold_name(a(end)+1:end);
my pwd is the following: ‘C:testsamples’
when running the first two pieces of code, I do not get any error. When running the third piece I get this error:
"Array indices must be positive integers or logical values."
Any ideas as to why? I am running this piece of code:
fold_name=pwd; a=regexp(fold_name,’/’); fold_name=fold_name(a(end)+1:end);
my pwd is the following: ‘C:testsamples’
when running the first two pieces of code, I do not get any error. When running the third piece I get this error:
"Array indices must be positive integers or logical values."
Any ideas as to why? matlab, array MATLAB Answers — New Questions
Betweenness Centrality for a vertices in an adjacency matrix
Hello,
I’m trying to calculate the betweenness centrality for all nodes in an adjacency matrix. It is a weighted network. As far as I know, the Input should be the distance matrix which I have obtained from the adjacency matrix.
Then, I found the following code:
http://www.mathworks.com/matlabcentral/fileexchange/10922-matlabbgl/content/matlab_bgl/betweenness_centrality.m
I’m not 100% sure, but I think that this is my solution. However, I’m still new to MatLab and can’t get the code running.
I read some questions about varargin, but I still don’t know what I need to put in here and what is meant by "set_matlab_bgl_options
% for the standard options."
Any help is highly appreciated. I’m currently writing my thesis and desperately need betweenness scores for my network 🙂
Thanks a lot!!!Hello,
I’m trying to calculate the betweenness centrality for all nodes in an adjacency matrix. It is a weighted network. As far as I know, the Input should be the distance matrix which I have obtained from the adjacency matrix.
Then, I found the following code:
http://www.mathworks.com/matlabcentral/fileexchange/10922-matlabbgl/content/matlab_bgl/betweenness_centrality.m
I’m not 100% sure, but I think that this is my solution. However, I’m still new to MatLab and can’t get the code running.
I read some questions about varargin, but I still don’t know what I need to put in here and what is meant by "set_matlab_bgl_options
% for the standard options."
Any help is highly appreciated. I’m currently writing my thesis and desperately need betweenness scores for my network 🙂
Thanks a lot!!! Hello,
I’m trying to calculate the betweenness centrality for all nodes in an adjacency matrix. It is a weighted network. As far as I know, the Input should be the distance matrix which I have obtained from the adjacency matrix.
Then, I found the following code:
http://www.mathworks.com/matlabcentral/fileexchange/10922-matlabbgl/content/matlab_bgl/betweenness_centrality.m
I’m not 100% sure, but I think that this is my solution. However, I’m still new to MatLab and can’t get the code running.
I read some questions about varargin, but I still don’t know what I need to put in here and what is meant by "set_matlab_bgl_options
% for the standard options."
Any help is highly appreciated. I’m currently writing my thesis and desperately need betweenness scores for my network 🙂
Thanks a lot!!! betweenness, graph theory MATLAB Answers — New Questions
How to create a degradation feature profile from available sensor data?
I have gathered sensor data. Now I want to derive degradation feature profile for my data to perform RUL estimation using exponential degradation model. The main reason behind using this model is that I have threshold values, but no run-to-failure data.I have gathered sensor data. Now I want to derive degradation feature profile for my data to perform RUL estimation using exponential degradation model. The main reason behind using this model is that I have threshold values, but no run-to-failure data. I have gathered sensor data. Now I want to derive degradation feature profile for my data to perform RUL estimation using exponential degradation model. The main reason behind using this model is that I have threshold values, but no run-to-failure data. predictive maintenance, rul, degradation models, condition monitoring MATLAB Answers — New Questions
UNDISTORT STEREO Images before RECTIFICATION ?
This is a query reg. Stereo Rectification using Matlab inbuilt functions
Does one need to :
UNDISTORT the STEREO Images before RECTIFICATION ?
My pair of views are near-perfect, but has large disparity.
Using stereo-Calibration, I get the distortion parameters as (given below for only one of the cameras):
RadialDistortion:
[-0.163 0.0958]
TangentialDistortion:
~ [ 0, 0];
Skew: -0.600.
The 3D back-projected results appear OK, but I am looking for high accuracy. Hence the query.
Any useful advise will be beneficial (thanx in advance, for that)This is a query reg. Stereo Rectification using Matlab inbuilt functions
Does one need to :
UNDISTORT the STEREO Images before RECTIFICATION ?
My pair of views are near-perfect, but has large disparity.
Using stereo-Calibration, I get the distortion parameters as (given below for only one of the cameras):
RadialDistortion:
[-0.163 0.0958]
TangentialDistortion:
~ [ 0, 0];
Skew: -0.600.
The 3D back-projected results appear OK, but I am looking for high accuracy. Hence the query.
Any useful advise will be beneficial (thanx in advance, for that) This is a query reg. Stereo Rectification using Matlab inbuilt functions
Does one need to :
UNDISTORT the STEREO Images before RECTIFICATION ?
My pair of views are near-perfect, but has large disparity.
Using stereo-Calibration, I get the distortion parameters as (given below for only one of the cameras):
RadialDistortion:
[-0.163 0.0958]
TangentialDistortion:
~ [ 0, 0];
Skew: -0.600.
The 3D back-projected results appear OK, but I am looking for high accuracy. Hence the query.
Any useful advise will be beneficial (thanx in advance, for that) transferred, stereo MATLAB Answers — New Questions
how to extract the learned features from a dlnetwork
I wanted to extract the feature vector of training and testing data from a dlnetwork by using the activations and forward functions, matlab show me this error with any format of training and testing data, Incorrect number or types of inputs or outputs for function activations or forward function.
featureSet = forward(net,trainData,net.Layers(181).Name,’OutputAs’,’columns’);
featureSet = activations(net,dltrainData,net.Layers(181).Name);
is there another running instruction with another format of training and testing dataI wanted to extract the feature vector of training and testing data from a dlnetwork by using the activations and forward functions, matlab show me this error with any format of training and testing data, Incorrect number or types of inputs or outputs for function activations or forward function.
featureSet = forward(net,trainData,net.Layers(181).Name,’OutputAs’,’columns’);
featureSet = activations(net,dltrainData,net.Layers(181).Name);
is there another running instruction with another format of training and testing data I wanted to extract the feature vector of training and testing data from a dlnetwork by using the activations and forward functions, matlab show me this error with any format of training and testing data, Incorrect number or types of inputs or outputs for function activations or forward function.
featureSet = forward(net,trainData,net.Layers(181).Name,’OutputAs’,’columns’);
featureSet = activations(net,dltrainData,net.Layers(181).Name);
is there another running instruction with another format of training and testing data extracting features from a pretrained dlnetwork MATLAB Answers — New Questions
Why do I receive “(MLM) Not master server, checkout attempt of ‘MATLAB’ from user@host refused” in the license manager log file?
Clients are reporting they receive License Manager Error -18 when they try to start MATLAB, and I am seeing errors in the log file. Why do I receive "(MLM) Not master server, checkout attempt of ‘MATLAB’ from user@host refused" in the license manager log file?Clients are reporting they receive License Manager Error -18 when they try to start MATLAB, and I am seeing errors in the log file. Why do I receive "(MLM) Not master server, checkout attempt of ‘MATLAB’ from user@host refused" in the license manager log file? Clients are reporting they receive License Manager Error -18 when they try to start MATLAB, and I am seeing errors in the log file. Why do I receive "(MLM) Not master server, checkout attempt of ‘MATLAB’ from user@host refused" in the license manager log file? MATLAB Answers — New Questions