Skip to content

Commit 1ee6368

Browse files
committed
refactor
1 parent 4d0509b commit 1ee6368

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

validators/nii.js

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var async = require('async');
21
var utils = require('../utils');
32
var Issue = utils.issues.Issue;
43

@@ -219,32 +218,32 @@ module.exports = function NIFTI (header, file, jsonContentsDict, bContentsDict,
219218
}
220219

221220
if (path.includes("_phasediff.nii") || path.includes("_phase1.nii") ||
222-
path.includes("_phase2.nii") || path.includes("_fieldmap.nii") || path.includes("_epi.nii")) {
223-
if (mergedDictionary.hasOwnProperty('IntendedFor')) {
224-
var intendedFor = typeof mergedDictionary['IntendedFor'] == "string" ? [mergedDictionary['IntendedFor']] : mergedDictionary['IntendedFor'];
225-
226-
for (var key = 0; key < intendedFor.length; key++) {
227-
var intendedForFile = intendedFor[key];
228-
var intendedForFileFull = "/" + path.split("/")[1] + "/" + intendedForFile;
229-
var onTheList = false;
230-
231-
for (var key2 in fileList) {
232-
var filePath = fileList[key2].relativePath;
233-
if (filePath === intendedForFileFull) {
234-
onTheList = true;
235-
}
236-
}
237-
if (!onTheList) {
238-
issues.push(new Issue({
239-
file: file,
240-
code: 37,
241-
reason: "'IntendedFor' property of this fieldmap ('" + path +
242-
"') does not point to an existing file('" + intendedForFile + "'). Please mind that this value should not include subject level directory " +
243-
"('/" + path.split("/")[1] + "/').",
244-
evidence: intendedForFile
245-
}));
221+
path.includes("_phase2.nii") || path.includes("_fieldmap.nii") || path.includes("_epi.nii") &&
222+
mergedDictionary.hasOwnProperty('IntendedFor')) {
223+
var intendedFor = typeof mergedDictionary['IntendedFor'] == "string" ? [mergedDictionary['IntendedFor']] : mergedDictionary['IntendedFor'];
224+
225+
for (var key = 0; key < intendedFor.length; key++) {
226+
var intendedForFile = intendedFor[key];
227+
var intendedForFileFull = "/" + path.split("/")[1] + "/" + intendedForFile;
228+
var onTheList = false;
229+
230+
for (var key2 in fileList) {
231+
var filePath = fileList[key2].relativePath;
232+
if (filePath === intendedForFileFull) {
233+
onTheList = true;
246234
}
247235
}
236+
if (!onTheList) {
237+
issues.push(new Issue({
238+
file: file,
239+
code: 37,
240+
reason: "'IntendedFor' property of this fieldmap ('" + path +
241+
"') does not point to an existing file('" + intendedForFile + "'). Please mind that this value should not include subject level directory " +
242+
"('/" + path.split("/")[1] + "/').",
243+
evidence: intendedForFile
244+
}));
245+
}
246+
}
248247
}
249248
}
250249
}

0 commit comments

Comments
 (0)