Skip to content

BUG: Simple save-load round-trip emits warning #802

@larsoner

Description

@larsoner

For example, this code:

>>> import warnings
>>> warnings.simplefilter('always')
>>> import nibabel
>>> img = nibabel.load('/home/larsoner/applications/freesurfer-6/subjects/fsaverage/mri/T1.mgz')
>>> nibabel.save(img, 'test.nii')
/home/larsoner/python/nibabel/nibabel/analyze.py:1012: DeprecationWarning: get_data() is deprecated in favor of get_fdata(), which has a more predictable return type. To obtain get_data() behavior going forward, use numpy.asanyarray(img.dataobj).

* deprecated from version: 3.0
* Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 5.0
  data = self.get_data()

This suggests that there is some design issue in this nib.save traceback, which leads up to the warning emission:

../nibabel/nibabel/loadsave.py:98: in save
    img.to_filename(filename)
../nibabel/nibabel/filebasedimages.py:334: in to_filename
    self.to_file_map()
../nibabel/nibabel/analyze.py:1012: in to_file_map
    data = self.get_data()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions