Skip to content
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/dicomwrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def voxel_sizes(self):
zs = self.get('SpacingBetweenSlices')
if zs is None:
zs = self.get('SliceThickness')
if zs is None:
if zs is None or zs == '':
zs = 1
# Protect from python decimals in pydicom 0.9.7
zs = float(zs)
Expand Down
Binary file not shown.
6 changes: 6 additions & 0 deletions nibabel/nicom/tests/test_dicomwrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
DATA_FILE_SLC_NORM = pjoin(IO_DATA_PATH, 'csa_slice_norm.dcm')
DATA_FILE_DEC_RSCL = pjoin(IO_DATA_PATH, 'decimal_rescale.dcm')
DATA_FILE_4D = pjoin(IO_DATA_PATH, '4d_multiframe_test.dcm')
DATA_FILE_EMPTY_ST = pjoin(IO_DATA_PATH, 'slicethickness_empty_string.dcm')

# This affine from our converted image was shown to match our image spatially
# with an image from SPM DICOM conversion. We checked the matching with SPM
Expand Down Expand Up @@ -616,6 +617,11 @@ def test_data_real(self):
assert_equal(sha1(dat_str).hexdigest(),
'149323269b0af92baa7508e19ca315240f77fa8c')

@dicom_test
def test_slicethickness_fallback(self):
dw = didw.wrapper_from_file(DATA_FILE_EMPTY_ST)
assert_equal(dw.voxel_sizes[2], 1.0)

@dicom_test
def test_data_fake(self):
# Test algorithm for get_data
Expand Down