Skip to content

Commit a863949

Browse files
committed
Relegate slicing to is_header, remove _minctest
Use more definitive test for MINC1 images Remove unused import
1 parent eca94e5 commit a863949

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

nibabel/minc1.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from .externals.netcdf import netcdf_file
1616

17-
from .filename_parser import splitext_addext
1817
from .spatialimages import Header, SpatialImage
1918
from .fileslice import canonical_slicers
2019

@@ -284,7 +283,7 @@ def data_from_fileobj(self, fileobj):
284283
class Minc1Header(MincHeader):
285284
@classmethod
286285
def is_header(klass, binaryblock):
287-
return binaryblock != b'\211HDF'
286+
return binaryblock[:4] == 'CDF\x01'
288287

289288

290289
class Minc1Image(SpatialImage):

nibabel/minc2.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def get_scaled_data(self, sliceobj=()):
137137
class Minc2Header(MincHeader):
138138
@classmethod
139139
def is_header(klass, binaryblock):
140-
return binaryblock == b'\211HDF'
140+
return binaryblock[:4] == b'\211HDF'
141141

142142

143143
class Minc2Image(Minc1Image):
@@ -167,9 +167,5 @@ def from_file_map(klass, file_map):
167167
data = klass.ImageArrayProxy(minc_file)
168168
return klass(data, affine, header, extra=None, file_map=file_map)
169169

170-
@classmethod
171-
def _minctest(klass, binaryblock):
172-
return binaryblock[:4] == b'\211HDF'
173-
174170

175171
load = Minc2Image.load

nibabel/spatialimages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ def is_image(klass, filename, sniff=None):
912912
with ImageOpener(metadata_filename, 'rb') as fobj:
913913
sniff = fobj.read(sizeof_hdr)
914914

915-
is_header = klass.header_class.is_header(sniff[:klass_sizeof_hdr])
915+
is_header = klass.header_class.is_header(sniff)
916916
except Exception as e:
917917
# Can happen if: file doesn't exist,
918918
# filesize < necessary sniff size (this happens!)

0 commit comments

Comments
 (0)