Skip to content

Commit 074ef32

Browse files
committed
fix removing date from _stim.json
1 parent 8a90f4e commit 074ef32

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

src/subfun/removeAllDateSuffix.m

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,43 @@
33
function removeAllDateSuffix(rawDir, subjName, sesName)
44
% removeAllDateSuffix(rawDir, subjName, sesName)
55
%
6-
6+
77
labels = {'func', 'bold', 'eeg', 'ieeg', 'meg', 'beh'};
8-
8+
99
for iModality = 1:numel(labels)
10-
10+
1111
subjectPath = fullfile(rawDir, subjName, sesName, labels{iModality});
12-
12+
1313
if exist(subjectPath, 'dir')
14-
14+
1515
% do events
1616
filenames = file_utils('List', subjectPath, ...
17-
sprintf('^%s.*_task-.*_events_date-.*$', subjName));
18-
17+
sprintf('^%s.*_task-.*_events_date-.*$', subjName));
18+
1919
removeDateSuffix(filenames, subjectPath);
20-
20+
2121
for iLabel = 1:numel(labels)
2222
filenames = file_utils('List', subjectPath, ...
23-
sprintf('^%s.*_task-.*_%s_date-.*$', ...
24-
subjName, labels{iLabel}));
25-
23+
sprintf('^%s.*_task-.*_%s_date-.*$', ...
24+
subjName, labels{iLabel}));
25+
2626
removeDateSuffix(filenames, subjectPath);
2727
end
28-
28+
2929
% do stim
3030
filenames = file_utils('List', subjectPath, ...
31-
sprintf('^%s.*_task-.*_stim_date-.*tsv$', subjName));
31+
sprintf('^%s.*_task-.*_stim_date-.*json$', subjName));
32+
removeDateSuffix(filenames, subjectPath);
33+
34+
filenames = file_utils('List', subjectPath, ...
35+
sprintf('^%s.*_task-.*_stim_date-.*tsv$', subjName));
3236
compressFiles(filenames, subjectPath);
3337
filenames = file_utils('List', subjectPath, ...
34-
sprintf('^%s.*_task-.*_stim_date-.*tsv.gz$', subjName));
38+
sprintf('^%s.*_task-.*_stim_date-.*tsv.gz$', subjName));
3539
removeDateSuffix(filenames, subjectPath);
36-
40+
3741
end
38-
42+
3943
end
4044
end
4145

@@ -45,11 +49,11 @@ function compressFiles(filenames, subjectPath)
4549
else
4650
filenames = cellstr(filenames);
4751
end
48-
52+
4953
for i = 1:numel(filenames)
50-
54+
5155
gzip(fullfile(subjectPath, filenames{i}));
5256
delete(fullfile(subjectPath, filenames{i}));
53-
57+
5458
end
5559
end

tests/test_removeDateSuffix.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function test_removeDateSuffixBasic()
2121
eventsName = 'test_events_date-202008050730.tsv';
2222
stimName = 'test_stim_date-202008050730.tsv';
2323
stimNameZipped = 'test2_stim_date-202008050730.tsv.gz';
24+
stimJsonName = 'test_stim_date-202008050730.json';
2425

2526
filesToProcess = { ...
2627
boldName
@@ -30,6 +31,7 @@ function test_removeDateSuffixBasic()
3031
eventsName
3132
stimName
3233
stimNameZipped
34+
stimJsonName
3335
};
3436

3537
% create new files for new tests
@@ -48,6 +50,7 @@ function test_removeDateSuffixBasic()
4850
expectedEventsName = 'test_events.tsv';
4951
expectedStimName = 'test_stim.tsv';
5052
expectedStimNameZipped = 'test2_stim.tsv.gz';
53+
expectedStimJson = 'test_stim.json';
5154

5255
removeDateSuffix(filenames, outputDir);
5356

@@ -61,6 +64,7 @@ function test_removeDateSuffixBasic()
6164
assertEqual(exist(fullfile(outputDir, expectedStimNameZipped), 'file'), 2);
6265
assertEqual(exist(fullfile(outputDir, expectedBoldName2), 'file'), 2);
6366
assertEqual(exist(fullfile(outputDir, expectedBoldName), 'file'), 2);
67+
assertEqual(exist(fullfile(outputDir, expectedStimJson), 'file'), 2);
6468

6569
% clean up
6670
delete('*.nii*');

0 commit comments

Comments
 (0)