Skip to content

Commit b930418

Browse files
committed
refactor
1 parent f0a7753 commit b930418

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

src/subject_level/convertOnsetTsvToMat.m

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,29 @@
3939
%
4040
% (C) Copyright 2019 CPP_SPM developers
4141

42-
%
4342
[pth, file, ext] = spm_fileparts(tsvFile);
4443
tsv.file = validationInputFile(pth, [file, ext]);
45-
4644
tsv.content = bids.util.tsvread(tsv.file);
4745

4846
if ~all(isnumeric(tsv.content.onset))
4947

50-
errorID = 'onsetsNotNumeric';
5148
msg = sprintf('%s\n%s', 'Onset column contains non numeric values in file:', tsv.file);
52-
errorHandling(mfilename(), errorID, msg, false, opt.verbosity);
49+
errorHandling(mfilename(), 'onsetsNotNumeric', msg, false, opt.verbosity);
5350

5451
end
5552

5653
if ~all(isnumeric(tsv.content.duration))
5754

58-
errorID = 'durationsNotNumeric';
5955
msg = sprintf('%s\n%s', 'Duration column contains non numeric values in file:', tsv.file);
60-
errorHandling(mfilename(), errorID, msg, false, opt.verbosity);
56+
errorHandling(mfilename(), 'durationsNotNumeric', msg, false, opt.verbosity);
6157

6258
end
6359

6460
varToConvolve = opt.model.bm.getVariablesToConvolve();
6561
designMatrix = opt.model.bm.getBidsDesignMatrix();
6662
designMatrix = removeIntercept(designMatrix);
6763

68-
% conditions to be filled in according to the conditions present in each run
64+
% conditions to be filled according to the conditions present in each run
6965
condToModel.names = {};
7066
condToModel.onsets = {};
7167
condToModel.durations = {};
@@ -81,11 +77,7 @@
8177

8278
for iVar = 1:numel(varToConvolve)
8379

84-
trialTypeNotFound = false; % should be dead code by now
85-
variableNotFound = false;
86-
extra = '';
87-
88-
% first assume the input is from events.tsv
80+
% in case we get the column names with a dot separator
8981
tokens = regexp(varToConvolve{iVar}, '\.', 'split');
9082

9183
% if the variable is present in namespace
@@ -138,24 +130,15 @@
138130

139131
else
140132

141-
variableNotFound = true;
142-
errorID = 'variableNotFound';
143-
input1 = 'Variable';
144-
145-
end
146-
147-
if variableNotFound
148-
149133
if opt.glm.useDummyRegressor
150134
condToModel = addDummyRegressor(condToModel);
151135
end
152136

153-
msg = sprintf('%s %s not found in \n %s\n Adding dummy regressor instead.', ...
154-
input1, ...
137+
msg = sprintf('Variable %s not found in \n %s\n Adding dummy regressor instead.', ...
155138
varToConvolve{iVar}, ...
156139
tsv.file);
157140

158-
errorHandling(mfilename(), errorID, msg, true, opt.verbosity);
141+
errorHandling(mfilename(), 'variableNotFound', msg, true, opt.verbosity);
159142

160143
end
161144

0 commit comments

Comments
 (0)