diff --git a/aa_engine/aa_doprocessing.m b/aa_engine/aa_doprocessing.m
index de37b01b1..9e9ec807d 100644
--- a/aa_engine/aa_doprocessing.m
+++ b/aa_engine/aa_doprocessing.m
@@ -433,6 +433,10 @@
aapsavefn=fullfile(aapsavepth,'aap_parameters');
aap.internal.aapversion=aa.Version;
aap.internal.aappath=aa.Path;
+ aap.internal.spmversion=spm('Version');
+ aap.internal.spmpath=spm('Dir');
+ aap.internal.matlabversion=version;
+ aap.internal.matlabpath=matlabroot;
save(aapsavefn,'aap');
end
end
diff --git a/aa_engine/aaq/nonDCS/PoolClass.m b/aa_engine/aaq/nonDCS/PoolClass.m
index ae496de5c..8cbed8712 100644
--- a/aa_engine/aaq/nonDCS/PoolClass.m
+++ b/aa_engine/aaq/nonDCS/PoolClass.m
@@ -4,6 +4,9 @@
JobStorageLocation
Jobs = JobClass.empty
+ Host = getenv('HOSTNAME')
+ NumWorkers
+
reqMemory = 1
reqWalltime = 1
initialConfiguration = ''
@@ -51,6 +54,7 @@
obj.Type = pool.Type;
obj.JobStorageLocation = pool.JobStorageLocation;
+ obj.NumWorkers = pool.NumWorkers;
switch obj.Type
case 'Torque'
diff --git a/aa_engine/aaq/nonDCS/TaskClass.m b/aa_engine/aaq/nonDCS/TaskClass.m
index 947b18137..2b1224d29 100644
--- a/aa_engine/aaq/nonDCS/TaskClass.m
+++ b/aa_engine/aaq/nonDCS/TaskClass.m
@@ -79,6 +79,7 @@
function val = get.State(obj)
val = 'unknown';
if exist(obj.ProcessFile,'file')
+ val = 'running';
fid = fopen(obj.ProcessFile,'r');
lines = textscan(fid,'%s','delimiter','@'); lines = lines{1};
fclose(fid);
diff --git a/aa_engine/aaq/nonDCS/aaq_qsub_nonDCS.m b/aa_engine/aaq/nonDCS/aaq_qsub_nonDCS.m
index 7fc4293bc..db1d6c664 100644
--- a/aa_engine/aaq/nonDCS/aaq_qsub_nonDCS.m
+++ b/aa_engine/aaq/nonDCS/aaq_qsub_nonDCS.m
@@ -26,11 +26,15 @@
pool.ResourceTemplate = '';
pool.SubmitArguments = '';
pool.AdditionalProperties.AdditionalSubmitArgs = '';
+
+ keyInd = arrayfun(@(x) strcmp(x.ATTRIBUTE.name,'NumWorkers'), xml.settings(2).settings.settings.key);
+ pool.NumWorkers = xml.settings(2).settings.settings.key(keyInd).double.value;
end
end
obj.pool = PoolClass(pool,obj.initialSubmitArguments,obj.poolConf{3});
obj.pool.reqMemory = aaparallel.memory;
obj.pool.reqWalltime = aaparallel.walltime;
+ obj.pool.NumWorkers = aaparallel.numberofworkers;
end
function obj = pool_args(obj,varargin)
diff --git a/aa_engine/aas_checkreg.m b/aa_engine/aas_checkreg.m
index d30b8573f..284a09b59 100755
--- a/aa_engine/aas_checkreg.m
+++ b/aa_engine/aas_checkreg.m
@@ -57,9 +57,6 @@ function aas_checkreg(aap,varargin)
if ~isfield(aap.tasklist.currenttask.settings,'diagnostic') ||...
isstruct(aap.tasklist.currenttask.settings.diagnostic) ||...
aap.tasklist.currenttask.settings.diagnostic
- % This will only work for 1-7 overlays
- OVERcolours = {[1 0 0], [0 1 0], [0 0 1], ...
- [1 1 0], [1 0 1], [0 1 1], [1 1 1]};
% One-by-one
for i = 1:size(image{1},1)
@@ -83,9 +80,11 @@ function aas_checkreg(aap,varargin)
end
if i > 1
% Summary
+ OVERcolours = distinguishable_colors(size(image{1},1));
+
spm_check_registration(image{2});
for i = 1:size(image{1},1)
- spm_orthviews('addcolouredimage',1,image{1}(i,:), OVERcolours{i})
+ spm_orthviews('addcolouredimage',1,image{1}(i,:), OVERcolours(i,:))
end
aas_checkreg_avi(aap, index, 0,'_summary');
close(1);
diff --git a/aa_engine/aas_connectAApipelines.m b/aa_engine/aas_connectAApipelines.m
index 40a16b88c..faffba278 100644
--- a/aa_engine/aas_connectAApipelines.m
+++ b/aa_engine/aas_connectAApipelines.m
@@ -66,38 +66,35 @@
%
% -------------------------------------------------------
% created by: cwild 2014-03-10
-%
-% updates:
-%
-% rhodri & cwild 2014-09-*: Update to allow fully qualified stream names in
-% local and remote analyses. E.g., using aamod_realign_00001.epi to fetch
-% the epi stream from the realign stage of a remote analysis, instead of
-% the last occurence of epi.
-% cwild 2014-09-09: output/input stream searching respects branches in the
-% local and remote analyses.
-% cwild 2014-04-02: Major update, added check for udpated data on the
-% remote
-% cwild 2014-03-18: misc cleaning
-%
% Error checking:
if isempty(aap.acq_details.subjects)
aas_log(aap, 1, 'aas_connectAApipelines() should be used after you have added subjects in your user script.');
end
-
if isempty(aap.acq_details.sessions)
aas_log(aap, 1, 'aas_connectAApipelines() should be used after you have added sessions in your user script.');
end
-
if any(~isfield(remoteAAlocations, {'host', 'directory', 'allowcache', 'maxstagetag', 'checkMD5'}))
aas_log(aap, 1, 'remoteAAlocations (input to aas_connectAApipelines) should be a struct array with the following fields: ''host'', ''directory'', ''allowcache'', ''maxstagetag'' ''checkMD5''');
end
global aaworker;
-% We need to transfer over the remote AAP files, will put them here
-studyPath = aas_getstudypath(aap);
+% We need study directory for aas_findinputstreamsources and to transfer over the remote AAP files
+studyPath = fullfile(aas_getstudypath(aap),[aap.directory_conventions.analysisid aap.directory_conventions.analysisid_suffix]);
aas_makedir(aap, studyPath);
+
+% Initialise aap
+% - evaluate subject names
+aap=aas_doprocessing_initialisationmodules(aap);
+% - integrate initial streams into the pipelines, if any
+aap=aas_builddependencymap(aap);
+v0 = aap.options.verbose;
+aap.options.verbose = -1; % mute error on missing streams, for they will be connected later
+aap=aas_findinputstreamsources(aap);
+aap.options.verbose = v0;
+% - remove partial initialisation
+aap = rmfield(aap,'internal');
% Collect remote AA structures here
remoteAA = {};
@@ -284,6 +281,8 @@
srcDomain = remoteAA{remoteOutput.locI}.schema.tasksettings.(remoteModule.name)(remoteModule.index).ATTRIBUTE.domain;
srcModality = remoteAA{remoteOutput.locI}.schema.tasksettings.(remoteModule.name)(remoteModule.index).ATTRIBUTE.modality;
+ if strcmp(trgDomain,'*'), trgDomain = srcDomain; end % for general purpose modules, such as aamod_maths
+
remoteStreams(end+1) = struct('stream', inputStreams{iI}, ...
'stagetag', aas_getstagetag(remoteAA{remoteOutput.locI}, remoteOutput.modI), ...
'sourcedomain', srcDomain, ...
@@ -401,9 +400,11 @@
else
if isstruct(aap.schema.tasksettings.(mod.name)(mod.index).inputstreams.stream{iI}) && ...
- isfield(aap.schema.tasksettings.(mod.name)(mod.index).inputstreams.stream{iI}, 'isessential') && ...
- aap.schema.tasksettings.(mod.name)(mod.index).inputstreams.stream{iI}.ATTRIBUTE.isessential
- aas_log(aap, 1, sprintf('%s''s input stream ''%s'' does not come from any module in this AA, or from one of your remote locations.\nTry connecting the AA pipelines *after* all aas_addinitialstream() calls in your user script.', mod.name, inputStreams{iI}));
+ (~isfield(aap.schema.tasksettings.(mod.name)(mod.index).inputstreams.stream{iI}, 'isessential') || ...
+ aap.schema.tasksettings.(mod.name)(mod.index).inputstreams.stream{iI}.isessential) && ...
+ (~isfield(aap.schema.tasksettings.(mod.name)(mod.index).inputstreams.stream{iI}.ATTRIBUTE, 'isessential') || ...
+ aap.schema.tasksettings.(mod.name)(mod.index).inputstreams.stream{iI}.ATTRIBUTE.isessential)
+ aas_log(aap, 1, sprintf('%s''s input stream ''%s'' does not come from any module in this pipeline, or from one of your remote locations.\nTry connecting the pipelines *after* all aas_addinitialstream() and aas_renamestream() calls in your user script.', mod.name, inputStreams{iI}));
end
end
diff --git a/aa_engine/aas_convertseries_fromstream.m b/aa_engine/aas_convertseries_fromstream.m
index 885ef8305..ec98d27c4 100644
--- a/aa_engine/aas_convertseries_fromstream.m
+++ b/aa_engine/aas_convertseries_fromstream.m
@@ -80,7 +80,6 @@
memLimit = meminfo; memLimit = memLimit.ResFree;
k=1;
-
while (k<=size(dicomdata_subdir,1))
oldAcquisitionNumber=-1;
@@ -90,7 +89,7 @@
% This array is used to collect sliceing timing info so we can
% reconstruct the slice order
sliceInfoD = zeros(0, 3);
-
+
while (k<=size(dicomdata_subdir,1))
tmp = spm_dicom_headers(deblank(dicomdata_subdir(k,:)));
diff --git a/aa_engine/aas_findinputstreamsources.m b/aa_engine/aas_findinputstreamsources.m
index 55c57c246..171ab02c9 100644
--- a/aa_engine/aas_findinputstreamsources.m
+++ b/aa_engine/aas_findinputstreamsources.m
@@ -64,7 +64,7 @@
end;
% Now we have one stream per cell
- for i=1:length(streamlist)
+ for i=1:numel(streamlist)
inputstreamname=inputstreams.stream{i};
ismodified=1; isessential=1;
if isstruct(inputstreamname)
@@ -153,12 +153,12 @@
end;
end;
end;
- if ~isempty(findremote) || ~isempty(stagethatoutputs)
- % change domain and modality if needed (due to input)
+ if (~isempty(findremote) || ~isempty(stagethatoutputs)) && (i==numel(streamlist))
+ % change domain and modality if needed (due to input, which is expected to be the last stream)
currstage = aap.schema.tasksettings.(stagename)(index).ATTRIBUTE;
currstream = aap.internal.inputstreamsources{k1}.stream(end);
- if (strcmp(currstage.domain,'*') && strcmp(currstage.modality,'MRI')) && ... % general-purpose module
- (~isempty(strfind(currstream.sourcedomain,'session')) || ~strcmp(currstream.sourcemodality,'MRI')) % special
+ if (strcmp(currstage.domain,'*') && strcmp(currstage.modality,'MRI'))% general-purpose module
+% (~isempty(strfind(currstream.sourcedomain,'session')) || ~strcmp(currstream.sourcemodality,'MRI')) % special
aap.schema.tasksettings.(stagename)(index).ATTRIBUTE.modality = currstream.sourcemodality;
aap.internal.aap_initial.schema.tasksettings.(stagename)(index).ATTRIBUTE.modality = currstream.sourcemodality;
aap.schema.tasksettings.(stagename)(index).ATTRIBUTE.domain = currstream.sourcedomain;
diff --git a/aa_modules/aamod_CoSMoMVPA.m b/aa_modules/aamod_CoSMoMVPA.m
index 4b2628887..1d47dee2a 100644
--- a/aa_modules/aamod_CoSMoMVPA.m
+++ b/aa_modules/aamod_CoSMoMVPA.m
@@ -3,29 +3,31 @@
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,'
');
-% imgpath = fullfile(localpath,fdiag(d).name);
-% aap=aas_report_addimage(aap,subj,imgpath);
-% aap = aas_report_add(aap,subj,' |
');
-% end
+ % 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,'');
+ % imgpath = fullfile(localpath,fdiag(d).name);
+ % aap=aas_report_addimage(aap,subj,imgpath);
+ % aap = aas_report_add(aap,subj,' |
');
+ % end
case 'doit'
%% Prepare data
+ TASKS = textscan(aas_getsetting(aap,'tasks'),'%s','Delimiter',':'); TASKS = TASKS{1}';
+
RSAROOT = fullfile(aas_getsubjpath(aap,subj),'RSA');
aas_makedir(aap,RSAROOT);
@@ -33,16 +35,16 @@
inps = inps(logical(cellfun(@(x) exist(aas_getinputstreamfilename(aap,'subject',subj,x),'file'), inps)));
struct_fn = aas_getfiles_bystream(aap,'subject',subj,inps{1});
- fnMask = cellfun(@(x) aas_getfiles_bystream(aap,'subject',subj,x), inps(cell_index(inps,'firstlevel_brainmask')),'UniformOutput',false);
+ fnMask = cellfun(@(x) aas_getfiles_bystream(aap,'subject',subj,x), inps(cell_index(inps,'mask')),'UniformOutput',false);
fnSPM = cellfun(@(x) aas_getfiles_bystream(aap,'subject',subj,x), inps(cellfun(@(x) ~isempty(regexp(x,'firstlevel_spm$', 'once')), inps)),'UniformOutput',false);
fnTmaps = cellfun(@(x) aas_getfiles_bystream(aap,'subject',subj,x), inps(cell_index(inps,'firstlevel_spmts')),'UniformOutput',false);
- if numel(fnSPM) > 1
+ if numel(fnMask) > 1
brain_mask = spm_imcalc(spm_vol(char(fnMask)),fullfile(RSAROOT,'brain_mask.nii'),'min(X)',{1});
else
brain_mask.fname = char(fnMask);
end
-
+
ITEMS = aas_getsetting(aap,'itemList');
fnT = {};
for run = 1:numel(fnSPM)
@@ -60,46 +62,68 @@
cosmo_set_path
cosmo_check_external('-tic');
- % Data
- ds=cosmo_fmri_dataset(fullfile(RSAROOT,'glm_T_stats_perrun.nii'),'mask',brain_mask.fname,...
- 'targets',repmat(1:numel(ITEMS),1,numel(fnSPM))');
- ds=cosmo_fx(ds, @(x)mean(x,1), 'targets', 1);
- ds.sa.labels=cellfun(@(x) x{1}, ITEMS, 'UniformOutput', false)';
- ds.sa.set=(1:numel(ITEMS))';
- cosmo_check_dataset(ds);
-
- % Searchlight
- nbrhood=cosmo_spherical_neighborhood(ds,'count',aas_getsetting(aap,'searchlightVox'));
+ if cell_index(TASKS, 'RSA') && isempty(aas_getsetting(aap,'bsMatrix')), TASKS(cell_index(TASKS, 'RSA')) = []; end
- % Model
- target_dsm=importdata(aas_getsetting(aap,'bsMatrix'));
- measure=@cosmo_target_dsm_corr_measure;
- measure_args=struct();
- measure_args.target_dsm=target_dsm;
-
- %% Info
- aas_log(aap,false,'INFO:Dataset input:'); cosmo_disp(ds);
- aas_log(aap,false,'INFO:Searchlight neighborhood definition:'); cosmo_disp(nbrhood);
- aas_log(aap,false,'INFO:Target DSM:'); disp(target_dsm);
-
-% imagesc(target_dsm)
-% set(gca,'XTick',1:size(ds.samples,1),'XTickLabel',ds.sa.labels,...
-% 'YTick',1:size(ds.samples,1),'YTickLabel',ds.sa.labels)
-
- %% Run
- ds_rsm_behav=cosmo_searchlight(ds,nbrhood,measure,measure_args);
-
-% cosmo_plot_slices(ds_rsm_behav);
-
- % store results
- rsa_fn=fullfile(RSAROOT,'RSAmap.nii');
- cosmo_map2fmri(ds_rsm_behav,rsa_fn);
-
- %% Cleanup
- path(oldPath);
-
- aap=aas_desc_outputs(aap,'subject',subj,'RSAmap',rsa_fn);
-
+ for t = TASKS
+ % Data
+ switch t{1}
+ case 'RSA'
+ ds=cosmo_fmri_dataset(fullfile(RSAROOT,'glm_T_stats_perrun.nii'),'mask',brain_mask.fname,...
+ 'targets',repmat(1:numel(ITEMS),1,numel(fnSPM))');
+ ds=cosmo_fx(ds, @(x)mean(x,1), 'targets', 1);
+ ds.sa.labels=cellfun(@(x) x{1}, ITEMS, 'UniformOutput', false)';
+ ds.sa.set=(1:numel(ITEMS))';
+ case 'C'
+ ds=cosmo_fmri_dataset(fullfile(RSAROOT,'glm_T_stats_perrun.nii'),'mask',brain_mask.fname,...
+ 'targets',repmat(1:numel(ITEMS),1,numel(fnSPM))','chunks',floor(((1:numel(ITEMS)*numel(fnSPM))-1)/numel(ITEMS))+1);
+ ds.sa.labels=cellfun(@(x) x{1}, repmat(ITEMS,1,numel(fnSPM)), 'UniformOutput', false)';
+ ds.sa.set=repmat((1:numel(ITEMS))',numel(fnSPM),1);
+ end
+
+ % Data
+ cosmo_check_dataset(ds);
+
+ % Searchlight
+ nbrhood=cosmo_spherical_neighborhood(ds,'count',aas_getsetting(aap,'searchlightVox'));
+
+ % Model
+ target_dsm = 'not specified';
+ switch t{1}
+ case 'RSA'
+ target_dsm=importdata(aas_getsetting(aap,'bsMatrix'));
+ measure=@cosmo_target_dsm_corr_measure;
+ measure_args = aas_getsetting(aap,'RSAsettings');
+ measure_args.target_dsm=target_dsm;
+ case 'C'
+ measure_args = aas_getsetting(aap,'Csettings');
+ measure_args.classifier = str2func(['cosmo_classify_' lower(measure_args.classifier)]);
+ measure_args.partitions = cosmo_balance_partitions(cosmo_nfold_partitioner(ds), ds);
+ measure=@cosmo_crossvalidation_measure;
+ end
+
+ %% Info
+ aas_log(aap,false,'INFO:Dataset input:'); cosmo_disp(ds);
+ aas_log(aap,false,'INFO:Searchlight neighborhood definition:'); cosmo_disp(nbrhood);
+ aas_log(aap,false,'INFO:Target DSM:'); disp(target_dsm);
+
+ % imagesc(target_dsm)
+ % set(gca,'XTick',1:size(ds.samples,1),'XTickLabel',ds.sa.labels,...
+ % 'YTick',1:size(ds.samples,1),'YTickLabel',ds.sa.labels)
+
+ %% Run
+ ds_rsm_behav=cosmo_searchlight(ds,nbrhood,measure,measure_args);
+
+ % cosmo_plot_slices(ds_rsm_behav);
+
+ % store results
+ rsa_fn=fullfile(RSAROOT,[t{1} 'map.nii']);
+ cosmo_map2fmri(ds_rsm_behav,rsa_fn);
+
+ %% Cleanup
+ path(oldPath);
+
+ aap=aas_desc_outputs(aap,'subject',subj,[t{1} 'map'],rsa_fn);
+ end
case 'checkrequirements'
otherwise
diff --git a/aa_modules/aamod_CoSMoMVPA.xml b/aa_modules/aamod_CoSMoMVPA.xml
index a5b680566..a39b68f5e 100644
--- a/aa_modules/aamod_CoSMoMVPA.xml
+++ b/aa_modules/aamod_CoSMoMVPA.xml
@@ -9,18 +9,32 @@
1
+
+ RSA:C
+
+
+ 0
+
+
+
+ LDA
+
+
-
+
structural
RSAmap
+ Cmap
diff --git a/aa_modules/aamod_autoidentifyseries.m b/aa_modules/aamod_autoidentifyseries.m
index b9d6568fb..4210b8527 100644
--- a/aa_modules/aamod_autoidentifyseries.m
+++ b/aa_modules/aamod_autoidentifyseries.m
@@ -196,10 +196,10 @@
if aap.options.autoidentifyfieldmaps
aap.acq_details.subjects(i).fieldmaps{d}=[];
- if numel(series_fieldmap{d})>=aap.options.autoidentifyfieldmaps_number
+ if numel(series_fieldmap{d})>=abs(aap.options.autoidentifyfieldmaps_number)
comment=[comment ' fieldmap series'];
% Generalisation of fieldmap number...
- for n = 1:aap.options.autoidentifyfieldmaps_number
+ for n = 1:abs(aap.options.autoidentifyfieldmaps_number)
comment=[comment sprintf(' %d',series_fieldmap{d}(n))];
end
comment=[comment '\n'];
diff --git a/aa_modules/aamod_coreg_extended_2.m b/aa_modules/aamod_coreg_extended_2.m
index 8283daef3..a61e16b82 100644
--- a/aa_modules/aamod_coreg_extended_2.m
+++ b/aa_modules/aamod_coreg_extended_2.m
@@ -164,7 +164,7 @@
%% Describe the outputs and Diagnostics
if strcmp(aap.options.wheretoprocess,'localsingle')
- aas_checkreg(aap,domain,cell2mat(varargin),diagstream,'structural');
+ aas_checkreg(aap,domain,cell2mat(varargin),mEPIimg,'structural');
for m = 1:numel(mainstream)
aas_checkreg(aap,domain,cell2mat(varargin),mainstream{m},'structural');
end
@@ -179,7 +179,7 @@
end
case 'checkrequirements'
- aas_log(aap,0,'No need to trim or skull strip structural\n' );
+
end
end
diff --git a/aa_modules/aamod_coreg_extended_2_RSA.xml b/aa_modules/aamod_coreg_extended_2.xml
similarity index 61%
rename from aa_modules/aamod_coreg_extended_2_RSA.xml
rename to aa_modules/aamod_coreg_extended_2.xml
index eaed0ad38..906071a17 100644
--- a/aa_modules/aamod_coreg_extended_2_RSA.xml
+++ b/aa_modules/aamod_coreg_extended_2.xml
@@ -1,32 +1,29 @@
-
+
0.5
0.2
+ 2
+
nmi
- 2
-
- 1
-
t1totemplate_xfm
- RSAmap
wholebrain_epi
- aamod_realignunwarp_00001.meanepi
- aamod_realign_00001.meanepi
+ meanepi
aamod_coreg_extended_1_00001.structural
+ epi
- RSAmap
+ epi
diff --git a/aa_modules/aamod_coreg_extended_2epi.xml b/aa_modules/aamod_coreg_extended_2epi.xml
index ca2c39aa9..c93493a31 100644
--- a/aa_modules/aamod_coreg_extended_2epi.xml
+++ b/aa_modules/aamod_coreg_extended_2epi.xml
@@ -14,6 +14,8 @@
nmi
+ 1
+
t1totemplate_xfm
epi
diff --git a/aa_modules/aamod_dartel_denorm.m b/aa_modules/aamod_dartel_denorm.m
index de4b0d1bf..bb363fb5a 100644
--- a/aa_modules/aamod_dartel_denorm.m
+++ b/aa_modules/aamod_dartel_denorm.m
@@ -1,4 +1,4 @@
-function [aap, resp]=aamod_dartel_denorm(aap, task, subj, sess)
+function [aap, resp]=aamod_dartel_denorm(aap, task, varargin)
% Inputstream order
% 1. coreg_exteded.main - subject domain (optional)
% 2. native.session - session domain
@@ -11,22 +11,23 @@
% possible tasks 'doit','report','checkrequirements'
switch task
case 'report'
+ subj = varargin{1};
domain = aap.tasklist.currenttask.domain;
- localpath = aas_getpath_bydomain(aap,domain,[subj,sess]);
+ localpath = aas_getpath_bydomain(aap,domain,cell2mat(varargin));
inpstreams = aas_getstreams(aap,'input');
workstream = inpstreams{end};
- images = cellstr(aas_getfiles_bystream_multilevel(aap, domain, [subj sess], workstream));
+ images = cellstr(aas_getfiles_bystream_multilevel(aap, domain, cell2mat(varargin), workstream));
regstreams = inpstreams(1:end-3); toRemove = [];
for i = 1:numel(regstreams)
- if ~aas_stream_has_contents(aap,domain,[subj sess],regstreams{i}), toRemove(end+1) = i; end
+ if ~aas_stream_has_contents(aap,domain,cell2mat(varargin),regstreams{i}), toRemove(end+1) = i; end
end
regstreams(toRemove) = [];
- streamfn = aas_getfiles_bystream(aap,domain,[subj sess],['native_' workstream],'output');
+ streamfn = aas_getfiles_bystream(aap,domain,cell2mat(varargin),workstream,'output');
streamfn = strtok_ptrn(basename(streamfn(1,:)),'-0');
fn = ['diagnostic_aas_checkreg_slices_' streamfn '_1.jpg'];
if ~exist(fullfile(localpath,fn),'file')
- aas_checkreg(aap,domain,[subj,sess],['native_' workstream],regstreams{end});
+ aas_checkreg(aap,domain,cell2mat(varargin),workstream,regstreams{end});
end
% Single-subjetc
fdiag = dir(fullfile(localpath,'diagnostic_*.jpg'));
@@ -41,33 +42,34 @@
case 'doit'
%% Preapre
+ subj = varargin{1};
domain = aap.tasklist.currenttask.domain;
- localpath = aas_getpath_bydomain(aap,domain,[subj,sess]);
+ localpath = aas_getpath_bydomain(aap,domain,cell2mat(varargin));
inpstreams = aas_getstreams(aap,'input');
workstream = inpstreams{end};
- images = cellstr(aas_getfiles_bystream_multilevel(aap, domain, [subj sess], workstream));
+ images = cellstr(aas_getfiles_bystream_multilevel(aap, domain, cell2mat(varargin), workstream));
regstreams = inpstreams(1:end-3); toRemove = [];
for i = 1:numel(regstreams)
- if ~aas_stream_has_contents(aap,domain,[subj sess],regstreams{i}), toRemove(end+1) = i; end
+ if ~aas_stream_has_contents(aap,domain,cell2mat(varargin),regstreams{i}), toRemove(end+1) = i; end
end
regstreams(toRemove) = [];
% Affine Template2mni
- xfm = load(aas_getfiles_bystream_multilevel(aap, domain, [subj sess], 'dartel_templatetomni_xfm'));
+ xfm = load(aas_getfiles_bystream_multilevel(aap, domain, cell2mat(varargin), 'dartel_templatetomni_xfm'));
for i = 1:numel(images)
- if ~exist(fullfile(aas_getpath_bydomain(aap,domain,[subj,sess]),[basename(images{i}) '.nii']),'file')
- copyfile(images{i},fullfile(aas_getpath_bydomain(aap,domain,[subj,sess]),[basename(images{i}) '.nii']));
+ if ~exist(fullfile(aas_getpath_bydomain(aap,domain,cell2mat(varargin)),[basename(images{i}) '.nii']),'file')
+ copyfile(images{i},fullfile(aas_getpath_bydomain(aap,domain,cell2mat(varargin)),[basename(images{i}) '.nii']));
end
- images{i} = fullfile(aas_getpath_bydomain(aap,domain,[subj,sess]),basename([images{i} '.nii']));
+ images{i} = fullfile(aas_getpath_bydomain(aap,domain,cell2mat(varargin)),basename([images{i} '.nii']));
spm_get_space(images{i},xfm.xfm\spm_get_space(images{i}));
end
% Flowfield
ff = aas_getfiles_bystream(aap, subj, 'dartel_flowfield');
- if ~exist(fullfile(aas_getpath_bydomain(aap,domain,[subj,sess]),[basename(ff) '.nii']),'file')
- copyfile(ff,fullfile(aas_getpath_bydomain(aap,domain,[subj,sess]),[basename(ff) '.nii']));
+ if ~exist(fullfile(aas_getpath_bydomain(aap,domain,cell2mat(varargin)),[basename(ff) '.nii']),'file')
+ copyfile(ff,fullfile(aas_getpath_bydomain(aap,domain,cell2mat(varargin)),[basename(ff) '.nii']));
end
- ff = fullfile(aas_getpath_bydomain(aap,domain,[subj,sess]),basename([ff '.nii']));
+ ff = fullfile(aas_getpath_bydomain(aap,domain,cell2mat(varargin)),basename([ff '.nii']));
%% Denorm
job.flowfields = {ff};
@@ -84,22 +86,31 @@
flags.which = [1 0];
% Reslice
- imreslice{1} = aas_getfiles_bystream_multilevel(aap,domain,[subj sess],regstreams{end});
+ imreslice{1} = aas_getfiles_bystream_multilevel(aap,domain,cell2mat(varargin),regstreams{end});
for r = 1:numel(job.images)
- imreslice{r+1} = fullfile(aas_getpath_bydomain(aap,domain,[subj sess]),['w' basename(job.images{r}) '.nii']);
- rwimgs{r} = fullfile(aas_getpath_bydomain(aap,domain,[subj sess]),[flags.prefix 'w' basename(job.images{r}) '.nii']);
+ imreslice{r+1} = fullfile(aas_getpath_bydomain(aap,domain,cell2mat(varargin)),['w' basename(job.images{r}) '.nii']);
+ rwimgs{r} = fullfile(aas_getpath_bydomain(aap,domain,cell2mat(varargin)),[flags.prefix 'w' basename(job.images{r}) '.nii']);
movefile(fullfile(fileparts(job.flowfields{1}),['w' basename(job.images{r}) '_' basename(job.flowfields{1}) '.nii']),imreslice{r+1});
if numel(regstreams) == 2 % Decoreg + Reslice to final target
- xfm = spm_get_space(aas_getfiles_bystream_multilevel(aap,domain,[subj sess],regstreams{2}))/...
- spm_get_space(aas_getfiles_bystream_multilevel(aap,domain,[subj sess],regstreams{1}));
+ xfm = spm_get_space(aas_getfiles_bystream_multilevel(aap,domain,cell2mat(varargin),regstreams{2}))/...
+ spm_get_space(aas_getfiles_bystream_multilevel(aap,domain,cell2mat(varargin),regstreams{1}));
spm_get_space(imreslice{r+1},xfm*spm_get_space(imreslice{r+1}))
end
end
spm_reslice(imreslice,flags);
- aap=aas_desc_outputs(aap,domain,[subj,sess],['native_' workstream],rwimgs);
+ aap=aas_desc_outputs(aap,domain,cell2mat(varargin),workstream,rwimgs);
%% Diag
if strcmp(aap.options.wheretoprocess,'localsingle')
- aas_checkreg(aap,domain,[subj,sess],['native_' workstream],regstreams{end});
+ aas_checkreg(aap,domain,cell2mat(varargin),workstream,regstreams{end});
+ end
+ case 'checkrequirements'
+ in = aas_getstreams(aap,'input'); in = in{end}; % last stream
+ [stagename, index] = strtok_ptrn(aap.tasklist.currenttask.name,'_0');
+ stageindex = sscanf(index,'_%05d');
+ out = aap.tasksettings.(stagename)(stageindex).outputstreams.stream; if iscell(out), out = out{1}; end
+ if ~strcmp(out,in)
+ aap = aas_renamestream(aap,aap.tasklist.currenttask.name,out,in,'output');
+ aas_log(aap,false,['INFO: ' aap.tasklist.currenttask.name ' output stream: ''' in '''']);
end
end
\ No newline at end of file
diff --git a/aa_modules/aamod_dartel_denormepi.xml b/aa_modules/aamod_dartel_denormepi.xml
new file mode 100644
index 000000000..654cae241
--- /dev/null
+++ b/aa_modules/aamod_dartel_denormepi.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+ 2
+
+ 0
+ 1
+
+
+ aamod_coreg_extended_2meanepi_00001.meanepi
+ aamod_realignunwarp_00001.meanepi
+ aamod_realign_00001.meanepi
+ dartel_templatetomni_xfm
+ dartel_flowfield
+ rois
+
+
+
+ rois
+
+
+
+
+
diff --git a/aa_modules/aamod_diffusion_dartel_denormDKI.xml b/aa_modules/aamod_diffusion_dartel_denormDKI.xml
index 8cec9d3b9..cdb79ba0e 100644
--- a/aa_modules/aamod_diffusion_dartel_denormDKI.xml
+++ b/aa_modules/aamod_diffusion_dartel_denormDKI.xml
@@ -13,11 +13,11 @@
aamod_diffusion_dkifit_00001.dki_FA
dartel_templatetomni_xfm
dartel_flowfield
- normalised_grey
+ grey
- native_grey
+ grey
diff --git a/aa_modules/aamod_diffusion_dartel_denormDTI.xml b/aa_modules/aamod_diffusion_dartel_denormDTI.xml
index 75a289c2f..43fb4d2b1 100644
--- a/aa_modules/aamod_diffusion_dartel_denormDTI.xml
+++ b/aa_modules/aamod_diffusion_dartel_denormDTI.xml
@@ -13,11 +13,11 @@
aamod_diffusion_dtinlfit_00001.dti_FA
dartel_templatetomni_xfm
dartel_flowfield
- normalised_grey
+ grey
- native_grey
+ grey
diff --git a/aa_modules/aamod_diffusionfromnifti.m b/aa_modules/aamod_diffusionfromnifti.m
index 28c982698..5f11c5088 100644
--- a/aa_modules/aamod_diffusionfromnifti.m
+++ b/aa_modules/aamod_diffusionfromnifti.m
@@ -38,10 +38,10 @@
end
end
comp = false;
- if strcmp(spm_file(niftifile,'Ext'),'gz'),
+ if strcmp(spm_file(niftifile,'Ext'),'gz')
comp = true;
- gunzip(niftifile);
- niftifile = niftifile(1:end-3);
+ gunzip(niftifile,fullfile(sesspth,'temp'));
+ niftifile = spm_file(niftifile(1:end-3),'path',fullfile(sesspth,'temp'));
end
% BVals/BVecs
@@ -59,7 +59,7 @@
for ln=1:3
fprintf(fid,'%.14f ',bvecs(:,ln));
fprintf(fid,'\n');
- end;
+ end
fclose(fid);
% Image
@@ -73,7 +73,7 @@
V(fileind).n=[1 1];
spm_write_vol(V(fileind),Y);
finalepis=[finalepis fn];
- end;
+ end
% Write out the files
% Now move dummy scans to dummy_scans directory
@@ -84,7 +84,7 @@
for d=1:numdummies
cmd=['mv ' finalepis{d} ' ' dummypath];
dummylist=strvcat(dummylist,spm_file(finalepis{d},'path','dummy_scans'));
- [s w]=aas_shell(cmd);
+ s=aas_shell(cmd);
if (s)
aas_log(aap,1,sprintf('ERROR:Problem moving dummy scan\nERROR: %s to\nERROR: %s\n',finalepis{d},dummypath));
end
@@ -98,7 +98,7 @@
finalepis = finalepis{1};
ind = find(finalepis=='-');
sfx = '';
- if isempty(ind),
+ if isempty(ind)
ind = find(finalepis=='.');
sfx = '_4D';
end
@@ -109,7 +109,7 @@
end
%% Describe outputs
- if comp, delete(niftifile); end
+ if comp, rmdir(fullfile(sesspth,'temp'),'s'); end
aap=aas_desc_outputs(aap,domain,indices,'dummyscans',dummylist);
aap=aas_desc_outputs(aap,domain,indices,'diffusion_data',finalepis);
aap=aas_desc_outputs(aap,domain,indices,'bvals',bvals_fn);
@@ -119,5 +119,5 @@
otherwise
aas_log(aap,1,sprintf('Unknown task %s',task));
-end;
+end
end
\ No newline at end of file
diff --git a/aa_modules/aamod_epifromnifti.m b/aa_modules/aamod_epifromnifti.m
index 499502f33..caec32626 100644
--- a/aa_modules/aamod_epifromnifti.m
+++ b/aa_modules/aamod_epifromnifti.m
@@ -25,6 +25,9 @@
series = series{sess};
%% Process
+ sesspth=aas_getsesspath(aap,subj,sess);
+ aas_makedir(aap,sesspth);
+
% Files
headerFn ='';
imageFn = series;
@@ -47,8 +50,8 @@
comp = false;
if any(strcmp(spm_file(niftifile,'Ext'),'gz'))
comp = true;
- gunzip(niftifile{1});
- niftifile{1} = niftifile{1}(1:end-3);
+ gunzip(niftifile{1},fullfile(sesspth,'temp'));
+ niftifile{1} = spm_file(niftifile{1}(1:end-3),'path',fullfile(sesspth,'temp'));
end
% Header
@@ -73,8 +76,6 @@
finalepis={};
V = spm_vol(niftifile);
if iscell(V), V = cell2mat(V); end
- sesspth=aas_getsesspath(aap,subj,sess);
- aas_makedir(aap,sesspth);
fle = spm_file(niftifile,'basename');
ext = spm_file(niftifile,'Ext');
for fileind=1:numel(V)
@@ -115,8 +116,7 @@
aap=aas_makedir(aap,dummypath);
for d=1:numdummies
cmd=['mv ' finalepis{d} ' ' dummypath];
- [pth, nme, ext]=fileparts(finalepis{d});
- dummylist=char(dummylist,fullfile('dummy_scans',[nme ext]));
+ dummylist=strvcat(dummylist,fullfile(dummypath, spm_file(finalepis{d},'filename')));
[s, w]=aas_shell(cmd);
if (s)
aas_log(aap,1,sprintf('Problem moving dummy scan\n%s\nto\n%s\n\n%s',finalepis{d},dummypath,w));
@@ -140,7 +140,7 @@
spm_file_merge(char({V(numdummies+1:end).fname}),finalepis,0,DICOMHEADERS{1}.volumeTR);
end
% And describe outputs
- if comp, delete(niftifile{1}); end
+ if comp, rmdir(fullfile(sesspth,'temp'),'s'); end
aap=aas_desc_outputs(aap,subj,sess,'epi',finalepis);
aap = aas_desc_outputs(aap,subj,sess,'dummyscans',dummylist);
dcmhdrfn = fullfile(sesspth,'dicom_headers.mat');
diff --git a/aa_modules/aamod_fieldmapfromnifti.m b/aa_modules/aamod_fieldmapfromnifti.m
index 6a1031f4d..0aacb68d3 100644
--- a/aa_modules/aamod_fieldmapfromnifti.m
+++ b/aa_modules/aamod_fieldmapfromnifti.m
@@ -37,8 +37,8 @@
for f = 1:numel(niftifile)
comp = strcmp(spm_file(niftifile{f},'Ext'),'gz');
if comp
- gunzip(niftifile{f});
- niftifile{f} = niftifile{f}(1:end-3);
+ gunzip(niftifile{f},fullfile(sesspth,'temp'));
+ niftifile{1} = spm_file(niftifile{f}(1:end-3),'path',fullfile(sesspth,'temp'));
end
aas_makedir(aap,fullfile(sesspth,sprintf('serie%02d',f)));
@@ -48,7 +48,7 @@
spm_write_vol(V,Y);
fn{f} = V.fname;
- if comp, delete(niftifile{f}); end
+ if comp, rmdir(fullfile(sesspth,'temp'),'s'); end
end
aap=aas_desc_outputs(aap,'session',[subj sess],'fieldmap',char(fn));
diff --git a/aa_modules/aamod_firstlevel_threshold.m b/aa_modules/aamod_firstlevel_threshold.m
index 71036852d..758f1f631 100644
--- a/aa_modules/aamod_firstlevel_threshold.m
+++ b/aa_modules/aamod_firstlevel_threshold.m
@@ -23,8 +23,8 @@
case 'report'
% collect contrast names and prepare summary
-
- cons = [aap.tasksettings.aamod_firstlevel_contrasts(aap.tasklist.currenttask.index).contrasts(2:end).con];
+ contrasts = aas_getsetting(aas_setcurrenttask(aap,aap.internal.inputstreamsources{aap.tasklist.currenttask.modulenumber}.stream(1).sourcenumber),'contrasts');
+ cons = [contrasts(2:end).con];
conNames = {cons.name};
[~,a] = unique(conNames,'first');
conNames = conNames(sort(a));
diff --git a/aa_modules/aamod_freesurfer_register.m b/aa_modules/aamod_freesurfer_register.m
index 06f73f640..37aec0b1a 100644
--- a/aa_modules/aamod_freesurfer_register.m
+++ b/aa_modules/aamod_freesurfer_register.m
@@ -21,9 +21,9 @@
case 'study'
localroot = aas_getstudypath(aap);
setenv('SUBJECTS_DIR', localroot)
- system(sprintf('ln -s %s/subjects/fsaverage %s/fsaverage',getenv('FREESURFER_HOME'),localroot));
- system(sprintf('ln -s %s/subjects/lh.EC_average %s/lh.EC_average',getenv('FREESURFER_HOME'),localroot));
- system(sprintf('ln -s %s/subjects/rh.EC_average %s/rh.EC_average',getenv('FREESURFER_HOME'),localroot));
+ system(sprintf('ln -s %s/subjects/fsaverage %s/fsaverage',aap.directory_conventions.freesurferdir,localroot));
+ system(sprintf('ln -s %s/subjects/lh.EC_average %s/lh.EC_average',aap.directory_conventions.freesurferdir,localroot));
+ system(sprintf('ln -s %s/subjects/rh.EC_average %s/rh.EC_average',aap.directory_conventions.freesurferdir,localroot));
subjname = 'fsaverage';
aas_makedir(aap,fullfile(localroot,aap.directory_conventions.structdirname));
% get template try FSL's
@@ -65,7 +65,7 @@
resliceflags = aap.spm.defaults.coreg.write;
resliceflags.interp = aap.tasklist.currenttask.settings.interp;
resliceflags.which = [1 0];
- srcwfs = '';
+ srcwfs = {};
for i = 1:numel(srcstream)
fsrc = aas_getfiles_bystream(aap,aap.tasklist.currenttask.domain, indices, srcstream{i});
for f = 1:size(fsrc,1)
@@ -79,9 +79,9 @@
if FWHM, FScommand = [FScommand sprintf(' --surf-fwhm %d',FWHM)]; end
[s, w] = aas_runFScommand(aap,FScommand);
%% Output stream
- srcwfs(end+1,:) = [strrep(src,[localroot '/'],'') '2FS_rh.mgh'];
- srcwfs(end+1,:) = [strrep(src,[localroot '/'],'') '2FS_lh.mgh'];
+ srcwfs{end+1} = [strrep(src,[localroot '/'],'') '2FS_rh.mgh'];
+ srcwfs{end+1} = [strrep(src,[localroot '/'],'') '2FS_lh.mgh'];
end
- aap = aas_desc_outputs(aap,aap.tasklist.currenttask.domain,indices,[srcstream{i} '_FS'],srcwfs);
+ aap = aas_desc_outputs(aap,aap.tasklist.currenttask.domain,indices,[srcstream{i} '_FS'],char(srcwfs));
end
end
diff --git a/aa_modules/aamod_mask_fromsegment.m b/aa_modules/aamod_mask_fromsegment.m
index 726a4c7a2..b11017147 100644
--- a/aa_modules/aamod_mask_fromsegment.m
+++ b/aa_modules/aamod_mask_fromsegment.m
@@ -46,14 +46,14 @@
%% A) Zero thresholding is easy...
for a = 1:size(segimg,1)
Y{a} = Y{a} > 0;
-
+
V{a}.fname = spm_file(segimg(a,:),'prefix','Z_r');
outstream = strvcat(outstream, V{a}.fname); % Save to stream...
spm_write_vol(V{a}, Y{a});
aas_log(aap,false,sprintf('Zero thresholded image %s sums up to %d vox', ...
V{a}.fname, sum(Y{a}(:))))
- end
+ end
case 'exclusive'
%% C) Exclusive thresholding of masks:
% Any particular voxel has greatest chance of being...
@@ -89,9 +89,25 @@
aas_log(aap,false,sprintf('Strict thresholded image %s sums up to %d vox', ...
V{a}.fname, sum(Y{a}(:))))
- end
+ end
end
- %% DIFFERENT STREAMS FOR DIFFERENT
+ %% OUTPUT
+ outStreams = aas_getstreams(aap,'output');
+ for a = 1:numel(inStreams)-1 % not for reference
+ aap = aas_desc_outputs(aap,subj,outStreams{a},outstream(a,:));
+ end
aap = aas_desc_outputs(aap,subj,'segmasks',outstream);
+ case 'checkrequirements'
+ in = aas_getstreams(aap,'input'); in(1) = []; % not for reference
+ [stagename, index] = strtok_ptrn(aap.tasklist.currenttask.name,'_0');
+ stageindex = sscanf(index,'_%05d');
+ out = aap.tasksettings.(stagename)(stageindex).outputstreams.stream; if ~iscell(out), out = {out}; end
+ for s = 1:numel(in)
+ if ~strcmp(out{s},[in{s} '_mask'])
+ instream = textscan(in{s},'%s','delimiter','.'); instream = instream{1}{end};
+ aap = aas_renamestream(aap,aap.tasklist.currenttask.name,out{s},[instream '_mask'],'output');
+ aas_log(aap,false,['INFO: ' aap.tasklist.currenttask.name ' output stream: ''' [instream '_mask'] '''']);
+ end
+ end
end
diff --git a/aa_modules/aamod_mask_fromsegment.xml b/aa_modules/aamod_mask_fromsegment.xml
index c76f994cc..ca13d4d3e 100644
--- a/aa_modules/aamod_mask_fromsegment.xml
+++ b/aa_modules/aamod_mask_fromsegment.xml
@@ -20,6 +20,9 @@
+ grey_mask
+ white_mask
+ csf_mask
segmasks
diff --git a/aa_modules/aamod_maths.m b/aa_modules/aamod_maths.m
index 9651b5f92..c35ab2355 100644
--- a/aa_modules/aamod_maths.m
+++ b/aa_modules/aamod_maths.m
@@ -1,4 +1,4 @@
-function [aap,resp]=aamod_maths(aap,task,subj,sess)
+function [aap,resp]=aamod_maths(aap,task,varargin)
resp='';
switch task
@@ -10,7 +10,7 @@
outputstreams=aas_getstreams(aap,'output'); ostream = outputstreams{1};
% obtain data
- inputfnameslist = aas_getfiles_bystream(aap,aap.tasklist.currenttask.domain,[subj sess],istream);
+ inputfnameslist = aas_getfiles_bystream(aap,aap.tasklist.currenttask.domain,cell2mat(varargin),istream);
outputfnameslist = '';
for inp = 1:size(inputfnameslist,1)
inputfnames = deblank(inputfnameslist(inp,:));
@@ -53,7 +53,7 @@
nifti_write(outputfnames,dat,funcstr,V);
outputfnameslist(inp,:) = outputfnames;
end
- aap=aas_desc_outputs(aap,aap.tasklist.currenttask.domain,[subj sess],ostream,outputfnameslist);
+ aap=aas_desc_outputs(aap,aap.tasklist.currenttask.domain,cell2mat(varargin),ostream,outputfnameslist);
case 'checkrequirements'
diff --git a/aa_modules/aamod_maths.xml b/aa_modules/aamod_maths.xml
index 792e6f798..4deb8206e 100644
--- a/aa_modules/aamod_maths.xml
+++ b/aa_modules/aamod_maths.xml
@@ -1,6 +1,7 @@
+
diff --git a/aa_modules/aamod_norm_write.m b/aa_modules/aamod_norm_write.m
index b5661e428..f06f3d8dd 100644
--- a/aa_modules/aamod_norm_write.m
+++ b/aa_modules/aamod_norm_write.m
@@ -80,7 +80,7 @@
if ~isempty(interp), flags.interp = interp; end
% find out what streams we should normalise
- streams=aap.tasklist.currenttask.outputstreams.stream;
+ streams=aas_getstreams(aap,'output');
for streamind=1:length(streams)
% Image to reslice
if isstruct(streams{streamind}), streams{streamind} = streams{streamind}.CONTENT; end
diff --git a/aa_modules/aamod_norm_write.xml b/aa_modules/aamod_norm_write.xml
index bacb0ce55..df6fe75c6 100644
--- a/aa_modules/aamod_norm_write.xml
+++ b/aa_modules/aamod_norm_write.xml
@@ -1,7 +1,7 @@
-
+
0.5
@@ -18,11 +18,11 @@
forward_deformation_field
normalisation_seg_sn
structural
- epi
+ epi
- epi
+ epi
diff --git a/aa_modules/aamod_norm_write_RSA.xml b/aa_modules/aamod_norm_write_RSA.xml
deleted file mode 100644
index 690630565..000000000
--- a/aa_modules/aamod_norm_write_RSA.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
- 0.5
- 0.1
-
-
- 2
-
- 2 2 2
- -78 78 -112 76 -70 85
- 4
-
-
- forward_deformation_field
- normalisation_seg_sn
- structural
- RSAmaps
-
-
-
- 1
- RSAmaps
-
-
-
-
-
diff --git a/aa_modules/aamod_norm_write_RSA_dartel.xml b/aa_modules/aamod_norm_write_RSA_dartel.xml
deleted file mode 100644
index 1f43bfd38..000000000
--- a/aa_modules/aamod_norm_write_RSA_dartel.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
- 0.75
- 0.2
-
-
- 2
-
- 1
- 2 2 2
-
- 0
-
-
- dartel_template
- dartel_templatetomni_xfm
- dartel_flowfield
- structural
- RSAmap
-
-
-
- 1
- RSAmap
- dartel_templatetomni_xfm
-
-
-
-
-
-
diff --git a/aa_modules/aamod_norm_write_dartel.m b/aa_modules/aamod_norm_write_dartel.m
index f467aab7a..5920f10e1 100644
--- a/aa_modules/aamod_norm_write_dartel.m
+++ b/aa_modules/aamod_norm_write_dartel.m
@@ -116,7 +116,7 @@
job.preserve = aap.tasklist.currenttask.settings.preserve; % modulation
% find out what streams we should normalise
- streams=aap.tasklist.currenttask.outputstreams.stream;
+ streams=aas_getstreams(aap,'output');
for streamind=1:length(streams)
if ~aas_stream_has_contents(aap,streams{streamind}), continue; end
if isstruct(streams{streamind}), streams{streamind} = streams{streamind}.CONTENT; end
diff --git a/aa_modules/aamod_norm_write_dartel.xml b/aa_modules/aamod_norm_write_dartel.xml
index 180e05ae8..c26dc0ea5 100644
--- a/aa_modules/aamod_norm_write_dartel.xml
+++ b/aa_modules/aamod_norm_write_dartel.xml
@@ -1,7 +1,7 @@
-
+
0.75
@@ -20,11 +20,11 @@
dartel_templatetomni_xfm
dartel_flowfield
structural
- epi
+ epi
- epi
+ epi
dartel_templatetomni_xfm
diff --git a/aa_modules/aamod_roi_extract.m b/aa_modules/aamod_roi_extract.m
index 32b36c266..81cd6b2e5 100644
--- a/aa_modules/aamod_roi_extract.m
+++ b/aa_modules/aamod_roi_extract.m
@@ -58,7 +58,7 @@
inputstreams = aas_getstreams(aap,'input');
% first input stream is the roi stream, all others are data
[roistream, inputstreams] = deal(inputstreams(1),inputstreams(2:end));
- ROIfile = aas_getfiles_bystream(aap,aap.tasklist.currenttask.domain,[varargin{:}],roistream{1});
+ ROIfile = aas_getfiles_bystream_multilevel(aap,aap.tasklist.currenttask.domain,[varargin{:}],roistream{1});
for in = inputstreams
instream = in{1};
diff --git a/aa_modules/aamod_segment8.m b/aa_modules/aamod_segment8.m
index 739b4d70e..1c8251ea0 100644
--- a/aa_modules/aamod_segment8.m
+++ b/aa_modules/aamod_segment8.m
@@ -331,15 +331,15 @@ function diag(aap,subj) % [TA]
Simg = aas_getfiles_bystream(aap,subj,'structural');
localpath = aas_getsubjpath(aap,subj);
outSeg = char(...
- aas_getfiles_bystream(aap,subj,'native_grey'),...
+ aas_getfiles_bystream(aap,subj,'native_csf'),...
aas_getfiles_bystream(aap,subj,'native_white'),...
- aas_getfiles_bystream(aap,subj,'native_csf'));
+ aas_getfiles_bystream(aap,subj,'native_grey'));
outNSeg = char(...
- aas_getfiles_bystream(aap,subj,'normalised_density_grey'),...
+ aas_getfiles_bystream(aap,subj,'normalised_density_csf'),...
aas_getfiles_bystream(aap,subj,'normalised_density_white'),...
- aas_getfiles_bystream(aap,subj,'normalised_density_csf'));
+ aas_getfiles_bystream(aap,subj,'normalised_density_grey'));
-OVERcolours = {[1 0 0], [0 1 0], [0 0 1]};
+OVERcolours = aas_colours;
%% Draw native template
spm_check_registration(Simg)
diff --git a/aa_modules/aamod_structuralfromnifti.m b/aa_modules/aamod_structuralfromnifti.m
index 35093650d..d009a4526 100644
--- a/aa_modules/aamod_structuralfromnifti.m
+++ b/aa_modules/aamod_structuralfromnifti.m
@@ -38,6 +38,8 @@
end
end
+ sesspth=fullfile(aas_getsubjpath(aap,subj),aap.directory_conventions.structdirname);
+ aas_makedir(aap,sesspth);
Ys = 0;
for s = 1:numel(series)
niftifile = series(s).fname;
@@ -51,20 +53,18 @@
end
end
comp = false;
- if strcmp(spm_file(niftifile,'Ext'),'gz'),
+ if strcmp(spm_file(niftifile,'Ext'),'gz')
comp = true;
- gunzip(niftifile);
- niftifile = niftifile(1:end-3);
+ gunzip(niftifile,fullfile(sesspth,'temp'));
+ niftifile = spm_file(niftifile(1:end-3),'path',fullfile(sesspth,'temp'));
end
- sesspth=fullfile(aas_getsubjpath(aap,subj),aap.directory_conventions.structdirname);
- aas_makedir(aap,sesspth);
fn(s,:)=spm_file(niftifile,'path',sesspth,'suffix','_0001');
V(s)=spm_vol(niftifile);
Y=spm_read_vols(V(s));
V(s).fname=deblank(fn(s,:));
V(s).n=[1 1];
- if comp, delete(niftifile); end
+ if comp, rmdir(fullfile(sesspth,'temp'),'s'); end
if aap.options.(['autoidentify' stream '_average'])
Ys = Ys + Y/numel(series);
diff --git a/aa_toolbox/aa_build_standalone_2_build.m b/aa_toolbox/aa_build_standalone_2_build.m
index 4f76b289a..711bf3af4 100644
--- a/aa_toolbox/aa_build_standalone_2_build.m
+++ b/aa_toolbox/aa_build_standalone_2_build.m
@@ -38,6 +38,7 @@ function aa_build_standalone_2_build(config, outdir)
aap.directory_conventions.DCMTKdir,...
aap.directory_conventions.templatedir...
}];
+toolsdir = toolsdir(cellfun(@(x) ~isempty(x), toolsdir));
toolsdir = mcc_a(toolsdir);
aas_makedir(aap,outdir);
@@ -56,8 +57,8 @@ function aa_build_standalone_2_build(config, outdir)
'-a',aap.directory_conventions.spmdir,...
toolsdir{:},...
'aa_standalone.m');
-catch
- warning('Error during compilation!')
+catch E
+ warning(E.identifier,'Error during compilation: %s\nSetting the environmental variable MCC_USE_DEPFUN to 1 before launching MATLAB may solve the issue.',E.message)
end
aa_close(aap);
diff --git a/aa_toolbox/aa_export_toBIDS.m b/aa_toolbox/aa_export_toBIDS.m
index 364ce7d99..9410baa8e 100644
--- a/aa_toolbox/aa_export_toBIDS.m
+++ b/aa_toolbox/aa_export_toBIDS.m
@@ -4,7 +4,7 @@ function aa_export_toBIDS(varargin)
%
% This function can run standalone or be included at the end of a userscript.
%
-% usage: aa_export_toBIDS([aap,] dest[, 'anatt1', ][, 'anatt2', ])
+% usage: aa_export_toBIDS([aap,] dest[, 'anatt1', ][, 'anatt2', ][, 'model', |'session'])
%
% also uses: aap.directory_conventions.BIDSfiles
%
@@ -13,7 +13,8 @@ function aa_export_toBIDS(varargin)
% 1) aa_export_toBIDS('/put/results/here');
% 2) aa_export_toBIDS(aap,'/put/results/here');
% 3) aa_export_toBIDS('put/results/here','anatt1','aamod_freesurfer_deface_00001|defaced_structural')
-% 4) aa_export_toBIDS(aap,'put/results/here','anatt1','aamod_freesurfer_deface_00001|defaced_structural')
+% 4) aa_export_toBIDS('put/results/here','model',1)
+% 5) aa_export_toBIDS('put/results/here','model','session')
%
% notes
%
@@ -23,7 +24,7 @@ function aa_export_toBIDS(varargin)
% reason you would ever pass in aap, assuming you first cd to the directory
% where aap_parameters.mat lives
%
-% b) example usage #3 and #4 shows how to override the default structural
+% b) example usage #3 shows how to override the default structural
% (i.e. t1) file to copy (in this example a defaced structural is used, which
% is probably required if you're going to upload results to a public
% repository like openfMRI. The syntax goes: stage|streamname. If you don't
@@ -31,7 +32,11 @@ function aa_export_toBIDS(varargin)
% of t1 [t2] in the analysis tasklist will be used, which is probably the
% output from dicom covert (which is not defaced).
%
-% c) BIDS requires three files to appear in the top level directory:
+% c) eample usage #4 and #5 show how to select model to extract events. aa
+% uses the first model by default. A number here can specify a certain
+% model, while 'session' tells aa that every session has its own specific model.
+%
+% d) BIDS requires three files to appear in the top level directory:
%
% README - a plaintext (ASCII or UTF-8) description of the data
% CHANGES- a plaintext (ASCII or UTF-8) list of version changes
@@ -49,12 +54,10 @@ function aa_export_toBIDS(varargin)
%
% This function is a work in progress. TODO:
%
+% - multi-model
% - multi-session
-% - multi-run
% - covariates
% - parametric
-% - multi-model
-
if isstruct(varargin{1})
aap = varargin{1};
@@ -67,6 +70,7 @@ function aa_export_toBIDS(varargin)
varargin(1) = [];
end
args = vargParser(varargin);
+if ~isfield(args,'model'), args.model = 1; end % default model
% identify source stages present from the tasklist
@@ -152,6 +156,7 @@ function aa_export_toBIDS(varargin)
aas_log(aap,false,'WARNING: No header is available!')
else
loaded = load(fhdr); hdr = loaded.dcmhdr;
+ if iscell(hdr), hdr = hdr{1}; end; hdr = hdr(1);
json = struct(...
'RepetitionTime',hdr.volumeTR,...
'EchoTime',hdr.volumeTE,...
@@ -207,18 +212,35 @@ function aa_export_toBIDS(varargin)
aap = aas_setcurrenttask(aap,stage_func);
for sess = 1:numel(aap.acq_details.sessions)
- aas_log(aap,false,['\tINFO: Exporting fMRI session: ' aas_getsessname(aap,sess)])
- src = aas_getfiles_bystream(aap,'session',[subj sess],'epi','output');
- fhdr = aas_getfiles_bystream(aap,'session',[subj sess],'epi_dicom_header','output');
-
+ taskname = aas_getsessname(aap,sess);
+ aas_log(aap,false,['\tINFO: Exporting fMRI session: ' taskname])
+ src_main = aas_getfiles_bystream(aap,'session',[subj sess],'epi','output');
+
% image
- if isempty(src)
+ if isempty(src_main)
aas_log(aap,false,'WARNING: No image is available!')
continue;
end
+
+ if any(strcmp(aas_getstreams(aap,'output'),'dummyscans'))
+ src = spm_file(tempname,'ext','nii');
+ src_dummy = aas_getfiles_bystream(aap,'session',[subj sess],'dummyscans','output');
+ spm_file_merge(char(src_dummy,src_main),src);
+ else
+ src = src_main;
+ end
+ fhdr = aas_getfiles_bystream(aap,'session',[subj sess],'epi_dicom_header','output');
+
+ isRun = regexp(taskname,'[_-]?[rR]un[0-9]*$');
+ if isRun
+ taskname = taskname(1:isRun-1);
+ runNo = str2double(regexp(aap.acq_details.sessions(sess).name(isRun:end),'[0-9]*','match'));
+ end
+
aas_makedir(aap,fullfile(subjpath,'func'));
- dest = fullfile(subjpath,'func',sprintf('%s_task-%s_bold.nii',suboutname,valueValidate(aap.acq_details.sessions(sess).name)));
- copyfile(src,dest); gzip(dest); delete(dest);
+ dest = fullfile(subjpath,'func',sprintf('%s_task-%s_bold.nii',suboutname,valueValidate(taskname)));
+ if isRun, dest = strrep(dest,'bold.nii',sprintf('run-%d_bold.nii',runNo)); end
+ copyfile(src,dest); gzip(dest); delete(dest); if exist('src_dummy','var'), delete(src); clear src_dummy; end
% header
loaded = load(fhdr); hdr = loaded.DICOMHEADERS{1};
@@ -234,19 +256,28 @@ function aa_export_toBIDS(varargin)
'PhaseEncodingDirection',[...
sliceaxes{cell_index(sliceaxes(:,1),deblank(hdr.InPlanePhaseEncodingDirection)),2}{aas_get_numaris4_numval(hdr.CSAImageHeaderInfo,'PhaseEncodingDirectionPositive')+1}...
],...
- 'TaskName',aap.acq_details.sessions(sess).name ...
+ 'TaskName',taskname ...
);
savejson('',json,spm_file(dest,'ext','json'));
end
% events
- if ~isfield(aap.tasksettings,'aamod_firstlevel_model')
+ stageModels = aap.tasklist.main.module(strcmp({aap.tasklist.main.module.name},'aamod_firstlevel_model'));
+
+ if isempty(stageModels)
aas_log(aap,false,'WARNING: No model information is available!')
continue
- end
+ end
- models = aap.tasksettings.aamod_firstlevel_model(1).model(2:end);
+ switch args.model
+ case 'session'
+ stageindex = strcmp(arrayfun(@(x) x.extraparameters.aap.acq_details.selected_sessions, stageModels,'UniformOutput',false),aas_getsessname(aap,sess));
+ otherwise
+ stageindex = args.model;
+ end
+
+ models = aap.tasksettings.aamod_firstlevel_model(stageindex).model(2:end);
selected_model = (strcmp({models.subject},aas_getsubjname(aap,subj)) | strcmp({models.subject},'*')) & ...
(strcmp({models.session},aap.acq_details.sessions(sess).name) | strcmp({models.session},'*'));
if ~any(selected_model)
@@ -328,19 +359,28 @@ function aa_export_toBIDS(varargin)
aap = aas_setcurrenttask(aap,stage_dwi);
for sess = 1:numel(aap.acq_details.diffusion_sessions)
aas_log(aap,false,['\tINFO: Exporting DWI session: ' aas_getsessname(aap,sess)])
- src = aas_getfiles_bystream(aap,'diffusion_session',[subj sess],'diffusion_data','output');
- aap.options.verbose = -1;
- fhdr = aas_getfiles_bystream(aap,'diffusion_session',[subj sess],'diffusion_dicom_header','output');
- aap.options.verbose = 2;
-
+ src_main = aas_getfiles_bystream(aap,'diffusion_session',[subj sess],'diffusion_data','output');
+
% image
- if isempty(src)
+ if isempty(src_main)
aas_log(aap,false,'WARNING: No image is available!')
continue;
end
+
+ if any(strcmp(aas_getstreams(aap,'output'),'dummyscans'))
+ src = spm_file(tempname,'ext','nii');
+ src_dummy = aas_getfiles_bystream(aap,'session',[subj sess],'dummyscans','output');
+ spm_file_merge(char(src_dummy,src_main),src);
+ else
+ src = src_main;
+ end
+ aap.options.verbose = -1;
+ fhdr = aas_getfiles_bystream(aap,'diffusion_session',[subj sess],'diffusion_dicom_header','output');
+ aap.options.verbose = 2;
+
aas_makedir(aap,fullfile(subjpath,'dwi'));
dest = fullfile(subjpath,'dwi',sprintf('%s_dwi.nii',suboutname));
- copyfile(src,dest); gzip(dest); delete(dest);
+ copyfile(src,dest); gzip(dest); delete(dest); if exist('src_dummy','var'), delete(src); clear src_dummy; end
% header
if isempty(fhdr)
diff --git a/aa_toolbox/aa_standalone.m b/aa_toolbox/aa_standalone.m
index 0bde22443..bfad3c175 100644
--- a/aa_toolbox/aa_standalone.m
+++ b/aa_toolbox/aa_standalone.m
@@ -39,8 +39,6 @@ function aa_standalone(fname_config, fname_tasklist, fname_aa, varargin)
xml_aa = xml_read(fname_aa,struct('ReadAttr',0));
aap = recursive_set(aap,xml_aa);
-% templates
-if strcmp(spm('Ver'),'SPM12'), aap = aas_configforSPM12(aap); end
% check path to T1 template --> the rest should work, too
if exist(fullfile(aap.directory_conventions.spmdir,aap.directory_conventions.T1template),'file')
aas_log(aap,false,['INFO: T1 template located in ' fullfile(aap.directory_conventions.spmdir,aap.directory_conventions.T1template)]);
diff --git a/aa_toolbox/provenance/aa-o.ttl b/aa_toolbox/provenance/aa-o.ttl
index 525cc499a..2fc960d81 100644
--- a/aa_toolbox/provenance/aa-o.ttl
+++ b/aa_toolbox/provenance/aa-o.ttl
@@ -5,8 +5,9 @@
@prefix xml: .
@prefix xsd: .
@prefix prov: .
+@prefix provone: .
@prefix rdfs: .
-@base .
+@base .
rdf:type owl:Ontology ;
@@ -173,7 +174,7 @@
:module rdf:type owl:Class ;
- rdfs:subClassOf prov:Activity ;
+ rdfs:subClassOf provone:ProcessExec ;
rdfs:seeAlso "http://automaticanalysis.org/getting-started/aa-orientation-components/" ;
@@ -186,7 +187,7 @@
:stream rdf:type owl:Class ;
rdfs:subClassOf nfo:LocalFileDataObject ,
- prov:Collection ;
+ provone:Data ;
rdfs:seeAlso "http://automaticanalysis.org/getting-started/streams-work/" ;
diff --git a/aa_toolbox/provenance/aa_provenance.m b/aa_toolbox/provenance/aa_provenance.m
index 48df1f2bb..1c3a34855 100644
--- a/aa_toolbox/provenance/aa_provenance.m
+++ b/aa_toolbox/provenance/aa_provenance.m
@@ -3,7 +3,7 @@
classdef aa_provenance < handle
properties
- version = '0.0.1'
+ version = '0.2.0'
pp
p
isvalid = false
@@ -16,7 +16,7 @@
relations = {}
- % so far only one subject and sessopn is supported
+ % so far only one subject and session is supported
indices = [1 1 1]
end
@@ -37,9 +37,11 @@
% Initialise
obj.pp = feval(basename(obj.provlib));
obj.pp.add_namespace('nfo','http://www.semanticdesktop.org/ontologies/2007/03/22/nfo');
- obj.pp.add_namespace('aa','http://automaticanalysis.org/'); % TODO: place
- obj.pp.add_namespace('nidm','http://www.incf.org/ns/nidash/nidm#');
- obj.pp.add_namespace('spm','http://www.incf.org/ns/nidash/spm#');
+ obj.pp.add_namespace('provone','http://purl.org/provone#');
+ obj.pp.add_namespace('nidm','http://purl.org/nidash/nidm#');
+ obj.pp.add_namespace('nidmw','http://purl.org/nidash/nidm/workflow#');
+ obj.pp.add_namespace('spm','http://purl.org/nidash/spm#');
+ obj.pp.add_namespace('aa','http://purl.org/aa#');
% agents
% Parallel Computing
@@ -49,25 +51,27 @@
});
% MATLAB
- obj.pp.agent('idMATLAB1',{...
- 'prov:type','prov:SoftwareAgent',...
- 'prov:label',{'MATLAB','xsd:string'},...
- 'aa:version',{version,'xsd:string'},...
- 'nfo:belongsToContainer',{matlabroot, 'nfo:Folder'},...
- 'aa:runs','idaa1',...
- });
+ if isfield(obj.aap.internal,'matlabversion')
+ obj.pp.agent('idMATLAB1',{...
+ 'prov:type','prov:SoftwareAgent',...
+ 'prov:label',{'MATLAB','xsd:string'},...
+ 'aa:version',{obj.aap.internal.matlabversion,'xsd:string'},...
+ 'nfo:belongsToContainer',{obj.aap.internal.matlabpath, 'nfo:Folder'},...
+ 'aa:runs','idaa1',...
+ });
+ else
+ obj.pp.agent('idMATLAB1',{...
+ 'prov:type','prov:SoftwareAgent',...
+ 'prov:label',{'MATLAB','xsd:string'},...
+ });
+ end
% aa
- global aa
- if ~isobject(aa)
- aa = aaClass;
- end
- aagent = aa;
obj.pp.agent('idaa',{...
'prov:type','aa:PipelineProcessor',...
- 'prov:label',aagent.Name,...
- 'nfo:belongsToContainer',{aagent.Path, 'nfo:Folder'},...
- 'aa:version',{aagent.Version,'xsd:string'},...
+ 'prov:label','automaticanalysis',...
+ 'nfo:belongsToContainer',{obj.aap.internal.aappath, 'nfo:Folder'},...
+ 'aa:version',{obj.aap.internal.aapversion,'xsd:string'},...
'aa:isTrackKeeping','1',...
'aa:hasParallelComputing','idPCP1',...
'aa:runs','idSPM1',...
@@ -76,20 +80,25 @@
});
% SPM
- spmdir0 = fileparts(which('spm'));
- spmdir = obj.aap.directory_conventions.spmdir;
- rmpath(spmdir0); addpath(spmdir);
- [V,R] = spm('Ver');
- rmpath(spmdir); addpath(spmdir0);
- obj.pp.agent('idSPM1',{...
- 'prov:type','nidm:SPM',...
- 'prov:type','prov:SoftwareAgent',...
- 'prov:label',{'SPM','xsd:string'},...
- 'aa:version',{V,'xsd:string'},...
- 'spm:softwareRevision',{R,'xsd:string'},...
- 'nfo:belongsToContainer',{spmdir, 'nfo:Folder'},...
- });
-
+ if isfield(obj.aap.internal,'matlabversion')
+ [V, R] = strtok(obj.aap.internal.spmversion);
+ R = regexp(R,'[0-9]*','match'); R = R{1};
+ obj.pp.agent('idSPM1',{...
+ 'prov:type','nidm:SPM',...
+ 'prov:type','prov:SoftwareAgent',...
+ 'prov:label',{'SPM','xsd:string'},...
+ 'aa:version',{V,'xsd:string'},...
+ 'spm:softwareRevision',{R,'xsd:string'},...
+ 'nfo:belongsToContainer',{obj.aap.internal.spmpath, 'nfo:Folder'},...
+ });
+ else
+ obj.pp.agent('idSPM1',{...
+ 'prov:type','nidm:SPM',...
+ 'prov:type','prov:SoftwareAgent',...
+ 'prov:label',{'SPM','xsd:string'},...
+ });
+ end
+
% FSL
fsldir = obj.aap.directory_conventions.fsldir;
fslversion = importdata(fullfile(fsldir,'etc','fslversion'));
@@ -200,7 +209,7 @@ function serialise(obj,serpath)
for i = 1:numel(inputs)
istream = inputs{i};
if any(istream=='.')
- [junk, istream] = strtok(istream,'.');
+ [istage, istream] = strtok(istream,'.');
istream = istream(2:end);
end
isOptional = numel(inputattrs)>=i && isstruct(inputattrs{i}) && isfield(inputattrs{i},'isessential') && ~inputattrs{i}.isessential;
@@ -220,10 +229,11 @@ function serialise(obj,serpath)
if srcindex == -1 % remote src --> add
% [junk,src] = strtok(src,':'); src = src(3:end);
rstage = smod.remotestream(strcmp({smod.remotestream.stream},istream));
- if isempty(rstage) % try specified steamname
- [junk,rem] = strtok_ptrn({smod.remotestream.stream},istream);
- rstage = smod.remotestream(strcmp(rem,istream));
- end
+ if isempty(rstage), rstage = smod.remotestream(strcmp({smod.remotestream.stream},[istage '.' istream])); end % try current specified steamname
+% if isempty(rstage) % try any specified steamname
+% [junk,rem] = strtok_ptrn({smod.remotestream.stream},istream);
+% rstage = smod.remotestream(strcmp(rem,istream));
+% end
idsrc = obj.addModule(rstage);
else % local --> already added
src = sprintf('%s_%05d',curr_aap.tasklist.main.module(srcindex).name,curr_aap.tasklist.main.module(srcindex).index);
diff --git a/examples/aa_user_bids_ds000114.m b/examples/aa_user_bids_ds000114.m
index 06669becd..14180aa1b 100644
--- a/examples/aa_user_bids_ds000114.m
+++ b/examples/aa_user_bids_ds000114.m
@@ -47,7 +47,7 @@
['multiple reference to "' rawdir '" BIDS directory in aap.directory_conventions.rawdatadir'])
aap.directory_conventions.rawdatadir = sources{bidsind};
-aap.acq_details.numdummies = 0;
+aap.acq_details.numdummies = 1;
aap.acq_details.input.combinemultiple = 1;
aap.options.autoidentifystructural_choosefirst = 1;
diff --git a/examples/cbu/aa_user_diffusion.m b/examples/cbu/aa_user_diffusion.m
index 668cba886..96bceb314 100644
--- a/examples/cbu/aa_user_diffusion.m
+++ b/examples/cbu/aa_user_diffusion.m
@@ -25,8 +25,8 @@
%% DEFINE SPECIFIC PARAMETERS
aap=aarecipe('aap_tasklist_diffusion.xml');
-aap = aas_renamestream(aap,'aamod_diffusion_dartel_denormDKI_00001','normalised_grey','normalised_white');
-aap = aas_renamestream(aap,'aamod_diffusion_dartel_denormDKI_00001','native_grey','native_white','output');
+aap = aas_renamestream(aap,'aamod_diffusion_dartel_denormDKI_00001','grey','normalised_white', 'input');
+aap = aas_renamestream(aap,'aamod_diffusion_dartel_denormDKI_00001','grey','native_white','output');
% Modify standard recipe module selection here if you'd like
aap.options.wheretoprocess = 'qsub'; % queuing system % typical value localsingle or qsub
diff --git a/examples/cbu/aa_user_diffusion_with_topup.m b/examples/cbu/aa_user_diffusion_with_topup.m
index fa9dce1a7..0acd6b9bc 100755
--- a/examples/cbu/aa_user_diffusion_with_topup.m
+++ b/examples/cbu/aa_user_diffusion_with_topup.m
@@ -24,8 +24,8 @@
% Default recipe without model
aap=aarecipe('aap_tasklist_diffusion_with_topup.xml');
-aap = aas_renamestream(aap,'aamod_diffusion_dartel_denormDKI_00001','normalised_grey','normalised_white');
-aap = aas_renamestream(aap,'aamod_diffusion_dartel_denormDKI_00001','native_grey','native_white','output');
+aap = aas_renamestream(aap,'aamod_diffusion_dartel_denormDKI_00001','grey','normalised_white', 'input');
+aap = aas_renamestream(aap,'aamod_diffusion_dartel_denormDKI_00001','grey','native_white','output');
% Modify standard recipe module selection here if you'd like
aap.options.wheretoprocess = 'qsub'; % queuing system % typical value localsingle or qsub
diff --git a/external/tsdiffana/tsdiffplot.m b/external/tsdiffana/tsdiffplot.m
index 896642471..f3e4fdcaf 100644
--- a/external/tsdiffana/tsdiffplot.m
+++ b/external/tsdiffana/tsdiffplot.m
@@ -11,7 +11,7 @@
% or selected via the GUI if not present
if nargin < 1
- tdfn = spm_get(1, 'timediff.mat', 'Select time diff information');
+ tdfn = spm_select(1, 'timediff.mat', 'Select time diff information');
end
if nargin < 2
fgs = [];
@@ -66,9 +66,9 @@
slicemean_norm = qa.slice.mean - repmat(mean(qa.slice.mean,1),size(qa.slice.mean,1),1);
datatoplot = {...
- {@plot 2:imgno qa.global.diff/mom '-' 'Volume' 'Scaled variance'} {@imagesc 1:imgno 1:zno slicemean_norm' 'Volume' 'Scaled mean slice intensity'};...
- {@plot 2:imgno sslicediff '*' 'Volume' 'Slice by slice variance'} {@imagesc 2:imgno-1 1:zno log(qa.slice.fft)' 'Number of cycles in timecourse' 'FFT of slice intensity [log]'};...
- {@plot 1:imgno qa.global.mean/mom '-' 'Volume' 'Scaled mean voxel intensity'} {@plot 2:imgno-1 log(qa.global.fft) '-' 'Number of cycles in timecourse' 'FFT of mean intensity [log]'};...
+ {{@plot} 2:imgno qa.global.diff/mom '-' 'Volume' 'Scaled variance'} {{@imagesc @colorbar} 1:imgno 1:zno slicemean_norm' 'Volume' 'Scaled mean slice intensity'};...
+ {{@imagesc @colorbar} 2:imgno 1:zno sslicediff' 'Volume' 'Scaled slice variance'} {{@imagesc @colorbar} 2:imgno-1 1:zno log(qa.slice.fft)' 'Number of cycles in timecourse' 'FFT of slice intensity [log]'};...
+ {{@plot} 1:imgno qa.global.mean/mom '-' 'Volume' 'Scaled mean voxel intensity'} {{@plot} 2:imgno-1 log(qa.global.fft) '-' 'Number of cycles in timecourse' 'FFT of mean intensity [log]'};...
};
@@ -81,15 +81,15 @@
for p = 1:size(datatoplot,1)
h1 = axes('position', [.1 1-(.7+p-1)/subpno .6958 .65*1/subpno]);
- h2 = datatoplot{p,m}{1}(datatoplot{p,m}{2:4});
+ h2 = datatoplot{p,m}{1}{1}(datatoplot{p,m}{2:4});
axis([0.5 imgno+0.5 -Inf Inf]);
set(h1,'xtick',dxt);
xlabel(datatoplot{p,m}{5});
ylabel(datatoplot{p,m}{6});
- if strcmp(func2str(datatoplot{p,m}{1}),'imagesc')
- colormap('jet')
+ if strcmp(func2str(datatoplot{p,m}{1}{1}),'imagesc'), colormap('jet'); end
+ if numel(datatoplot{p,m}{1}) > 1
pos = get(h1,'position');
- colorbar;
+ datatoplot{p,m}{1}{2}();
set(h1,'position',pos);
end
hs = [hs; h2];
@@ -100,16 +100,11 @@
mx = max(sslicediff);
mn = min(sslicediff);
avg = mean(sslicediff);
- h2 = plot(avg, 'k');
- axis([0 zno+1 -Inf Inf]);
- hold on
- h3 = plot(mn, 'b');
- h4 = plot(mx, 'r');
- hold off
+ h2 = errorbar(1:zno,avg,mn-avg,mx-avg,'r*','MarkerEdgeColor','k');
xlabel('Slice');
ylabel('Slice variance');
- legend('Mean','Min','Max','Location','Best');
- hs = [hs; h2; h3; h4];
+ legend(sprintf('Mean\nMin-Max'),'Location','Best');
+ hs = [hs; h2];
end
% realignment params
diff --git a/extrafunctions/make_stats_table.m b/extrafunctions/make_stats_table.m
index 873404931..4363f2a2b 100644
--- a/extrafunctions/make_stats_table.m
+++ b/extrafunctions/make_stats_table.m
@@ -117,7 +117,7 @@ function make_stats_table(varargin)
[p,n,~] = fileparts(fname);
fname = fullfile(p,[n '.jpg']);
- print(hreg, '-djpeg', '-r200', fname);
+ print(hreg, '-djpeg', '-r200', fname, '-noui');
close(hreg);
diff --git a/extrafunctions/meminfo.m b/extrafunctions/meminfo.m
index 3abb59b4f..d2453747c 100644
--- a/extrafunctions/meminfo.m
+++ b/extrafunctions/meminfo.m
@@ -48,26 +48,31 @@
% limits
- [ status, result ] = system('ulimit -m');
-
- result = deblank(result);
-
- if strcmp(result,'unlimited')
- M.ResLimit = Inf;
- else
- M.ResLimit = str2double(result);
- end
-
- [ status, result ] = system('ulimit -v');
-
- result = deblank(result);
-
- if strcmp(result,'unlimited')
- M.VirtLimit = Inf;
- else
- M.VirtLimit = str2double(result);
- end
-
+ try
+ [ status, result ] = system('ulimit -m');
+ result = deblank(result);
+ if strcmp(result,'unlimited')
+ M.ResLimit = Inf;
+ else
+ M.ResLimit = str2double(result);
+ end
+ catch
+ fprintf('ulimit not available, defaulting to inf\n');
+ M.ResLimit = Inf;
+ end
+
+ try
+ [ status, result ] = system('ulimit -v');
+ result = deblank(result);
+ if strcmp(result,'unlimited')
+ M.VirtLimit = Inf;
+ else
+ M.VirtLimit = str2double(result);
+ end
+ catch
+ M.VirtLimit = Inf;
+ end
+
% process
% assuming ps returns results in KB
@@ -101,13 +106,24 @@
% limits
- [junk, out] = aas_shell('ulimit -m',true); out = deblank(out);
- if strcmp(out,'unlimited'), dat = Inf;
- else dat = str2double(out); end
+ try
+ [junk, out] = aas_shell('ulimit -m',true);
+ out = deblank(out);
+ if strcmp(out,'unlimited'), dat = Inf;
+ else dat = str2double(out); end
+ catch
+ fprintf('ulimit not available, defaulting to inf\n');
+ dat = Inf;
+ end
M.ResLimit = dat;
- [junk, out] = aas_shell('ulimit -v',true); out = deblank(out);
- if strcmp(out,'unlimited'), dat = Inf;
- else dat = str2double(out); end
+
+ try
+ [junk, out] = aas_shell('ulimit -v',true);
+ out = deblank(out);
+ if strcmp(out,'unlimited'), dat = Inf;
+ else dat = str2double(out); end
+ catch
+ dat = Inf;
M.VirtLimit = dat;
% process