Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors about running example of surfdist #17

Open
DrChenziyan opened this issue Mar 30, 2023 · 1 comment
Open

Errors about running example of surfdist #17

DrChenziyan opened this issue Mar 30, 2023 · 1 comment

Comments

@DrChenziyan
Copy link

Hi~
When I test the example code in the readme, there is an error when I run sd.analysis.dist_calc

Here are my codes:

cmap = 'coolwarm'
base_dir = 'path/2/Applications/freesurfer/subjects/'
surf = nib.freesurfer.read_geometry(os.path.join(base_dir, 'bert/surf/lh.pial'))
cort = np.sort(nib.freesurfer.read_label(os.path.join(base_dir, 'bert/label/lh.cortex.label')))
sulc = nib.freesurfer.read_morph_data(os.path.join(base_dir, 'bert/surf/lh.sulc'))
src  = sd.load.load_freesurfer_label(os.path.join(base_dir, 'bert/label/lh.aparc.a2009s.annot'), 'S_central', cort)
## All codes above run successfully~~

# calculate distance
dist = sd.analysis.dist_calc(surf, cort, src)

AND Here are the errors:

NumbaNotImplementedError                  Traceback (most recent call last)
File [~/anaconda3/envs/d2l/lib/python3.9/site-packages/numba/core/typing/typeof.py:244](https://vscode-remote+ssh-002dremote-002bchenzy-005fsever1.vscode-resource.vscode-cdn.net/export/bioinfo-team/home/chenzy/Desktop/PythonTutorial/MedicalImages_Deeplearning/fmri_learning/~/anaconda3/envs/d2l/lib/python3.9/site-packages/numba/core/typing/typeof.py:244), in _typeof_ndarray(val, c)
    243 try:
--> 244     dtype = numpy_support.from_dtype(val.dtype)
    245 except errors.NumbaNotImplementedError:

File [~/anaconda3/envs/d2l/lib/python3.9/site-packages/numba/np/numpy_support.py:114](https://vscode-remote+ssh-002dremote-002bchenzy-005fsever1.vscode-resource.vscode-cdn.net/export/bioinfo-team/home/chenzy/Desktop/PythonTutorial/MedicalImages_Deeplearning/fmri_learning/~/anaconda3/envs/d2l/lib/python3.9/site-packages/numba/np/numpy_support.py:114), in from_dtype(dtype)
    112         return types.NestedArray(subtype, dtype.shape)
--> 114 raise errors.NumbaNotImplementedError(dtype)

NumbaNotImplementedError: >i4

During handling of the above exception, another exception occurred:

NumbaValueError                           Traceback (most recent call last)
[/export/bioinfo-team/home/chenzy/Desktop/PythonTutorial/MedicalImages_Deeplearning/fmri_learning/test.ipynb](https://vscode-remote+ssh-002dremote-002bchenzy-005fsever1.vscode-resource.vscode-cdn.net/export/bioinfo-team/home/chenzy/Desktop/PythonTutorial/MedicalImages_Deeplearning/fmri_learning/test.ipynb) Cell 4 in ()
      [1](vscode-notebook-cell://ssh-remote%2Bchenzy_sever1/export/bioinfo-team/home/chenzy/Desktop/PythonTutorial/MedicalImages_Deeplearning/fmri_learning/test.ipynb#W3sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0) # calculate distance
----> [2](vscode-notebook-cell://ssh-remote%2Bchenzy_sever1/export/bioinfo-team/home/chenzy/Desktop/PythonTutorial/MedicalImages_Deeplearning/fmri_learning/test.ipynb#W3sdnNjb2RlLXJlbW90ZQ%3D%3D?line=1) dist = sd.analysis.dist_calc(surf, cort, src)

File [~/anaconda3/envs/d2l/lib/python3.9/site-packages/surfdist-0.15.5-py3.9.egg/surfdist/analysis.py:14](https://vscode-remote+ssh-002dremote-002bchenzy-005fsever1.vscode-resource.vscode-cdn.net/export/bioinfo-team/home/chenzy/Desktop/PythonTutorial/MedicalImages_Deeplearning/fmri_learning/~/anaconda3/envs/d2l/lib/python3.9/site-packages/surfdist-0.15.5-py3.9.egg/surfdist/analysis.py:14), in dist_calc(surf, cortex, source_nodes)
      6 def dist_calc(surf, cortex, source_nodes):
      8     """
      9     Calculate exact geodesic distance along cortical surface from set of source nodes.
     10     "dist_type" specifies whether to calculate "min", "mean", "median", or "max" distance values
...
--> 246     raise errors.NumbaValueError(f"Unsupported array dtype: {val.dtype}")
    247 layout = numpy_support.map_layout(val)
    248 readonly = not val.flags.writeable

NumbaValueError: Unsupported array dtype: >i4

The requirements of my computer:

python 3.9.10
numpy 1.23.5
numba 0.56.4
Cython 0.29.33
tvb-gist 2.2
nibabel 3.2.2

Could you please help me to solve the problem, Thank you~

@margulies
Copy link
Collaborator

Thanks for your interest in the code and for pointing out this error. I've discussed this with @neurabenn, and we've created a PR that only removed the numba requirement. Could you try running the code from this PR #18 , and let us know if it resolves the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants