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
9 changes: 7 additions & 2 deletions src/batches/saveMatlabBatch.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function saveMatlabBatch(matlabbatch, batchType, opt, subLabel) %#ok<INUSL>
%
% Saves the matlabbatch job in a .mat and a .m file.
% Saves the matlabbatch job in a .m file.
% Environment information are saved in a .json file.
%
% % USAGE::
Expand All @@ -9,14 +9,17 @@ function saveMatlabBatch(matlabbatch, batchType, opt, subLabel) %#ok<INUSL>
%
% :param matlabbatch:
% :type matlabbatch: structure
%
% :param batchType:
% :type batchType: string
%
% :param opt: Options chosen for the analysis. See ``checkOptions()``.
% :type opt: structure
%
% :param subLabel:
% :type subLabel: string
%
% The .mat file can directly be loaded with the SPM batch or run directly
% The .m file can directly be loaded with the SPM batch or run directly
% by SPM standalone or SPM docker.
%
% The .json file also contains heaps of info about the "environment" used
Expand Down Expand Up @@ -52,6 +55,8 @@ function saveMatlabBatch(matlabbatch, batchType, opt, subLabel) %#ok<INUSL>

saveSpmScript(batchFileName);

delete(batchFileName);

[OS, GeneratedBy] = getEnvInfo(opt);
GeneratedBy(1).Description = batchType;

Expand Down
4 changes: 2 additions & 2 deletions tests/tests_batches/test_saveMatlabBatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function test_saveMatlabBatch_basic()
expectedOutput = fullfile(pwd, ['sub-' subLabel], ...
['batch_test_' datestr(now, 'yyyy-mm-ddTHH-MM') '.mat']);

assertEqual(exist(expectedOutput, 'file'), 2);
assertEqual(exist(expectedOutput, 'file'), 0);
assertEqual(exist(spm_file(expectedOutput, 'ext', '.json'), 'file'), 2);

expectedOutput = fullfile(pwd, ['sub-' subLabel], ...
Expand All @@ -47,7 +47,7 @@ function test_saveMatlabBatch_group()

saveMatlabBatch(matlabbatch, 'groupTest', opt);

assertEqual(exist(expectedOutput, 'file'), 2);
assertEqual(exist(expectedOutput, 'file'), 0);
assertEqual(exist(spm_file(strrep(expectedOutput, '-', '_'), 'ext', '.m'), 'file'), 2);

cleanUp(fullfile(pwd, 'group'));
Expand Down