function varargout = JOVE_GUI1(varargin) gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @JOVE_GUI1_OpeningFcn, ... 'gui_OutputFcn', @JOVE_GUI1_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 % --- Executes just before JOVE_GUI1 is made visible. function JOVE_GUI1_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; warning('off'); addpath(genpath(fullfile(pwd,'Utilities'))); handles.Data = []; handles.FuncLink = ''; handles.FuncFolder = ''; handles.c1 = []; handles.c2 = []; handles.c3 = []; handles.IsFuncLoaded = 0; handles.IsMotLoaded = 0; handles.IsStructLoaded = 0; handles.AreAllDataLoaded = 0; handles.TR = 1; handles.Mot = []; % Makes the plots as we want set(handles.CSFWMPlot,'Box','off'); set(handles.TransPlot,'Box','off'); set(handles.RotPlot,'Box','off'); set(handles.CSFWMPlot,'XTick',[]); set(handles.TransPlot,'XTick',[]); xlabel(handles.RotPlot,'Time [s]'); ylabel(handles.CSFWMPlot,'CSF/WM [a.u.]'); ylabel(handles.TransPlot,'Trans. [mm]'); ylabel(handles.RotPlot,'Rot. [deg]'); ylabel(handles.GMPlot,'GM voxels'); % Update handles structure guidata(hObject, handles); function varargout = JOVE_GUI1_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output; %% Data button: fMRI data function DataButton_Callback(hObject, eventdata, handles) % 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) tmp_idx = 1; % The files are loaded sequentially: File{t} contains the path % towards the t-th frame for t = 1:length(filename1) File{t} = fullfile(pathname1, filename1{t}); if strcmp(File{t}(end-2:end),'img') else % Reads the frame tmp_header = spm_vol(File{tmp_idx}); tmp = spm_read_vols(tmp_header); handles.Data(:,tmp_idx) = tmp(:); tmp_idx = tmp_idx + 1; end end % Link towards one of the functional files handles.FuncLink = fullfile(pathname1, filename1{t}); handles.FuncFolder = fullfile(pathname1); % Confirms that functional data has been loaded handles.IsFuncLoaded = 1; end guidata(hObject,handles); %% Data button: probabilistic tissue maps function DataButton2_Callback(hObject, eventdata, handles) % Selection of the file [filename2,pathname2]=uigetfile({'*.*','All Files'},... 'Select structural files...','MultiSelect','on'); % If the user has indeed entered files if ~isequal(filename2,0) || ~isequal(pathname2,0) if handles.IsFuncLoaded == 1 % Probabilistic tissue maps are binarized to be able to compute WM % and CSF regressors, as well as global signal handles.c1 = mapVolumeToVolume(fullfile(pathname2, filename2{1}),handles.FuncLink); handles.c1(handles.c1 < 0.99) = 0; handles.c1(handles.c1 >= 0.99) = 1; handles.c1 = logical(handles.c1(:)); handles.c2 = mapVolumeToVolume(fullfile(pathname2, filename2{2}),handles.FuncLink); handles.c2(handles.c2 < 0.99) = 0; handles.c2(handles.c2 >= 0.99) = 1; handles.c2 = logical(handles.c2(:)); handles.c3 = mapVolumeToVolume(fullfile(pathname2, filename2{3}),handles.FuncLink); handles.c3(handles.c3 < 0.99) = 0; handles.c3(handles.c3 >= 0.99) = 1; handles.c3 = logical(handles.c3(:)); else errordlg('Please load functional data first !'); end handles.IsStructLoaded = 1; end % Computes the CSF and WM regressors handles.CSF_regressor = mean(handles.Data(handles.c2,:),1); handles.CSF_regressor = handles.CSF_regressor - mean(handles.CSF_regressor); handles.WM_regressor = mean(handles.Data(handles.c3,:),1); handles.WM_regressor = handles.WM_regressor - mean(handles.WM_regressor); guidata(hObject,handles); %% Data button: motion file function DataButton3_Callback(hObject, eventdata, handles) % Selection of the file [filename3,pathname3]=uigetfile({'*.*','All Files'},... 'Select structural files...','MultiSelect','off'); handles.Mot = textread(fullfile(pathname3,filename3)); handles.Mot = handles.Mot(:,1:6); handles.IsMotLoaded = 1; guidata(hObject,handles); %% Detrending radio switch function DetrendingButton_Callback(hObject, eventdata, handles) guidata(hObject,handles); %% Regression popup function RegressionButton_Callback(hObject, eventdata, handles) guidata(hObject,handles); function RegressionButton_CreateFcn(hObject, eventdata, handles) Regression_Types = {'None','Const','Const|Lin','Const|Lin|Quad',... 'Const|Lin|Quad|CSF','Const|Lin|Quad|CSF|WM','Const|Lin|Quad|CSF|WM|Mot'}; set(hObject,'String',Regression_Types); guidata(hObject,handles); %% Preprocessing button function PreproButton_Callback(hObject, eventdata, handles) % Data from all 3 tissue types tmp_GM = handles.Data(handles.c1,:); tmp_WM = handles.Data(handles.c2,:); tmp_CSF = handles.Data(handles.c3,:); % If we asked to detrend, detrending is performed if get(handles.DetrendingButton,'Value') == 1 tmp_GM = (detrend(tmp_GM'))'; tmp_WM = (detrend(tmp_WM'))'; tmp_CSF = (detrend(tmp_CSF'))'; end % X is the regressor matrix X = []; % Given the subcase asked for, the matrix is updated switch get(handles.RegressionButton,'Value') case 1 case 2 X = [X,ones(size(tmp_GM,2),1)]; case 3 X = [X,ones(size(tmp_GM,2),1),(1:size(tmp_GM,2))'/size(tmp_GM,2)]; case 4 X = [X,ones(size(tmp_GM,2),1),(1:size(tmp_GM,2))'/size(tmp_GM,2),((1:size(tmp_GM,2)).^2)'/size(tmp_GM,2)]; case 5 X = [X,ones(size(tmp_GM,2),1),(1:size(tmp_GM,2))'/size(tmp_GM,2),((1:size(tmp_GM,2)).^2)'/size(tmp_GM,2),handles.CSF_regressor']; case 6 X = [X,ones(size(tmp_GM,2),1),(1:size(tmp_GM,2))'/size(tmp_GM,2),((1:size(tmp_GM,2)).^2)'/size(tmp_GM,2),handles.CSF_regressor',handles.WM_regressor']; case 7 X = [X,ones(size(tmp_GM,2),1),(1:size(tmp_GM,2))'/size(tmp_GM,2),((1:size(tmp_GM,2)).^2)'/size(tmp_GM,2),handles.CSF_regressor',handles.WM_regressor',handles.Mot]; end % If we asked for at least one regressor, then we regress out the % covariates from the data if get(handles.RegressionButton,'Value') > 1 for vox = 1:size(tmp_GM,1) [~,tmp_GM(vox,:)] = y_regress_ss(tmp_GM(vox,:)',X); tmp_GM(vox,:) = tmp_GM(vox,:) + mean(tmp_GM(vox,:)); end for vox = 1:size(tmp_WM,1) [~,tmp_WM(vox,:)] = y_regress_ss(tmp_WM(vox,:)',X); tmp_WM(vox,:) = tmp_WM(vox,:) + mean(tmp_WM(vox,:)); end for vox = 1:size(tmp_CSF,1) [~,tmp_CSF(vox,:)] = y_regress_ss(tmp_CSF(vox,:)',X); tmp_CSF(vox,:) = tmp_CSF(vox,:) + mean(tmp_CSF(vox,:)); end end % Plotting handles.GMPlot = JOVE_PlotTimeCourses(handles.GMPlot,tmp_GM,handles.TR); handles.CSFWMPlot = JOVE_PlotMotion(handles.CSFWMPlot,[handles.CSF_regressor',handles.WM_regressor'],handles.TR); handles.TransPlot = JOVE_PlotMotion(handles.TransPlot,handles.Mot(:,1:3),handles.TR); handles.RotPlot = JOVE_PlotMotion(handles.RotPlot,handles.Mot(:,4:6),handles.TR); guidata(hObject,handles); %% Save button function SaveButton_Callback(hObject, eventdata, handles) ISFC_VX = handles.Data; ISFC_VX(~handles.c1,:) = NaN; save(fullfile(handles.FuncFolder,['ISFC_VX']),'ISFC_VX'); guidata(hObject,handles); function TRBox_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); % --- Executes during object creation, after setting all properties. function TRBox_CreateFcn(hObject, eventdata, handles) set(hObject,'String','Enter TR...'); set(hObject,'FontAngle','italic'); function TRBox_ButtonDownFcn(hObject,eventdata,handles) set(hObject,'Enable','on'); set(hObject,'String',''); set(hObject,'FontAngle','normal'); uicontrol(hObject); guidata(hObject, handles); function ClearButton_Callback(hObject, eventdata, handles) TRBox_CreateFcn(handles.TRBox, eventdata, handles); set(handles.TRBox,'BackgroundColor',240/255*[1 1 1]); RegressionButton_CreateFcn(handles.RegressionButton, eventdata, handles) set(handles.DetrendingButton,'Value',0); set(handles.RegressionButton,'Value',1); set(handles.TRBox,'Enable','off'); handles.Data = []; handles.FuncLink = ''; handles.FuncFolder = ''; handles.c1 = []; handles.c2 = []; handles.c3 = []; handles.IsFuncLoaded = 0; handles.IsMotLoaded = 0; handles.IsStructLoaded = 0; handles.AreAllDataLoaded = 0; handles.TR = 1; handles.Mot = []; % Makes the plots as we want set(handles.CSFWMPlot,'Box','off'); set(handles.TransPlot,'Box','off'); set(handles.RotPlot,'Box','off'); set(handles.CSFWMPlot,'XTick',[]); set(handles.TransPlot,'XTick',[]); xlabel(handles.RotPlot,'Time [s]'); ylabel(handles.CSFWMPlot,'CSF/WM [a.u.]'); ylabel(handles.TransPlot,'Trans. [mm]'); ylabel(handles.RotPlot,'Rot. [deg]'); ylabel(handles.GMPlot,'GM voxels'); cla(handles.GMPlot); cla(handles.TransPlot); cla(handles.RotPlot); cla(handles.CSFWMPlot); guidata(hObject,handles);