Repository navigation
Expand file tree
/
Copy pathaamod_template.m
More file actions
55 lines (44 loc) · 2.07 KB
/
Copy pathaamod_template.m
File metadata and controls
55 lines (44 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
% This is a tempate for a module code processing an MRI session
function [aap,resp]=aamod_template(aap,task,subj,sess)
resp='';
switch task
case 'report'
localpath = aas_getpath_bydomain(aap,aap.tasklist.currenttask.domain,[subj,sess]);
fdiag = dir(fullfile(localpath,'diagnostic_*.jpg'));
if isempty(fdiag)
streams=aas_getstreams(aap,'output');
for streamind=1:length(streams)
% obtain output
outputfnames = aas_getfiles_bystream(aap,aap.tasklist.currenttask.domain,[subj sess],streams{streamind},'output');
% perform diagnostics
do_diag(outputfnames);
end
fdiag = dir(fullfile(localpath,'diagnostic_*.jpg'));
end
for d = 1:numel(fdiag)
aap = aas_report_add(aap,subj,'<table><tr><td>');
imgpath = fullfile(localpath,fdiag(d).name);
aap=aas_report_addimage(aap,subj,imgpath);
aap = aas_report_add(aap,subj,'</td></tr></table>');
end
case 'doit'
[junk, SPMtool] = aas_cache_get(aap,'spm');
SPMtool.load;
streams=aas_getstreams(aap,'input');
for streamind=1:length(streams)
% obtain input filename(s)
inputfnames = aas_getfiles_bystream(aap,aap.tasklist.currenttask.domain,[subj sess],streams{streamind});
pfx = 'o'; % prefix for outputs
outputfnames = spm_file(inputfnames,'prefix',pfx);
% obtain parameter
par = aap.tasklist.currenttask.settings.parameter;
% do stuff
do_stuff(inputfnames, outputfnames, par);
% Describe outputs
aap=aas_desc_outputs(aap,aap.tasklist.currenttask.domain,[subj sess],streams{streamind},outputfnames);
end
case 'checkrequirements'
if ~aas_cache_get(aap,'spm'), aas_log(aap,true,'SPM is not found'); end
otherwise
aas_log(aap, 0, sprintf('%s: Unknown task %s',mfilename, task));
end