tsbinns / mni_to_atlas

A simple Python-based tool for finding brain atlas regions based on MNI coordinates.
MIT License
10 stars 0 forks source link

Syntax error while importing #3

Closed caggursoy closed 6 months ago

caggursoy commented 11 months ago

Hi,

I am receiving the following runtime error whenever I try to import the package. Here's how I try to import it

from mni_to_atlas import AtlasBrowser

Traceback (most recent call last):

  File ~/.conda/envs/nipype/lib/python3.10/site-packages/IPython/core/interactiveshell.py:3526 in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  Cell In[11], line 11
    from mni_to_atlas import AtlasBrowser

  File ~/.conda/envs/nipype/lib/python3.10/site-packages/mni_to_atlas/__init__.py:3
    from .atlas_browser import AtlasBrowser

  File ~/.conda/envs/nipype/lib/python3.10/site-packages/mni_to_atlas/atlas_browser.py:336
    region_id = int(self._atlas[*atlas_coords])
                    ^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

And here's my system information:

I would be glad if you can offer any help with this regard

caggursoy commented 11 months ago

Update

If I remove the character from line 336 of _atlasbrowser.py I encounter a completely different error. Original script `region_id = int(self._atlas[atlas_coords]) Edited script region_id = int(self._atlas[atlas_coords])`

Please see the error below, when the edited script is run with the following parameters: coord = np.array([0,40,-4]) atlas.find_regions(coord)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/zi/home/cagatay.guersoy/.conda/envs/nipype/lib/python3.10/site-packages/mni_to_atlas/atlas_browser.py", line 141, in find_regions
    region = self._find_region(atlas_coords)
  File "/zi/home/cagatay.guersoy/.conda/envs/nipype/lib/python3.10/site-packages/mni_to_atlas/atlas_browser.py", line 336, in _find_region
    region_id = int(self._atlas[atlas_coords])
TypeError: only length-1 arrays can be converted to Python scalars
tsbinns commented 11 months ago

Thanks for bringing this to my attention! I haven't touched this code in a while so I'll have to investigate what's going wrong, will try to have a solution in the coming days.

Cheers!

tsbinns commented 11 months ago

@caggursoy Please can you try updating your Python version to >= 3.11, that should stop this from happening.

Will try to release a new version in the coming days as a more permanent fix.