Skip to content

Siemens CSA Reader: Increase maximum number of items #690

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

Merged
merged 1 commit into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion nibabel/nicom/csareader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
'IS': int, # integer string
}

MAX_CSA_ITEMS = 199
MAX_CSA_ITEMS = 1000


class CSAError(Exception):
Expand Down
Binary file added nibabel/nicom/tests/data/csa_str_1001n_items.bin
Binary file not shown.
Binary file removed nibabel/nicom/tests/data/csa_str_200n_items.bin
Binary file not shown.
10 changes: 5 additions & 5 deletions nibabel/nicom/tests/test_csareader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
CSA2_B1000 = open(pjoin(IO_DATA_PATH, 'csa2_b1000.bin'), 'rb').read()
CSA2_0len = gzip.open(pjoin(IO_DATA_PATH, 'csa2_zero_len.bin.gz'), 'rb').read()
CSA_STR_valid = open(pjoin(IO_DATA_PATH, 'csa_str_valid.bin'), 'rb').read()
CSA_STR_200n_items = open(pjoin(IO_DATA_PATH, 'csa_str_200n_items.bin'), 'rb').read()
CSA_STR_1001n_items = open(pjoin(IO_DATA_PATH, 'csa_str_1001n_items.bin'), 'rb').read()


@dicom_test
Expand Down Expand Up @@ -70,15 +70,15 @@ def test_csa_len0():

def test_csa_nitem():
# testing csa.read's ability to raise an error when n_items >= 200
assert_raises(csa.CSAReadError, csa.read, CSA_STR_200n_items)
# OK when < 200
assert_raises(csa.CSAReadError, csa.read, CSA_STR_1001n_items)
# OK when < 1000
csa_info = csa.read(CSA_STR_valid)
assert_equal(len(csa_info['tags']), 1)
# OK after changing module global
n_items_thresh = csa.MAX_CSA_ITEMS
try:
csa.MAX_CSA_ITEMS = 1000
csa_info = csa.read(CSA_STR_200n_items)
csa.MAX_CSA_ITEMS = 2000
csa_info = csa.read(CSA_STR_1001n_items)
assert_equal(len(csa_info['tags']), 1)
finally:
csa.MAX_CSA_ITEMS = n_items_thresh
Expand Down