function varargout = JOVE_GUI3(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @JOVE_GUI3_OpeningFcn, ... 'gui_OutputFcn', @JOVE_GUI3_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end function JOVE_GUI3_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; addpath(genpath(fullfile(pwd,'Utilities'))); handles.W = realmax; handles.Step = realmax; handles.Boot = 10; handles.TC = {}; handles.TC_sub = {}; handles.CurrentState = []; handles.IsDataLoaded = 0; handles.StartTiming = 1; handles.EndTiming = 2; handles.ISFC = {}; handles.RefSize = 2; handles.SesInfo = []; handles.SN = ''; % Creates the session table (first, one row and only one value) set(handles.SesTable,'Data',{1}); set(handles.SesTable,'ColumnWidth',{10}); set(handles.GroupPlot,'XTick',[]); set(handles.GroupPlot,'YTick',[]); set(handles.GroupPlot,'Visible','off'); set(handles.GroupPlot,'Box','off'); guidata(hObject, handles); function varargout = JOVE_GUI3_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output; function WindowText_Callback(hObject, eventdata, handles) % If the high-pass takes a reasonable value, then we validate it if (~isempty(str2double(get(hObject,'String')))) && ... (str2double(get(hObject,'String')) > 1) && ... (str2double(get(hObject,'String')) < size(handles.TC{1},2)) handles.W = str2double(get(hObject,'String')); set(hObject,'BackgroundColor', [0.4 0.6 0.4]); else set(hObject,'BackgroundColor', [0.93 0.84 0.84]); end guidata(hObject,handles); function WindowText_CreateFcn(hObject, eventdata, handles) set(hObject,'String','Enter window size...'); set(hObject,'FontAngle','italic'); guidata(hObject,handles); function WindowText_ButtonDownFcn(hObject, eventdata, handles) set(hObject,'Enable','on'); set(hObject,'String',''); set(hObject,'FontAngle','normal'); uicontrol(hObject); guidata(hObject,handles); function BootText_Callback(hObject, eventdata, handles) % If the high-pass takes a reasonable value, then we validate it if (~isempty(str2double(get(hObject,'String')))) && ... (str2double(get(hObject,'String')) > 1) handles.Boot = str2double(get(hObject,'String')); set(hObject,'BackgroundColor', [0.4 0.6 0.4]); else set(hObject,'BackgroundColor', [0.93 0.84 0.84]); end guidata(hObject,handles); % --- Executes during object creation, after setting all properties. function BootText_CreateFcn(hObject, eventdata, handles) set(hObject,'String','Enter boot folds...'); set(hObject,'FontAngle','italic'); guidata(hObject,handles); function BootText_ButtonDownFcn(hObject, eventdata, handles) set(hObject,'Enable','on'); set(hObject,'String',''); set(hObject,'FontAngle','normal'); uicontrol(hObject); guidata(hObject,handles); function StepText_Callback(hObject, eventdata, handles) % If the high-pass takes a reasonable value, then we validate it if (~isempty(str2double(get(hObject,'String')))) && ... (str2double(get(hObject,'String')) >= 1) && ... (str2double(get(hObject,'String')) < size(handles.TC{1},2)) handles.Step = str2double(get(hObject,'String')); set(hObject,'BackgroundColor', [0.4 0.6 0.4]); else set(hObject,'BackgroundColor', [0.93 0.84 0.84]); end guidata(hObject,handles); function StepText_CreateFcn(hObject, eventdata, handles) set(hObject,'String','Enter step size...'); set(hObject,'FontAngle','italic'); guidata(hObject,handles); function StepText_ButtonDownFcn(hObject,eventdata,handles) set(hObject,'Enable','on'); set(hObject,'String',''); set(hObject,'FontAngle','normal'); uicontrol(hObject); guidata(hObject,handles); function StartText_Callback(hObject, eventdata, handles) if (~isempty(str2double(get(hObject,'String')))) && ... (str2double(get(hObject,'String')) >= 1) && ... (str2double(get(hObject,'String')) < size(handles.TC{1},2)) handles.StartTiming = str2double(get(hObject,'String')); set(hObject,'BackgroundColor', [0.4 0.6 0.4]); for s = 1:length(handles.TC_sub) handles.TC_sub{s} = handles.TC{s}(:,handles.StartTiming:handles.EndTiming); end else set(hObject,'BackgroundColor', [0.93 0.84 0.84]); end guidata(hObject,handles); % --- Executes during object creation, after setting all properties. function StartText_CreateFcn(hObject, eventdata, handles) set(hObject,'String','Enter start timing...'); set(hObject,'FontAngle','italic'); guidata(hObject,handles); function StartText_ButtonDownFcn(hObject, eventdata, handles) set(hObject,'Enable','on'); set(hObject,'String',''); set(hObject,'FontAngle','normal'); uicontrol(hObject); guidata(hObject,handles); function LoadButton_Callback(hObject, eventdata, handles) out_idx = []; % Selection of all the fMRI files [filename1,pathname1]=uigetfile({'*.*','All Files'},... 'Select fMRI files (NIFTI)...','MultiSelect','on'); % If the user has indeed entered files if ~isequal(filename1,0) || ~isequal(pathname1,0) % The files are loaded sequentially: File{t} contains the path % towards the t-th frame for s = 1:length(filename1) load((fullfile(pathname1, filename1{s}))); assignin('base','ToSave', ToSave); handles.TC{s} = ToSave; [~,idx_toremove] = RemoveNaNRegions(handles.TC{s}); out_idx = unique([out_idx,idx_toremove]); end for s = 1:length(filename1) handles.TC{s}(ismember(1:size(handles.TC{s},1),out_idx),:) = NaN; handles.TC_sub{s} = handles.TC{s}; end handles.IsDataLoaded = 1; end handles.EndTiming = size(handles.TC{1},2); handles.CurrentState = zeros(1,length(handles.TC)); n_rows = floor(length(handles.TC)/8); n_add = mod(length(handles.TC),8); if n_rows > 0 tmp_data = num2cell(zeros(n_rows+1,8)); for i = 1:n_rows for j = 1:8 tmp_data{i,j} = 1; end end end for a = 1:n_add tmp_data{n_rows+1,a} = 1; end set(handles.SesTable,'Data',tmp_data); % Plots the depiction of groups handles.GroupPlot = JOVE_PlotISFCGroups(handles.GroupPlot,handles.Boot,handles.CurrentState); guidata(hObject,handles); function PlotButton_Callback(hObject, eventdata, handles) % Gets session labels handles.SesInfo = cell2mat(get(handles.SesTable,'Data')); tmp_ses = handles.SesInfo'; tmp_ses = tmp_ses(:); tmp_ses(tmp_ses == 0) = []; handles.ISFC = JOVE_Perform_Bootstrapping(handles.TC_sub,tmp_ses,handles.W,handles.Step,handles.TR,handles.Boot,handles.RefSize,handles.GroupPlot,handles.ISFCPlot,hObject,handles); [tmp,IDX] = sort(sum(abs(handles.ISFC{1}),2),'descend'); IDX = IDX(~isnan(tmp)); try handles.ISFCPlot = JOVE_PlotAtlasTC(handles.ISFCPlot,handles.ISFC{1},IDX(1:50),'ISFC',handles.W,handles.Step,handles.TR); catch errordlg('No computation for your subject of interest; run again with larger boot number !'); end guidata(hObject,handles); function EndText_Callback(hObject, eventdata, handles) if (~isempty(str2double(get(hObject,'String')))) && ... (str2double(get(hObject,'String')) >= handles.StartTiming) && ... (str2double(get(hObject,'String')) <= size(handles.TC{1},2)) handles.EndTiming = str2double(get(hObject,'String')); set(hObject,'BackgroundColor', [0.4 0.6 0.4]); for s = 1:length(handles.TC_sub) handles.TC_sub{s} = handles.TC{s}(:,handles.StartTiming:handles.EndTiming); end else set(hObject,'BackgroundColor', [0.93 0.84 0.84]); end guidata(hObject,handles); % --- Executes during object creation, after setting all properties. function EndText_CreateFcn(hObject, eventdata, handles) set(hObject,'String','Enter end timing...'); set(hObject,'FontAngle','italic'); guidata(hObject,handles); function EndText_ButtonDownFcn(hObject, eventdata, handles) set(hObject,'Enable','on'); set(hObject,'String',''); set(hObject,'FontAngle','normal'); uicontrol(hObject); guidata(hObject,handles); function RefText_Callback(hObject, eventdata, handles) if (~isempty(str2double(get(hObject,'String')))) && ... (str2double(get(hObject,'String')) > 1) && ... (str2double(get(hObject,'String')) < length(handles.TC)) handles.RefSize = str2double(get(hObject,'String')); set(hObject,'BackgroundColor', [0.4 0.6 0.4]); else set(hObject,'BackgroundColor', [0.93 0.84 0.84]); end guidata(hObject,handles); function RefText_CreateFcn(hObject, eventdata, handles) set(hObject,'String','Enter ref. number...'); set(hObject,'FontAngle','italic'); guidata(hObject,handles); function RefText_ButtonDownFcn(hObject, eventdata, handles) set(hObject,'Enable','on'); set(hObject,'String',''); set(hObject,'FontAngle','normal'); uicontrol(hObject); guidata(hObject,handles); % --- Executes when entered data in editable cell(s) in SesTable. function SesTable_CellEditCallback(hObject, eventdata, handles) % hObject handle to SesTable (see GCBO) % eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE) % Indices: row and column indices of the cell(s) edited % PreviousData: previous data for the cell(s) edited % EditData: string(s) entered by the user % NewData: EditData or its converted form set on the Data property. Empty if Data was not changed % Error: error string when failed to convert EditData to appropriate value for Data % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------- function SesTable_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to SesTable (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes when selected cell(s) is changed in SesTable. function SesTable_CellSelectionCallback(hObject, eventdata, handles) % hObject handle to SesTable (see GCBO) % eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE) % Indices: row and column indices of the cell(s) currently selecteds % handles structure with handles and user data (see GUIDATA) function ClearButton_Callback(hObject, eventdata, handles) handles.W = realmax; handles.Step = realmax; handles.Boot = 10; handles.TC = {}; handles.TC_sub = {}; handles.CurrentState = []; handles.IsDataLoaded = 0; handles.StartTiming = 1; handles.EndTiming = 2; handles.ISFC = {}; handles.RefSize = 2; handles.SesInfo = []; handles.SN = ''; % Creates the session table (first, one row and only one value) set(handles.SesTable,'Data',{1}); set(handles.SesTable,'ColumnWidth',{10}); set(handles.GroupPlot,'XTick',[]); set(handles.GroupPlot,'YTick',[]); set(handles.GroupPlot,'Visible','off'); set(handles.GroupPlot,'Box','off'); set(handles.WindowText,'Enable','off'); set(handles.StepText,'Enable','off'); set(handles.TRText,'Enable','off'); set(handles.BootText,'Enable','off'); set(handles.RefText,'Enable','off'); set(handles.StartText,'Enable','off'); set(handles.EndText,'Enable','off'); set(handles.SaveText,'Enable','off'); set(handles.WindowText,'BackgroundColor',240/255*[1 1 1]); set(handles.StepText,'BackgroundColor',240/255*[1 1 1]); set(handles.TRText,'BackgroundColor',240/255*[1 1 1]); set(handles.BootText,'BackgroundColor',240/255*[1 1 1]); set(handles.RefText,'BackgroundColor',240/255*[1 1 1]); set(handles.StartText,'BackgroundColor',240/255*[1 1 1]); set(handles.EndText,'BackgroundColor',240/255*[1 1 1]); set(handles.SaveText,'BackgroundColor',240/255*[1 1 1]); WindowText_CreateFcn(handles.WindowText, eventdata, handles); StepText_CreateFcn(handles.StepText, eventdata, handles); TRText_CreateFcn(handles.TRText, eventdata, handles); BootText_CreateFcn(handles.BootText, eventdata, handles); RefText_CreateFcn(handles.RefText, eventdata, handles); StartText_CreateFcn(handles.StartText, eventdata, handles); EndText_CreateFcn(handles.EndText, eventdata, handles); SaveText_CreateFcn(handles.SaveText,eventdata,handles); cla(handles.GroupPlot); cla(handles.ISFCPlot); guidata(hObject, handles); function SaveButton_Callback(hObject, eventdata, handles) ISFC_Final = handles.ISFC; save(handles.SN,'ISFC_Final'); function SaveText_Callback(hObject, eventdata, handles) if (~isempty(get(hObject,'String'))) handles.SN = get(hObject,'String'); set(hObject,'BackgroundColor', [0.4 0.6 0.4]); else set(hObject,'BackgroundColor', [0.93 0.84 0.84]); end guidata(hObject,handles); function SaveText_CreateFcn(hObject, eventdata, handles) set(hObject,'String','Enter save name...'); set(hObject,'FontAngle','italic'); guidata(hObject,handles); function SaveText_ButtonDownFcn(hObject, eventdata, handles) set(hObject,'Enable','on'); set(hObject,'String',''); set(hObject,'FontAngle','normal'); uicontrol(hObject); guidata(hObject,handles); function TRText_Callback(hObject, eventdata, handles) % If the high-pass takes a reasonable value, then we validate it if (~isempty(str2double(get(hObject,'String')))) && ... (str2double(get(hObject,'String')) > 0) handles.TR = str2double(get(hObject,'String')); set(hObject,'BackgroundColor', [0.4 0.6 0.4]); else set(hObject,'BackgroundColor', [0.93 0.84 0.84]); end guidata(hObject,handles); function TRText_CreateFcn(hObject, eventdata, handles) set(hObject,'String','Enter TR...'); set(hObject,'FontAngle','italic'); guidata(hObject,handles); function TRText_ButtonDownFcn(hObject, eventdata, handles) set(hObject,'Enable','on'); set(hObject,'String',''); set(hObject,'FontAngle','normal'); uicontrol(hObject); guidata(hObject,handles);