|
17 | 17 |
|
18 | 18 | import numpy as np
|
19 | 19 |
|
| 20 | +from nibabel.optpkg import optional_package |
20 | 21 | from . import csareader as csar
|
21 | 22 | from .dwiparams import B2q, nearest_pos_semi_def, q2bg
|
22 | 23 | from ..openers import ImageOpener
|
23 | 24 | from ..onetime import auto_attr as one_time
|
24 |
| -from ..pydicom_compat import tag_for_keyword, Sequence |
25 | 25 | from ..deprecated import deprecate_with_version
|
26 | 26 |
|
| 27 | +pydicom = optional_package("pydicom")[0] |
| 28 | + |
27 | 29 |
|
28 | 30 | class WrapperError(Exception):
|
29 | 31 | pass
|
@@ -52,10 +54,8 @@ def wrapper_from_file(file_like, *args, **kwargs):
|
52 | 54 | dcm_w : ``dicomwrappers.Wrapper`` or subclass
|
53 | 55 | DICOM wrapper corresponding to DICOM data type
|
54 | 56 | """
|
55 |
| - from ..pydicom_compat import read_file |
56 |
| - |
57 | 57 | with ImageOpener(file_like) as fobj:
|
58 |
| - dcm_data = read_file(fobj, *args, **kwargs) |
| 58 | + dcm_data = pydicom.read_file(fobj, *args, **kwargs) |
59 | 59 | return wrapper_from_data(dcm_data)
|
60 | 60 |
|
61 | 61 |
|
@@ -520,7 +520,7 @@ def image_shape(self):
|
520 | 520 | if hasattr(first_frame, 'get') and first_frame.get([0x18, 0x9117]):
|
521 | 521 | # DWI image may include derived isotropic, ADC or trace volume
|
522 | 522 | try:
|
523 |
| - self.frames = Sequence( |
| 523 | + self.frames = pydicom.Sequence( |
524 | 524 | frame for frame in self.frames if
|
525 | 525 | frame.MRDiffusionSequence[0].DiffusionDirectionality
|
526 | 526 | != 'ISOTROPIC'
|
@@ -550,15 +550,15 @@ def image_shape(self):
|
550 | 550 | # Determine if one of the dimension indices refers to the stack id
|
551 | 551 | dim_seq = [dim.DimensionIndexPointer
|
552 | 552 | for dim in self.get('DimensionIndexSequence')]
|
553 |
| - stackid_tag = tag_for_keyword('StackID') |
| 553 | + stackid_tag = pydicom.datadict.tag_for_keyword('StackID') |
554 | 554 | # remove the stack id axis if present
|
555 | 555 | if stackid_tag in dim_seq:
|
556 | 556 | stackid_dim_idx = dim_seq.index(stackid_tag)
|
557 | 557 | frame_indices = np.delete(frame_indices, stackid_dim_idx, axis=1)
|
558 | 558 | dim_seq.pop(stackid_dim_idx)
|
559 | 559 | if has_derived:
|
560 | 560 | # derived volume is included
|
561 |
| - derived_tag = tag_for_keyword("DiffusionBValue") |
| 561 | + derived_tag = pydicom.datadict.tag_for_keyword("DiffusionBValue") |
562 | 562 | if derived_tag not in dim_seq:
|
563 | 563 | raise WrapperError("Missing information, cannot remove indices "
|
564 | 564 | "with confidence.")
|
|
0 commit comments