Skip to content

Commit

Permalink
Add optional series MainDicomTags
Browse files Browse the repository at this point in the history
  • Loading branch information
gacou54 committed Aug 30, 2023
1 parent 329ce4a commit 8ec0e3f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
23 changes: 22 additions & 1 deletion pyorthanc/resources/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from .instance import Instance
from .resource import Resource
from .. import util
from .. import errors, util


class Series(Resource):
Expand Down Expand Up @@ -105,6 +105,27 @@ def series_number(self) -> str:
"""
return self.get_main_information()['MainDicomTags']['SeriesNumber']

@property
def performed_procedure_step_description(self):
try:
return self.get_main_information()['MainDicomTags']['PerformedProcedureStepDescription']
except KeyError:
raise errors.OptionalTagDoesNotExistError(f'{self} has no PerformedProcedureStepDescription tag.')

@property
def protocol_name(self):
try:
return self.get_main_information()['MainDicomTags']['ProtocolName']
except KeyError:
raise errors.OptionalTagDoesNotExistError(f'{self} has no ProtocolName tag.')

@property
def station_name(self):
try:
return self.get_main_information()['MainDicomTags']['StationName']
except KeyError:
raise errors.OptionalTagDoesNotExistError(f'{self} has no StationName tag.')

@property
def is_stable(self):
return self.get_main_information()['IsStable']
Expand Down
8 changes: 8 additions & 0 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pytest

from pyorthanc import errors
from .conftest import LABEL_SERIES
from .data import a_series

Expand All @@ -22,6 +23,13 @@ def test_attributes(series):
assert series.instances != []
assert str(series) == f'Series({a_series.IDENTIFIER})'

with pytest.raises(errors.OptionalTagDoesNotExistError):
series.performed_procedure_step_description
with pytest.raises(errors.OptionalTagDoesNotExistError):
series.protocol_name
with pytest.raises(errors.OptionalTagDoesNotExistError):
series.station_name


def test_zip(series):
result = series.get_zip()
Expand Down

0 comments on commit 8ec0e3f

Please sign in to comment.