You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My colleague noted that conform no longer works. I replicated this on my system using nibabel Version 5.2.1 and the current stable release of numpy Version 2.1.0 on my MacOS M2 with Python 3.11.2. My colleague resolved this by making an environment and specifying numpy<2. However, it would be good to have a solution to encourage people to enjoy all the benefits of modern numpy.
To replicate, run this script:
importnibabelasnibimportnumpyasnpfromnibabel.processingimportconforminput_image_path='./T1w.nii'output_image_path='./cT1w.nii'img=nib.load(input_image_path)
conformed_img=conform(img)
nib.save(conformed_img, output_image_path)
print(f"Conformed image saved as {output_image_path}")
I get this error:
Traceback (most recent call last):
File "/Users/chris/Downloads/ARC_reslice/conformer.py", line 8, in <module>
conformed_img = conform(img)
^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nibabel/processing.py", line 388, in conform
out_aff = rescale_affine(reoriented.affine, reoriented.shape, voxel_size, out_shape)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nibabel/affines.py", line 368, in rescale_affine
shape = np.array(shape, copy=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
The text was updated successfully, but these errors were encountered:
Ah, we definitely need a release. This has been fixed in master. In the short term, pip install git+https://github.com/nipy/nibabel.git@master will do the job. I will aim to have a release out by the end of the month. I will probably do a 5.3 to avoid the complications of a major release. I think 6.0 will probably be numpy 2+ only, because there are some things that are quite hard to support properly on both sides of the major release (#1318)...
My colleague noted that conform no longer works. I replicated this on my system using nibabel Version 5.2.1 and the current stable release of numpy Version 2.1.0 on my MacOS M2 with Python 3.11.2. My colleague resolved this by making an environment and specifying numpy<2. However, it would be good to have a solution to encourage people to enjoy all the benefits of modern numpy.
To replicate, run this script:
I get this error:
The text was updated successfully, but these errors were encountered: