% this file forms the unity test for GiftIcaReport % it requires that SPM is on the search path %% inspect if eviourment is properly set if isempty(which('spm'));error('SPM not on the path, unity test not performed');end %check if test files exist P={'X:\My Documents\MATLAB\Projects\fMRI_script\GIFT_Clean\TestData\g_sub01_component_ica_s1_.nii'}; if not(exist(P{1},'file'));error('Test file not found,unity test not performed');end P2={'X:\My Documents\MATLAB\Projects\fMRI_script\GIFT_Clean\TestData\g_sub01_timecourses_ica_s1_.nii'}; if not(exist(P2{1},'file'));error('Test file not found,unity test not performed');end %% basic call and close Q = GiftIcaReport; clear('Q') %% basic call with no SPM error try tmp=fileparts(which('spm')); rmpath(tmp); Q = GiftIcaReport; catch ME addpath(tmp); %put back the path if ~ strcmpi(ME.identifier,'GiftIcaReport:set_SPMPath:SPM_not_found') rethrow(ME); else disp('passed no SPM test') disp(ME) end end %% test set ICAfile Q = GiftIcaReport; Q.ICAfile=[]; %set to empty try Q.ICAfile = 'junk'; catch ME if ~strcmpi(ME.identifier,'GiftICAReport:setfile:FileNotFound') rethrow(ME); else disp('passed file not found test') disp(ME); end end Q.ICAfile=P; Q.ICAfile=P{1}; %Q.ICAfile='ui'; % request a user interface %% test set TC file %Q.TCfile='ui'; Q.TCfile=P2; %% test set orientation try Q.Orientation='junk'; catch ME if ~strcmpi(ME.identifier,'GiftIcaReport:set_orientation:invalid_orientation') rethrow(ME) else disp('passed test on Orientation error') disp(ME) end end Q.Orientation='all'; Q.Orientation='tra'; Q.Orientation='cor'; Q.Orientation='sag'; %% test setting slice numbers I try Q.PlotSliceNumbers=0:5; catch ME if ~strcmpi(ME.identifier,'GiftIcaReport:set_slicenumbers:invalid_input') rethrow(ME); else disp('passed error test on set slicenumbers'); disp(ME); end end %% test setting slice numbers II try Q.PlotSliceNumbers='junk'; catch ME if ~strcmpi(ME.identifier,'GiftIcaReport:set_slicenumbers:invalid_input') rethrow(ME); else disp('passed error test on set slicenumbers'); disp(ME); end end %% test ImageLimits Q.ImageLimits = [0 1]; %to do check on properly working error %% test NPlots set Q.NPlots=25; disp(Q.PlotSliceNumbers); % %Q.PlotSliceNumbers=1:2:100; Q.Layout='north'; % to do build error handling check Q.LoadData; Q.NPlots=9; %if PlotSliceNumbers is empty, auto set the slices to plot Q.PlotSliceNumbers=[]; %auto set the slices to plot Q.BuildFigure; Q.GenReport;