Skip to content

Commit 7dd75f8

Browse files
committed
MNT: Remove loadsave.which_analyze_type
1 parent 1b7a4a0 commit 7dd75f8

File tree

2 files changed

+0
-51
lines changed

2 files changed

+0
-51
lines changed

nibabel/loadsave.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -282,45 +282,3 @@ def read_img_data(img, prefer='scaled'):
282282
if prefer == 'scaled':
283283
return hdr.data_from_fileobj(fileobj)
284284
return hdr.raw_data_from_fileobj(fileobj)
285-
286-
287-
@deprecate_with_version('which_analyze_type deprecated.', '3.2', '4.0')
288-
def which_analyze_type(binaryblock):
289-
""" Is `binaryblock` from NIfTI1, NIfTI2 or Analyze header?
290-
291-
Parameters
292-
----------
293-
binaryblock : bytes
294-
The `binaryblock` is 348 bytes that might be NIfTI1, NIfTI2, Analyze,
295-
or None of the the above.
296-
297-
Returns
298-
-------
299-
hdr_type : str
300-
* a nifti1 header (pair or single) -> return 'nifti1'
301-
* a nifti2 header (pair or single) -> return 'nifti2'
302-
* an Analyze header -> return 'analyze'
303-
* None of the above -> return None
304-
305-
Notes
306-
-----
307-
Algorithm:
308-
309-
* read in the first 4 bytes from the file as 32-bit int ``sizeof_hdr``
310-
* if ``sizeof_hdr`` is 540 or byteswapped 540 -> assume nifti2
311-
* Check for 'ni1', 'n+1' magic -> assume nifti1
312-
* if ``sizeof_hdr`` is 348 or byteswapped 348 assume Analyze
313-
* Return None
314-
"""
315-
from .nifti1 import header_dtype
316-
hdr_struct = np.ndarray(shape=(), dtype=header_dtype, buffer=binaryblock)
317-
bs_hdr_struct = hdr_struct.byteswap()
318-
sizeof_hdr = hdr_struct['sizeof_hdr']
319-
bs_sizeof_hdr = bs_hdr_struct['sizeof_hdr']
320-
if 540 in (sizeof_hdr, bs_sizeof_hdr):
321-
return 'nifti2'
322-
if hdr_struct['magic'] in (b'ni1', b'n+1'):
323-
return 'nifti1'
324-
if 348 in (sizeof_hdr, bs_sizeof_hdr):
325-
return 'analyze'
326-
return None

nibabel/tests/test_image_load_save.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from ..volumeutils import native_code, swapped_code
3030
from ..optpkg import optional_package
3131
from ..spatialimages import SpatialImage
32-
from ..deprecator import ExpiredDeprecationError
3332

3433
from numpy.testing import assert_array_equal, assert_array_almost_equal
3534
import pytest
@@ -271,14 +270,6 @@ def test_filename_save():
271270
shutil.rmtree(pth)
272271

273272

274-
def test_analyze_detection():
275-
# Test detection of Analyze, Nifti1 and Nifti2
276-
# Algorithm is as described in loadsave:which_analyze_type
277-
hdr = Nifti1Header(b'\0' * 348, check=False)
278-
with pytest.raises(ExpiredDeprecationError):
279-
nils.which_analyze_type(hdr.binaryblock)
280-
281-
282273
def test_guessed_image_type():
283274
# Test whether we can guess the image type from example files
284275
with pytest.deprecated_call():

0 commit comments

Comments
 (0)