From fa276859eec9cb38344985185dc524c8b587d91f Mon Sep 17 00:00:00 2001 From: Tom Close Date: Thu, 16 Nov 2023 13:38:15 +1100 Subject: [PATCH] fixed up handling of scans without metadata --- xnat_ingest/cli/upload.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/xnat_ingest/cli/upload.py b/xnat_ingest/cli/upload.py index af4802c..d0aa853 100644 --- a/xnat_ingest/cli/upload.py +++ b/xnat_ingest/cli/upload.py @@ -354,11 +354,14 @@ def upload( staged_session.select_resources(dataset, include_all_dicoms=include_dicoms), f"Uploading scans found in {session.name}", ): - image_type = scan.metadata.get("ImageType") - if image_type and image_type[:2] == ["DERIVED", "SECONDARY"]: - modality = "SC" + if scan.metadata: + image_type = scan.metadata.get("ImageType") + if image_type and image_type[:2] == ["DERIVED", "SECONDARY"]: + modality = "SC" + else: + modality = scan.metadata.get("Modality", default_scan_modality) else: - modality = scan.metadata.get("Modality", default_scan_modality) + modality = default_scan_modality if modality == "SC": ScanClass = xnat_repo.connection.classes.ScScanData elif modality == "MR":