|
12 | 12 | import numpy as np |
13 | 13 |
|
14 | 14 | from .filename_parser import types_filenames, splitext_addext |
15 | | -from .volumeutils import BinOpener, Opener |
| 15 | +from .openers import ImageOpener |
16 | 16 | from .analyze import AnalyzeImage |
17 | 17 | from .spm2analyze import Spm2AnalyzeImage |
18 | 18 | from .nifti1 import Nifti1Image, Nifti1Pair, header_dtype as ni1_hdr_dtype |
@@ -68,18 +68,18 @@ def guessed_image_type(filename): |
68 | 68 | elif lext == '.mnc': |
69 | 69 | # Look for HDF5 signature for MINC2 |
70 | 70 | # https://www.hdfgroup.org/HDF5/doc/H5.format.html |
71 | | - with Opener(filename) as fobj: |
| 71 | + with ImageOpener(filename) as fobj: |
72 | 72 | signature = fobj.read(4) |
73 | 73 | klass = Minc2Image if signature == b'\211HDF' else Minc1Image |
74 | 74 | elif lext == '.nii': |
75 | | - with BinOpener(filename) as fobj: |
| 75 | + with ImageOpener(filename) as fobj: |
76 | 76 | binaryblock = fobj.read(348) |
77 | 77 | ft = which_analyze_type(binaryblock) |
78 | 78 | klass = Nifti2Image if ft == 'nifti2' else Nifti1Image |
79 | 79 | else: # might be nifti 1 or 2 pair or analyze of some sort |
80 | 80 | files_types = (('image', '.img'), ('header', '.hdr')) |
81 | 81 | filenames = types_filenames(filename, files_types) |
82 | | - with BinOpener(filenames['header']) as fobj: |
| 82 | + with ImageOpener(filenames['header']) as fobj: |
83 | 83 | binaryblock = fobj.read(348) |
84 | 84 | ft = which_analyze_type(binaryblock) |
85 | 85 | if ft == 'nifti2': |
@@ -208,7 +208,7 @@ def read_img_data(img, prefer='scaled'): |
208 | 208 | hdr.set_data_offset(dao.offset) |
209 | 209 | if default_scaling and (dao.slope, dao.inter) != (1, 0): |
210 | 210 | hdr.set_slope_inter(dao.slope, dao.inter) |
211 | | - with BinOpener(img_file_like) as fileobj: |
| 211 | + with ImageOpener(img_file_like) as fileobj: |
212 | 212 | if prefer == 'scaled': |
213 | 213 | return hdr.data_from_fileobj(fileobj) |
214 | 214 | return hdr.raw_data_from_fileobj(fileobj) |
|
0 commit comments