From c732750c76726301d0418166dcf84629952b0315 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Wed, 16 Aug 2023 10:11:55 -0400 Subject: [PATCH] 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 62cbec26..38800d0e 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: