From fcaebcae3007c00073e79f7d2d3e4b31e279ba43 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Wed, 16 Aug 2023 10:00:35 -0400 Subject: [PATCH 1/2] TEST: Add null metadata field to test dataset to stress indexer --- bids/tests/data/ds005/task-mixedgamblestask_bold.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bids/tests/data/ds005/task-mixedgamblestask_bold.json b/bids/tests/data/ds005/task-mixedgamblestask_bold.json index fb2a2e927..b90b3d6d3 100644 --- a/bids/tests/data/ds005/task-mixedgamblestask_bold.json +++ b/bids/tests/data/ds005/task-mixedgamblestask_bold.json @@ -1,5 +1,6 @@ { "RepetitionTime": 2.0, "TaskName": "mixed-gambles task", - "SliceTiming": [0.0, 0.0571, 0.1143, 0.1714, 0.2286, 0.2857] + "SliceTiming": [0.0, 0.0571, 0.1143, 0.1714, 0.2286, 0.2857], + "NullTestMetadata": null } From c732750c76726301d0418166dcf84629952b0315 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Wed, 16 Aug 2023 10:11:55 -0400 Subject: [PATCH 2/2] FIX: Drop JSON sidecar fields with null values during metadata indexing --- bids/layout/index.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bids/layout/index.py b/bids/layout/index.py index 62cbec26b..38800d0eb 100644 --- a/bids/layout/index.py +++ b/bids/layout/index.py @@ -465,6 +465,10 @@ def create_association_pair(src, dst, kind, kind2=None): # Create Tag <-> Entity mappings, and any newly discovered Entities for md_key, md_val in file_md.items(): + # Treat null entries (deserialized to None) as absent + # Alternative is to cast None to null in layout.models._create_tag_dict + if md_val is None: + continue tag_string = '{}_{}'.format(bf.path, md_key) # Skip pairs that were already found in the filenames if tag_string in all_tags: