|
1 | | -var async = require('async'); |
2 | 1 | var utils = require('../utils'); |
3 | 2 | var Issue = utils.issues.Issue; |
4 | 3 |
|
| 4 | +function checkIfIntendedExists(intendedForFile, fileList, issues, file) { |
| 5 | + var intendedForFileFull = "/" + file.relativePath.split("/")[1] + "/" + intendedForFile; |
| 6 | + var onTheList = false; |
| 7 | + |
| 8 | + for (var key2 in fileList) { |
| 9 | + var filePath = fileList[key2].relativePath; |
| 10 | + if (filePath === intendedForFileFull) { |
| 11 | + onTheList = true; |
| 12 | + } |
| 13 | + } |
| 14 | + if (!onTheList) { |
| 15 | + issues.push(new Issue({ |
| 16 | + file: file, |
| 17 | + code: 37, |
| 18 | + reason: "'IntendedFor' property of this fieldmap ('" + file.relativePath + |
| 19 | + "') does not point to an existing file('" + intendedForFile + "'). Please mind that this value should not include subject level directory " + |
| 20 | + "('/" + file.relativePath.split("/")[1] + "/').", |
| 21 | + evidence: intendedForFile |
| 22 | + })); |
| 23 | + } |
| 24 | +} |
| 25 | + |
5 | 26 | /** |
6 | 27 | * NIFTI |
7 | 28 | * |
@@ -218,33 +239,13 @@ module.exports = function NIFTI (header, file, jsonContentsDict, bContentsDict, |
218 | 239 | } |
219 | 240 | } |
220 | 241 |
|
221 | | - 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 = path.split("/")[1] + "/" + intendedFor[key]; |
228 | | - var onTheList = false; |
229 | | - async.eachOfLimit(fileList, 200, function (file) { |
230 | | - var filePath = file.relativePath; |
231 | | - if (filePath.endsWith(intendedForFile)){ |
232 | | - onTheList = true; |
233 | | - } |
| 242 | + if (utils.type.isFieldMapMainNii(path) && mergedDictionary.hasOwnProperty('IntendedFor')) { |
| 243 | + var intendedFor = typeof mergedDictionary['IntendedFor'] == "string" ? [mergedDictionary['IntendedFor']] : mergedDictionary['IntendedFor']; |
234 | 244 |
|
235 | | - }, function(){ |
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 | | - })); |
244 | | - } |
245 | | - }); |
| 245 | + for (var key = 0; key < intendedFor.length; key++) { |
| 246 | + var intendedForFile = intendedFor[key]; |
| 247 | + checkIfIntendedExists(intendedForFile, fileList, issues, file); |
246 | 248 | } |
247 | | - } |
248 | 249 | } |
249 | 250 | } |
250 | 251 |
|
|
0 commit comments