Skip to content

Commit

Permalink
Merge pull request #690 from isolovey-robarts/max_csa_items
Browse files Browse the repository at this point in the history
Siemens CSA Reader: Increase maximum number of items
  • Loading branch information
effigies committed Dec 3, 2018
2 parents ad26878 + 8c90a20 commit a960b92
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
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

0 comments on commit a960b92

Please sign in to comment.