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
23 changes: 13 additions & 10 deletions src/spmBatching/bidsCopyRawFolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,22 @@ function bidsCopyRawFolder(opt, deleteZippedNii)
% use a call to system cp function to use the derefence option (-L)
% to get the data 'out' of an eventual datalad dataset
try
system( ...
sprintf('cp -Lr %s %s', ...
status = system( ...
sprintf('cp -R -L %s %s', ...
fullfile(rawDir, subDir), ...
fullfile(derivativesDir, subDir)));
catch
message = [ ...
'Copying data with system command failed: ' ...
'are you running Windows?\n', ...
'Will use matlab/octave copyfile command instead.\n', ...
'Could be an issue if your data set contains symbolic links' ...
'(e.g. if you use datalad or git-annex.'];
warning(message);

if status > 0
message = [ ...
'Copying data with system command failed: ' ...
'are you running Windows?\n', ...
'Will use matlab/octave copyfile command instead.\n', ...
'Could be an issue if your data set contains symbolic links' ...
'(e.g. if you use datalad or git-annex.'];
error(message);
end

catch
copyfile(fullfile(rawDir, subDir), ...
fullfile(derivativesDir, subDir));
end
Expand Down
45 changes: 45 additions & 0 deletions tests/test_bidsCopyRawFolder.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function test_suite = test_bidsCopyRawFolder %#ok<*STOUT>
try % assignment of 'localfunctions' is necessary in Matlab >= 2016
test_functions = localfunctions(); %#ok<*NASGU>
catch % no problem; early Matlab versions can use initTestSuite fine
end
initTestSuite;
end

function test_bidsCopyRawFolderBasic()

% directory with this script becomes the current directory
opt.dataDir = fullfile( ...
fileparts(mfilename('fullpath')), ...
'..', 'demos', 'MoAE', 'output', 'MoAEpilot');

% group of subjects to analyze
opt.groups = {''};
% suject to run in each group
opt.subjects = {[]};
% task to analyze
opt.taskName = 'auditory';

checkDependencies();
opt = checkOptions(opt);

bidsCopyRawFolder(opt, 1);

assertEqual(exist( ...
fullfile(opt.dataDir, '..', ...
'derivatives', 'SPM12_CPPL', ...
'dataset_description.json'), 'file'), ...
2);

assertEqual(exist( ...
fullfile(opt.dataDir, '..', ...
'derivatives', 'SPM12_CPPL', 'sub-01', 'func', ...
'sub-01_task-auditory_bold.nii'), 'file'), ...
2);

assertEqual(exist( ...
fullfile(opt.dataDir, '..', ...
'derivatives', 'SPM12_CPPL', 'sub-01', 'anat', ...
'sub-01_T1w.nii'), 'file'), ...
2);
end