Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/batches/preproc/setBatchSTC.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
%
% (C) Copyright 2019 CPP_SPM developers

% TODO with multitask support it is even more needed to check
% that all files have the same slice timing and that might not be the case
% reflected in opt.metadata

p = inputParser;

addRequired(p, 'matlabbatch', @iscell);
Expand Down Expand Up @@ -60,12 +64,10 @@
printBatchName('slice timing correction', opt);

% get metadata for STC
% Note that slice ordering is assumed to be from foot to head. If it is not, enter
% instead: TR - INTRASCAN_TIME - SLICE_TIMING_VECTOR

% SPM accepts slice time acquisition as inputs for slice order (simplifies
% things when dealing with multiecho data)
nbSlices = length(sliceOrder); % unique is necessary in case of multi echo
% SPM accepts slice time acquisition as inputs for slice order
% (simplifies things when dealing with multiecho data)
nbSlices = length(sliceOrder);
TR = opt.metadata.RepetitionTime;
TA = TR - (TR / nbSlices);
% round acquisition time to the upper millisecond
Expand Down Expand Up @@ -125,7 +127,6 @@
BIDS, ...
subLabel, sessions{iSes}, runs{iRun}, opt);

% % TODO remove this validation
file = validationInputFile(subFuncDataDir, fileName);

% add the file to the list
Expand All @@ -141,8 +142,4 @@

matlabbatch{end + 1}.spm.temporal = temporal;

% The following lines are commented out because those parameters
% can be set in the spm_my_defaults.m
% matlabbatch{1}.spm.temporal.st.prefix = spm_get_defaults('slicetiming.prefix');

end
23 changes: 0 additions & 23 deletions src/templates/setBatchTemplate.m

This file was deleted.

24 changes: 0 additions & 24 deletions src/templates/templateFunction.m

This file was deleted.

42 changes: 0 additions & 42 deletions src/templates/templateFunctionExample.m

This file was deleted.

72 changes: 0 additions & 72 deletions src/templates/templateGetOption.m

This file was deleted.

2 changes: 1 addition & 1 deletion src/workflows/preproc/bidsSTC.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function bidsSTC(opt)
% If no slice timing information is available from the file metadata or from
% the ``opt`` strcuture this step will be skipped.
%
% See also: getSliceOrder()
% See also: setBatchSTC, getSliceOrder
%
% See the documentation for more information about slice timing correction.
%
Expand Down
70 changes: 70 additions & 0 deletions templates/batch.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
function matlabbatch = batch(varargin)
%
% Short batch description
%
% USAGE::
%
% matlabbatch = setBatchTemplate(matlabbatch, BIDS, opt, subLabel)
%
% :param matlabbatch: matlabbatch to append to.
% :type matlabbatch: cell
% :param BIDS: BIDS layout returned by ``getData`` or ``bids.layout`.
% :type BIDS: structure
% :param opt: structure or json filename containing the options. See
% ``checkOptions()`` and ``loadAndCheckOptions()``.
% :type opt: structure
% :param subLabel: subject label
% :type subLabel: string
%
%
% :returns: - :matlabbatch: (cell) The matlabbatch ready to run the spm job
%
%
% Example::
%
%
% (C) Copyright 2021 CPP_SPM developers

p = inputParser;

addRequired(p, 'matlabbatch', @iscell);
addRequired(p, 'BIDS', @isstruct);
addRequired(p, 'opt', @isstruct);
addRequired(p, 'subLabel', @ischar);

parse(p, varargin{:});

matlabbatch = p.Results.matlabbatch;
BIDS = p.Results.BIDS;
opt = p.Results.opt;
subLabel = p.Results.subLabel;

printBatchName('name for this batch');

for iTask = 1:numel(opt.taskName)

opt.query.task = opt.taskName{iTask};

[sessions, nbSessions] = getInfo(BIDS, subLabel, opt, 'Sessions');

for iSes = 1:nbSessions

% get all runs for that subject across all sessions
[runs, nbRuns] = getInfo(BIDS, subLabel, opt, 'Runs', sessions{iSes});

for iRun = 1:nbRuns

something = foo();

end

runCounter = runCounter + 1;
end

end

matlabbatch{end + 1}.spm.something = something;
matlabbatch{end}.spm.else = faa;
matlabbatch{end}.spm.other = fii;

end
44 changes: 44 additions & 0 deletions templates/getOption.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function opt = getOption()
%
% returns a structure that contains the options chosen for preprocessing
%
%
% (C) Copyright 2021 CPP_SPM developers

if nargin < 1
opt = [];
end

% task to analyze
opt.taskName = 'balloonanalogrisktask';

% The directory where the data are located
opt.dir.raw = FIXME;
opt.dir.derivatives = FIXME;

% Options for slice time correction
% If left unspecified the slice timing will be done using the mid-volume acquisition
% time point as reference.
% opt.STC_referenceSlice = [];

% when opt.ignoreFieldmaps is set to false, the
% preprocessing pipeline will look for the voxel displacement maps (created by
% the corresponding workflow) and will use them for realign and unwarp
% opt.ignoreFieldmaps = false;

% session number and type of the anatomical reference
% opt.anatReference.type = 'T1w';
% opt.anatReference.session = 1;

% any voxel with p(grayMatter) + p(whiteMatter) + p(CSF) > threshold
% will be included in the skull stripping mask
% opt.skullstrip.threshold = 0.75;

% space where we conduct the analysis
% opt.space = 'MNI';

% Options for normalize
% Voxel dimensions for resampling at normalization of functional data or leave empty [ ].
% opt.funcVoxelDims = [];

end
43 changes: 43 additions & 0 deletions templates/newFunction.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function vargarout = newFunction(varargin)
%
% Short description of what the function does goes here.
%
% USAGE::
%
% [foo, faa, fi] = newFunction(foo, faa, fii, 'boo')
%
% :param foo: obligatory argument. Lorem ipsum dolor sit amet,
% :type foo: cell
% :param faa: optional argument. Lorem ipsum dolor sit amet,
% :type faa: structure
% :param fii: parameter. default: ``boo``
% :type fii: string
%
% :returns: - :foo: (type) (dimension)
% - :faa: (type) (dimension)
% - :fii: (type) (dimension)
%
% Example::
%
% (C) Copyright 2021 CPP_SPM developers

% The code goes below

p = inputParser;

default_faa = [];
default_fii = 'boo';

addRequired(p, 'foo', @iscell);
addOptional(p, 'faa', default_faa, @isstruct);
addParameter(p, 'fii', default_fii, @ischar);

parse(p, varargin{:});

foo = p.Results.foo;
faa = p.Results.faa;
fii = p.Results.fii;

vargarout = {foo, faa, fii};

end
Loading