This commit is contained in:
p147685 2020-04-15 21:35:12 +02:00
parent 1c93374f37
commit 3b9a1b9444
2 changed files with 132 additions and 9 deletions

View File

@ -6,10 +6,15 @@ classdef GiftIcaReport<handle
% https://doi.org/10.1016/j.neuroimage.2016.12.036
properties
ICA_file = {}; % .nii file containing the ICA images
TC_file = {}; % .nii file containing the TimeCourse data
ICAfile = {}; % .nii file containing the ICA images
TCfile = {}; % .nii file containing the TimeCourse data
Orientation = 'sag';% orientation of images to create
SliceNumber = []; % slice numbers to plot
SliceNumbers = []; % slice numbers to plot
end
properties (Access=private)
OrientationOptions={'tra','sag','cor','all'};
SPMPath
end
@ -31,11 +36,69 @@ classdef GiftIcaReport<handle
obj.SPMPath=fileparts(SPMFound);
end
function outputArg = method1(obj,inputArg)
%METHOD1 Summary of this method goes here
% Detailed explanation goes here
outputArg = obj.Property1 + inputArg;
function set.TCfile(obj,val)
obj.TCfile=obj.setfile(val);
end
function set.ICAfile(obj,val)
obj.ICAfile=obj.setfile(val);
end
function set.Orientation(obj,val)
switch lower(val)
case obj.OrientationOptions %#ok<MCSUP>
obj.Orientation=val;
otherwise
id = 'GiftIcaReport:set_orientation:invalid_orientation';
msg = sprintf('%s\n%s\n%s\t%s\t%s\n',...
'invalid option for orientation',...
'pick one of the following options',...
obj.OrientationOptions{:}); %#ok<MCSUP>
throw(MException(id,msg));
end
end
function set.SliceNumbers(obj,val)
if isnumeric(val) && ~any(val<1)
obj.SliceNumbers=val;
else
id = 'GiftIcaReport:set_slicenumbers:invalid_input';
msg = sprintf('invalid input for slicenumbers');
throw(MException(id,msg));
end
end
end
methods %private methods
function out = setfile(~,val)
if isempty(val)
out={};
return
end
if strcmpi('ui',val)
out={spm_select(1,'image','select ICA file, first frame')};
return
end
if iscell(val)
if ~exist(val{1},'file')
id='GiftICAReport:setfile:FileNotFound';
msg='File not Found';
throw(MException(id,msg));
else
out=val(1);
return
end
else
if ~exist(val,'file')
id='GiftICAReport:setfile:FileNotFound';
msg='File not Found';
throw(MException(id,msg));
else
out={val};
return
end
end
end
end
end

View File

@ -3,7 +3,11 @@
%% 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
Q = GiftIcaReport;
%% basic call with no SPM error
@ -19,4 +23,60 @@ catch ME
disp('passed no SPM test')
disp(ME)
end
end
end
%% test set ICAfile
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.ICAfile=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='tra';
Q.Orientation='cor';
Q.Orientation='sag';
%% test setting slice numbers I
try
Q.SliceNumbers=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.SliceNumbers='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
Q.SliceNumbers=1:2:100;