From a6a19f82c1feb3ed5d19d157a462fa94155ab776 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Wed, 7 Aug 2024 09:26:48 -0400 Subject: [PATCH] feat(legacy): Support BIDS-URIs for IntendedFor fields --- .../microscopy/checkJSONAndField.js | 20 +++++++++---------- bids-validator/validators/nifti/nii.js | 18 +++++++---------- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/bids-validator/validators/microscopy/checkJSONAndField.js b/bids-validator/validators/microscopy/checkJSONAndField.js index 2072abbe3..74984351f 100644 --- a/bids-validator/validators/microscopy/checkJSONAndField.js +++ b/bids-validator/validators/microscopy/checkJSONAndField.js @@ -100,16 +100,16 @@ const checkIfIntendedExists = (intendedFor, fileList, file) => { for (let key = 0; key < intendedFor.length; key++) { const intendedForFile = intendedFor[key] const intendedForFileFull = - '/' + file.relativePath.split('/')[1] + '/' + intendedForFile - let onTheList = false - for (let key2 in fileList) { - if (key2) { - const filePath = fileList[key2].relativePath - if (filePath === intendedForFileFull) { - onTheList = true - } - } - } + '/' + + (intendedForFile.startsWith('bids::') + ? intendedForFile.split('::')[1] + : file.relativePath.split('/')[1] + '/' + intendedForFile) + const onTheList = Object.values(fileList).some( + (f) => + f.relativePath === intendedForFileFull || + // Consider .ome.zarr/ files + f.relativePath.startsWith(`${intendedForFileFull}/`), + ) if (!onTheList) { issues.push( new Issue({ diff --git a/bids-validator/validators/nifti/nii.js b/bids-validator/validators/nifti/nii.js index 579be541a..8e96a711f 100644 --- a/bids-validator/validators/nifti/nii.js +++ b/bids-validator/validators/nifti/nii.js @@ -1396,17 +1396,13 @@ function sliceTimingGreaterThanRepetitionTime(array, repetitionTime) { function checkIfIntendedExists(intendedForFile, fileList, issues, file) { const intendedForFileFull = - '/' + file.relativePath.split('/')[1] + '/' + intendedForFile - let onTheList = false - - for (let key2 in fileList) { - if (key2) { - const filePath = fileList[key2].relativePath - if (filePath === intendedForFileFull) { - onTheList = true - } - } - } + '/' + + (intendedForFile.startsWith('bids::') + ? intendedForFile.split('::')[1] + : file.relativePath.split('/')[1] + '/' + intendedForFile) + const onTheList = Object.values(fileList).some( + (f) => f.relativePath === intendedForFileFull, + ) if (!onTheList) { issues.push( new Issue({