Skip to content

Commit 674bb25

Browse files
committed
RF Type cleanup from MB’s suggestions
1 parent 65de3fe commit 674bb25

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

nibabel/nifti1.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,19 +418,22 @@ def __init__(self, code, content, parent_hdr=None):
418418
self._is_little_endian = parent_hdr.endianness == '<'
419419
else:
420420
self._is_little_endian = True
421-
if content.__class__ == pdcm.dataset.Dataset:
421+
if isinstance(content, pdcm.dataset.Dataset):
422422
self._is_implicit_VR = False
423423
self._raw_content = self._mangle(content)
424424
self._content = content
425-
elif len(content): # Got a byte string - unmangle it
425+
elif isinstance(content, bytes): # Got a byte string - unmangle it
426426
self._raw_content = content
427427
self._is_implicit_VR = self._guess_implicit_VR()
428428
ds = self._unmangle_and_verify(content, self._is_implicit_VR,
429429
self._is_little_endian)
430430
self._content = ds
431-
else: # Otherwise, initialize a new dicom dataset
431+
elif content == None: # Otherwise, initialize a new dicom dataset
432432
self._is_implicit_VR = False
433433
self._content = pdcm.dataset.Dataset()
434+
else:
435+
raise TypeError("content must be either a bytestring or a pydicom "
436+
"Dataset. Got %s" % content.__class__)
434437

435438
def _unmangle_and_verify(self, content, is_implicit_VR, is_little_endian):
436439
""""Decode and verify dicom dataset"""

0 commit comments

Comments
 (0)