Skip to content
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

add ability to retrieve ROI names in a case insensitive way #47

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test for case insensitivity
  • Loading branch information
awtkns committed Feb 22, 2022
commit f434fcd0cce29146bf7099aa89aecadb700e23e3
20 changes: 19 additions & 1 deletion tests/test_rtstruct_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,30 @@ def test_add_valid_roi(new_rtstruct: RTStruct):
assert new_rtstruct.get_roi_names() == [NAME]


def test_get_roi_by_name_case_insensitive(new_rtstruct: RTStruct):
NAME = "Test ROI"
mask = get_empty_mask(new_rtstruct)
mask[50:100, 50:100, 0] = 1
new_rtstruct.add_roi(mask, name=NAME)

assert type(new_rtstruct.get_roi_mask_by_name(name=NAME.upper())) is np.ndarray


def test_get_invalid_roi_by_none_name(new_rtstruct: RTStruct):
NAME = "Test ROI"
mask = get_empty_mask(new_rtstruct)
mask[50:100, 50:100, 0] = 1
new_rtstruct.add_roi(mask, name=NAME)

with pytest.raises(RTStruct.ROIException):
new_rtstruct.get_roi_mask_by_name(name=None)


def test_get_invalid_roi_mask_by_name(new_rtstruct: RTStruct):
assert new_rtstruct.get_roi_names() == []
with pytest.raises(RTStruct.ROIException):
new_rtstruct.get_roi_mask_by_name("FAKE_NAME")


def test_loading_invalid_rt_struct(series_path):
invalid_rt_struct_path = os.path.join(series_path, "ct_1.dcm")
assert os.path.exists(invalid_rt_struct_path)
Expand Down