From 0b1f6032dc693a8d5d12a2c5ff155eb93125725b Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 2 Jul 2024 11:27:22 +0100 Subject: [PATCH] better errors --- amid/stanford_coca.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/amid/stanford_coca.py b/amid/stanford_coca.py index f7482d5..c507e2a 100644 --- a/amid/stanford_coca.py +++ b/amid/stanford_coca.py @@ -22,7 +22,7 @@ ) from skimage.draw import polygon -from .internals import Dataset, licenses, register, field +from .internals import Dataset, field, licenses, register class CoCaClasses(IntEnum): @@ -107,16 +107,18 @@ def _i(self, i): return i.split('-')[1] def _folder_with_images(self, i): - if self._split(i) == 'gated': + split = self._split(i) + if split == 'gated': return Path('Gated_release_final') / 'patient' - if self._split(i) == 'nongated': + if split == 'nongated': return 'deidentified_nongated' raise ValueError("Unknown split. Use 'gated' or 'nongated' options.") def _folder_with_annotations(self, i): - if self._split(i) == 'gated': + split = self._split(i) + if split == 'gated': return Path('Gated_release_final') / 'calcium_xml' - if self._split(i) == 'nongated': + if split == 'nongated': return None raise ValueError("Unknown split. Use 'gated' or 'nongated' options.") @@ -134,6 +136,9 @@ def ids(self): def _series(self, i): folder_with_dicoms = self.root / self._folder_with_images(i) / i series = list(map(pydicom.dcmread, folder_with_dicoms.glob('*/*.dcm'))) + if not series: + raise FileNotFoundError(f'No dicoms found at {folder_with_dicoms}') + # series = sorted(series, key=lambda x: x.InstanceNumber) series = expand_volumetric(series) series = drop_duplicated_instances(series)