Skip to content

Commit 652edd9

Browse files
committed
RF: Replace deprecated pydicom.dicomio.read_file with dcmread
1 parent 89cf1cd commit 652edd9

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

nibabel/nicom/dicomreaders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def read_mosaic_dir(dicom_path, globber='*.dcm', check_is_dwi=False, dicom_kwarg
5353
If True, raises an error if we don't find DWI information in the
5454
DICOM headers.
5555
dicom_kwargs : None or dict
56-
Extra keyword arguments to pass to the pydicom ``read_file`` function.
56+
Extra keyword arguments to pass to the pydicom ``dcmread`` function.
5757
5858
Returns
5959
-------

nibabel/nicom/dicomwrappers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ def wrapper_from_file(file_like, *args, **kwargs):
4444
filename string or file-like object, pointing to a valid DICOM
4545
file readable by ``pydicom``
4646
\*args : positional
47-
args to ``dicom.read_file`` command.
47+
args to ``dicom.dcmread`` command.
4848
\*\*kwargs : keyword
49-
args to ``dicom.read_file`` command. ``force=True`` might be a
49+
args to ``dicom.dcmread`` command. ``force=True`` might be a
5050
likely keyword argument.
5151
5252
Returns
@@ -55,7 +55,7 @@ def wrapper_from_file(file_like, *args, **kwargs):
5555
DICOM wrapper corresponding to DICOM data type
5656
"""
5757
with ImageOpener(file_like) as fobj:
58-
dcm_data = pydicom.read_file(fobj, *args, **kwargs)
58+
dcm_data = pydicom.dcmread(fobj, *args, **kwargs)
5959
return wrapper_from_data(dcm_data)
6060

6161

nibabel/nicom/tests/test_dicomreaders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_passing_kwds():
4141
# This should not raise an error
4242
data2, aff2, bs2, gs2 = func(IO_DATA_PATH, dwi_glob, dicom_kwargs=dict(force=True))
4343
assert_array_equal(data, data2)
44-
# This should raise an error in pydicom.dicomio.read_file
44+
# This should raise an error in pydicom.filereader.dcmread
4545
with pytest.raises(TypeError):
4646
func(IO_DATA_PATH, dwi_glob, dicom_kwargs=dict(not_a_parameter=True))
4747
# These are invalid dicoms, so will raise an error unless force=True

nibabel/nicom/tests/test_dicomwrappers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
DATA_FILE = pjoin(IO_DATA_PATH, 'siemens_dwi_1000.dcm.gz')
2424
DATA_FILE_PHILIPS = pjoin(IO_DATA_PATH, 'philips_mprage.dcm.gz')
2525
if have_dicom:
26-
DATA = pydicom.read_file(gzip.open(DATA_FILE))
27-
DATA_PHILIPS = pydicom.read_file(gzip.open(DATA_FILE_PHILIPS))
26+
DATA = pydicom.dcmread(gzip.open(DATA_FILE))
27+
DATA_PHILIPS = pydicom.dcmread(gzip.open(DATA_FILE_PHILIPS))
2828
else:
2929
DATA = None
3030
DATA_PHILIPS = None
@@ -170,7 +170,7 @@ def test_wrapper_from_data():
170170

171171
@dicom_test
172172
def test_wrapper_args_kwds():
173-
# Test we can pass args, kwargs to read_file
173+
# Test we can pass args, kwargs to dcmread
174174
dcm = didw.wrapper_from_file(DATA_FILE)
175175
data = dcm.get_data()
176176
# Passing in non-default arg for defer_size

nibabel/pydicom_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
if have_dicom:
3636
# Values not imported by default
3737
import pydicom.values # type: ignore
38-
from pydicom.dicomio import read_file # noqa:F401
38+
from pydicom.dicomio import dcmread as read_file # noqa:F401
3939
from pydicom.sequence import Sequence # noqa:F401
4040

4141
tag_for_keyword = pydicom.datadict.tag_for_keyword

0 commit comments

Comments
 (0)