-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelperMergeDCMData.m
More file actions
39 lines (37 loc) · 1.78 KB
/
helperMergeDCMData.m
File metadata and controls
39 lines (37 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
% Translational Neuromodeling Project, ETH Zurich
% 'Decoding moral judgements from neurotypical individuals compared to
% individuals with ASD'
%--------------------------------------------------------------------------
% authors: Stephan Boner, Alexander Hess, Nina Stumpf
% date: 2019-05-30
% version: 1.0
%--------------------------------------------------------------------------
% This file merges the files stored in 2 different folders by iterating
% through all subjects in the destionation folder and adding all runs from
% the same subject in the source folder.
%
% Example way to use:
% tnProjectPath = what('TNProject');
% tnProjectPath = tnProjectPath.path;
% mergeDCMData(fullfile(tnProjectPath, 'data_dcm_nomod'), fullfile(tnProjectPath, 'data'));
%==========================================================================
% Specify folders to be merged:
tnProjectPath = what('TNProject');
tnProjectPath = tnProjectPath.path;
mergeDCMData(fullfile(tnProjectPath, 'data_dcm_nomod'), fullfile(tnProjectPath, 'data'));
function helperMergeDCMData(subjectsPathFrom, subjectsPathTo)
toSubjects = dir(fullfile(subjectsPathTo, 'sub*'));
for i = 1:numel(toSubjects)
subject = toSubjects(i).name;
dcmPathFrom = fullfile(subjectsPathFrom, subject, 'DCM');
taskfoldersFrom = dir(fullfile(dcmPathFrom, 'sub*'));
dcmPathTo = fullfile(subjectsPathTo, subject, 'DCM');
if ~exist(dcmPathTo,'dir'); mkdir(dcmPathTo); end
for j = 1:numel(taskfoldersFrom)
taskFolderName = taskfoldersFrom(j).name;
taskFolderToPath = fullfile(dcmPathTo, taskFolderName);
if ~exist(taskFolderToPath,'dir'); mkdir(taskFolderToPath); end
copyfile(fullfile(dcmPathFrom, taskFolderName, 'DCM*'), taskFolderToPath);
end
end
end