Skip to content

Commit 4afe4a9

Browse files
committed
series of small fixes after testing pipeline on demo
1 parent f2dec7c commit 4afe4a9

8 files changed

Lines changed: 35 additions & 27 deletions

File tree

demo/batch_download_run.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
WD = fileparts(mfilename('fullpath'));
1919

2020
% we add all the subfunctions that are in the sub directories
21+
addpath(fullfile(WD, '..'));
2122
addpath(genpath(fullfile(WD, '..', 'src')));
2223
addpath(genpath(fullfile(WD, '..', 'lib')));
2324

@@ -66,7 +67,7 @@
6667
%% Get data
6768
% fprintf('%-40s:', 'Downloading dataset...');
6869
% urlwrite(URL, 'MoAEpilot.zip');
69-
% unzip('MoAEpilot.zip', fullfile(WD, 'output'));
70+
unzip('MoAEpilot.zip', fullfile(WD, 'output'));
7071

7172
%% Check dependencies
7273
% If toolboxes are not in the MATLAB Directory and needed to be added to
@@ -81,10 +82,12 @@
8182
checkDependencies();
8283

8384
%% Run batches
85+
isMVPA = 0;
86+
8487
bidsCopyRawFolder(opt, 1);
8588
bidsSTC(opt);
8689
bidsSpatialPrepro(opt);
8790
bidsSmoothing(FWHM, opt);
88-
bidsFFX(1, FWHM, opt, 0);
89-
bidsFFX(2, FWHM, opt, 0);
90-
bidsResults(FWHM, [], opt, 0);
91+
bidsFFX('specifyAndEstimate', opt, FWHM, isMVPA);
92+
bidsFFX('contrasts', opt, FWHM, isMVPA);
93+
bidsResults(opt, FWHM, [], isMVPA);

src/specifyContrasts.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@
3939

4040
switch Step.Level
4141

42-
case 'subject'
42+
case 'run'
4343

4444
[contrasts, con_counter] = ...
45-
specifySubjectLevelContrasts(Step, con_counter, SPM);
45+
specifyRunLvlContrasts(contrasts, Step, con_counter, SPM);
4646

47-
case 'run'
47+
case 'subject'
4848

4949
[contrasts, con_counter] = ...
50-
specifyRunLevelContrasts(Step, con_counter, SPM);
50+
specifySubLvlContrasts(contrasts, Step, con_counter, SPM);
5151

5252
end
5353

@@ -73,7 +73,7 @@
7373

7474
end
7575

76-
function [contrasts, con_counter] = specifySubjectLevelContrasts(Step, con_counter, SPM)
76+
function [contrasts, con_counter] = specifySubLvlContrasts(contrasts, Step, con_counter, SPM)
7777

7878
if isfield(Step, 'AutoContrasts')
7979

@@ -129,7 +129,7 @@
129129

130130
end
131131

132-
function [contrasts, con_counter] = specifyRunLevelContrasts(Step, con_counter, SPM)
132+
function [contrasts, con_counter] = specifyRunLvlContrasts(contrasts, Step, con_counter, SPM)
133133

134134
if isfield(Step, 'AutoContrasts')
135135

src/spmBatching/bidsResults.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function bidsResults(funcFWHM, conFWHM, opt, isMVPA)
1+
function bidsResults(opt, funcFWHM, conFWHM, isMVPA)
22
% This scripts computes the results for a series of contrast that can be
33
% specified at the run, subject or dataset step level (see contrast specification
44
% following the BIDS stats model specification)
@@ -28,9 +28,9 @@ function bidsResults(funcFWHM, conFWHM, opt, isMVPA)
2828
switch opt.result.Steps(iStep).Level
2929

3030
case 'run'
31-
error('run level not implemented yet');
31+
warning('run level not implemented yet');
3232

33-
saveMatlabBatch(matlabbatch, 'computeFfxResults', opt, subID); %#ok<UNRCH>
33+
% saveMatlabBatch(matlabbatch, 'computeFfxResults', opt, subID);
3434

3535
case 'subject'
3636

@@ -44,7 +44,10 @@ function bidsResults(funcFWHM, conFWHM, opt, isMVPA)
4444
iStep, ...
4545
iCon);
4646

47-
saveMatlabBatch(matlabbatch, 'computeFfxResults', opt, subID);
47+
% TODO
48+
% Save this batch in for each subject and not once for all
49+
50+
saveMatlabBatch(matlabbatch, 'computeFfxResults', opt);
4851

