Skip to content

Commit

Permalink
better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme1 committed Jul 2, 2024
1 parent 3197ea0 commit 0b1f603
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions amid/stanford_coca.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.")

Expand All @@ -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)
Expand Down

0 comments on commit 0b1f603

Please sign in to comment.