Skip to content

Commit 3527a1c

Browse files
committed
Relegate slicing to is_header, remove _minctest
1 parent 8a3ed16 commit 3527a1c

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

nibabel/minc1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class MincHeader(Header):
272272
# We don't use the data layout - this just in case we do later
273273
data_layout = 'C'
274274

275-
#
275+
# Number of bytes needed to distinguish Minc1 and Minc2 headers
276276
sniff_size = 4
277277

278278
def data_to_fileobj(self, data, fileobj, rescale=True):
@@ -287,7 +287,7 @@ def data_from_fileobj(self, fileobj):
287287
class Minc1Header(MincHeader):
288288
@classmethod
289289
def is_header(klass, binaryblock):
290-
return binaryblock != b'\211HDF'
290+
return binaryblock[:4] != b'\211HDF'
291291

292292

293293
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
@@ -909,7 +909,7 @@ def is_image(klass, filename, sniff=None):
909909
sniff_size = np.max([1024, klass.header_class.sniff_size])
910910
with BinOpener(metadata_filename, 'rb') as fobj:
911911
sniff = fobj.read(sniff_size)
912-
return klass.header_class.is_header(sniff[:klass.header_class.sniff_size]), sniff
912+
return klass.header_class.is_header(sniff), sniff
913913
except Exception as e:
914914
# Can happen if: file doesn't exist,
915915
# filesize < necessary sniff size (this happens!)

0 commit comments

Comments
 (0)