4952
case 'dataset'
5053

@@ -60,7 +63,7 @@ function bidsResults(funcFWHM, conFWHM, opt, isMVPA)
6063
matlabbatch = resultsMatlabbatch( ...
6164
matlabbatch, opt, iStep, iCon, results);
6265

63-
saveMatlabBatch(matlabbatch, 'computeFfxResults', opt);
66+
saveMatlabBatch(matlabbatch, 'computeRfxResults', opt);
6467

6568
end
6669
end

src/spmBatching/bidsSTC.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,17 @@ function bidsSTC(opt)
4949
%% GET FUNCTIOVAL FILES
5050
fprintf(1, ' BUILDING STC JOB : STC\n');
5151

52-
matlabbatch = setBatchSTC(BIDS, subID, opt);
52+
matlabbatch = setBatchSTC(BIDS, opt, subID);
5353

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

58-
saveMatlabBatch(matlabbatch, 'STC', opt, subID);
58+
if ~isempty(matlabbatch)
59+
saveMatlabBatch(matlabbatch, 'STC', opt, subID);
5960

60-
spm_jobman('run', matlabbatch);
61+
spm_jobman('run', matlabbatch);
62+
end
6163

6264
end
6365
end

src/spmBatching/bidsSmoothing.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ function bidsSmoothing(funcFWHM, opt)
2020

2121
subID = group(iGroup).subNumber{iSub};
2222

23+
printProcessingSubject(groupName, iSub, subID);
24+
2325
fprintf(1, 'PREPARING: SMOOTHING JOB \n');
2426

25-
matlabbatch = setBatchSmoothing(BIDS, subID, opt, funcFWHM, groupName);
27+
matlabbatch = setBatchSmoothing(BIDS, opt, subID, funcFWHM);
2628

2729
saveMatlabBatch(matlabbatch, 'Smoothing', opt, subID);
2830

src/spmBatching/setBatchSTC.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function matlabbatch = setBatchSTC(BIDS, subID, opt)
1+
function matlabbatch = setBatchSTC(BIDS, opt, subID)
22
% Slice timing units is in milliseconds to be BIDS compliant and not in slice number
33
% as is more traditionally the case with SPM.
44
%
@@ -13,6 +13,8 @@
1313
%
1414
% See README.md for more information about slice timing correction
1515

16+
matlabbatch = [];
17+
1618
% get slice order
1719
sliceOrder = getSliceOrder(opt, 1);
1820
if isempty(sliceOrder)
@@ -50,8 +52,6 @@
5052

5153
[sessions, nbSessions] = getInfo(BIDS, subID, opt, 'Sessions');
5254

53-
matlabbatch = [];
54-
5555
for iSes = 1:nbSessions
5656

5757
% get all runs for that subject across all sessions

src/spmBatching/setBatchSmoothing.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function matlabbatch = setBatchSmoothing(BIDS, subID, opt, funcFWHM, groupName)
1+
function matlabbatch = setBatchSmoothing(BIDS, opt, subID, funcFWHM)
22

33
% creates prefix to look for
44
prefix = getPrefix('smoothing', opt);
@@ -23,8 +23,6 @@
2323
% numRuns = group(iGroup).numRuns(iSub);
2424
for iRun = 1:nbRuns
2525

26-
printProcessingRun(groupName, iSub, subID, iSes, iRun);
27-
2826
% get the filename for this bold run for this task
2927
[fileName, subFuncDataDir] = getBoldFilename( ...
3028
BIDS, ...

src/spmBatching/setBatchSubjectLevelGLMSpec.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@
7575
for iRun = 1:nbRuns
7676

7777
% get functional files
78-
[fullpathBoldFileName, prefix] = ...
78+
fullpathBoldFileName = ...
7979
getBoldFilenameForFFX(BIDS, opt, subID, funcFWHM, iSes, iRun);
8080
matlabbatch{1}.spm.stats.fmri_spec.sess(sesCounter).scans = ...
8181
cellstr(fullpathBoldFileName);
8282

8383
% get stimuli onset time file
8484
fullpathOnsetFileName = ...
85-
createAndReturnOnsetFile(opt, subID, funcFWHM, boldFileName, isMVPA);
85+
createAndReturnOnsetFile(opt, subID, funcFWHM, fullpathBoldFileName, isMVPA);
8686

8787
matlabbatch{1}.spm.stats.fmri_spec.sess(sesCounter).multi = ...
8888
cellstr(fullpathOnsetFileName);

0 commit comments

Comments
 (0)