From dc4868d5353d615b8c1b7c6d4c8aceced847b16e Mon Sep 17 00:00:00 2001 From: Michael Barrett <103449618+barrettMCW@users.noreply.github.com> Date: Wed, 4 Sep 2024 11:00:42 -0500 Subject: [PATCH] Handle Datasets made from BytesIO --- deid/dicom/parser.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deid/dicom/parser.py b/deid/dicom/parser.py index 52189c9..ac16bd8 100644 --- a/deid/dicom/parser.py +++ b/deid/dicom/parser.py @@ -4,6 +4,7 @@ import os import re +from io import BytesIO from copy import deepcopy from pydicom import read_file @@ -102,6 +103,7 @@ def load(self, dicom_file, force=True): # Set class variables that might be helpful later df = self.dicom.get("filename") + df = None if isinstance(df, BytesIO) else df self.dicom_file = None if not df else os.path.abspath(df) self.dicom_name = None if not df else os.path.basename(self.dicom_file)