-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow users to specify Content Label and ensure the value is formatted correctly #130
Changes from 1 commit
ea1d5dc
e653ed6
138880e
3d617f9
c39000d
fa56561
7c196f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"""Enumerate values specific to the Parametric Map IOD.""" | ||
from enum import Enum | ||
|
||
|
||
class ContentLabelValues(Enum): | ||
|
||
"""Enumerated values for attribute Content Label.""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, I think it would be a good idea to make it clear in the documentation that these are suggested values and not part of the standard There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed enumerations via fa56561 |
||
|
||
ACTIVATION_MAP = 'ACTIVATION_MAP' | ||
ATTENTION_MAP = 'ATTENTION_MAP' | ||
FEATURE_MAP = 'FEATURE_MAP' | ||
SALIENCY_MAP = 'SALIENCY_MAP' | ||
hackermd marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,11 +1,12 @@ | ||||||
"""Functions for working with DICOM value representations.""" | ||||||
import re | ||||||
from typing import Union | ||||||
|
||||||
from pydicom.valuerep import PersonName | ||||||
|
||||||
|
||||||
def check_person_name(person_name: Union[str, PersonName]) -> None: | ||||||
"""Check for problems with person name strings. | ||||||
"""Check the value representation person name strings. | ||||||
|
||||||
The DICOM Person Name (PN) value representation has a specific format with | ||||||
multiple components (family name, given name, middle name, prefix, suffix) | ||||||
|
@@ -59,3 +60,44 @@ def check_person_name(person_name: Union[str, PersonName]) -> None: | |||||
'name is really intended, add a trailing caret character to ' | ||||||
'disambiguate the name.' | ||||||
) | ||||||
|
||||||
|
||||||
def check_code_string(value: str) -> None: | ||||||
hackermd marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
"""Check the value representation person name strings. | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
value: str | ||||||
Code string | ||||||
|
||||||
Raises | ||||||
------ | ||||||
TypeError | ||||||
When `value` is not a string | ||||||
ValueError | ||||||
When `value` has zero or more than 16 characters or when `value` | ||||||
contains characters that are invalid for the value representation | ||||||
|
||||||
""" | ||||||
if not isinstance(value, str): | ||||||
raise TypeError('Invalid type for a code string.') | ||||||
|
||||||
if len(value) == 0: | ||||||
raise ValueError('Code string must not be empty.') | ||||||
|
||||||
if len(value) > 16: | ||||||
raise ValueError('Code string must have maximally 16 characters.') | ||||||
|
||||||
if not value.isupper(): | ||||||
raise ValueError('Code string must be all upper case.') | ||||||
|
||||||
if re.match(r'[0-9_]', value) is not None: | ||||||
raise ValueError( | ||||||
'Code string must not start with a number of an underscore.' | ||||||
hackermd marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
) | ||||||
|
||||||
if re.match(r'[A-Z0-9_]+[^-]$', value) is None: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From my reading of the standard, whitespace is allowed too:
Also, I don't understand the need for the Therefore I think it's something like
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Further question: where is the requirement "Code string must not start with a number or an underscore" specified? It seems sensible, it's just not in Table 6.2-1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a note to the function in c39000d. I think we should encode those values such that they could be used as fields of an enumeration (in C or syntactically similar languages). |
||||||
raise ValueError( | ||||||
'Code string must contain only capital letters, numbers, or ' | ||||||
'underscores.' | ||||||
hackermd marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be a good idea to make it clear in the documentation that these are suggested values and not part of the standard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed enumerations via fa56561