-
Notifications
You must be signed in to change notification settings - Fork 145
Closed
Description
Hi,
I encountered this error while attempting to use the WebGL view with Pycortex v1.2.11 and NumPy 2.3.4:
File "/home/ftravi/Documents/Projects/fmri-context/decoding/plot_rois.py", line 30, in <module>
webgl.show(vol, with_colorbar=True, linewidth=4, thick=1, with_curvature=True, roi_list=ROIS_TO_PLOT, open_browser=True)
File "/home/ftravi/.local/lib/python3.12/site-packages/cortex/utils.py", line 40, in __call__
return self._load()(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ftravi/.local/lib/python3.12/site-packages/cortex/webgl/view.py", line 399, in show
package = Package(data)
^^^^^^^^^^^^^
File "/home/ftravi/.local/lib/python3.12/site-packages/cortex/webgl/data.py", line 24, in __init__
self.uniques = list(data.uniques(collapse=True))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ftravi/.local/lib/python3.12/site-packages/cortex/dataset/dataset.py", line 120, in uniques
uniques.add(sv)
File "/home/ftravi/.local/lib/python3.12/site-packages/cortex/dataset/braindata.py", line 63, in __hash__
return hash(_hash(self.data))
^^^^^^^^^^^^^^^^
File "/home/ftravi/.local/lib/python3.12/site-packages/cortex/dataset/braindata.py", line 631, in _hash
return hashlib.sha1(array.tostring()).hexdigest()
^^^^^^^^^^^^^^
AttributeError: 'numpy.ndarray' object has no attribute 'tostring'
As stated in the traceback, it occurs in line 631 of dataset/braindata.py.
Minimal code to reproduce the error:
- Have Numpy > 2.2 installed
import cortex
vol = cortex.Volume.random(subject='S1', xfmname='fullhead')
cortex.webshow(vol)
Quick fix:
Simply replacing line 631 in dataset/braindata.py from:
return hashlib.sha1(array.tostring()).hexdigest()
to:
return hashlib.sha1(array.tobytes()).hexdigest()
If needed, I can open a pull request with this fix.
Thank you!
Copilot
Metadata
Metadata
Assignees
Labels
No labels