[BUG]: Cannot register parcellation with non-continuous values #257

Merged
synchon merged 9 commits from update/non-cont-parcel-support into main 2025-10-07 10:05:31 +00:00
synchon commented 2025-09-24 12:57:03 +00:00 (Migrated from github.com)

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I want to register the Glasser parcellation: https://afni.nimh.nih.gov/pub/dist/atlases/MNI_HCP/MNI_Glasser_HCP_2021_v1.0a/

However, I get this error:

  File "/home/fraimondo/dev/tbox/junifer/junifer/data/parcellations.py", line 269, in load_parcellation
    raise_error(
  File "/home/fraimondo/dev/tbox/junifer/junifer/utils/logging.py", line 289, in raise_error
    raise klass(msg)
ValueError: Parcellation Glasser must have all the values in the range  [0, 361].

This is because so far, junifer expects that parcellation values are continuous. Some parcellations are not, like this one. The values are 1-180 for one hemisphere, and 1001-1180 for the other.

This was a restriction added when merging parcellations, as we have to "shift" the values to merge them, and this is done by adding the number of labels:

github.com/juaml/junifer@3fd1877dda/junifer/data/parcellations.py (L1362-L1364)

Expected Behavior

Parcellations without continuous numbering should be able to be included in junifer (and merged)

Steps To Reproduce

  1. Get junifer latest
  2. Register the Glasser parcellation
  3. Try to compute any marker that uses a parcel (or even load_parcellation)

Environment

junifer:
  version: 0.0.3.dev101
python:
  version: 3.11.3
  implementation: CPython
dependencies:
  click: 8.1.3
  numpy: 1.23.5
  datalad: 0.18.2+59.gc5054cb91
  pandas: 1.5.3
  nibabel: 4.0.2
  nilearn: 0.10.0
  sqlalchemy: 1.4.48
  ruamel.yaml: 0.17.31
system:
  platform: Linux-6.1.0-12-amd64-x86_64-with-glibc2.36
environment:
  LC_CTYPE: en_US.UTF-8
  PATH: 
    /home/fraimondo/miniconda3/envs/junifer/bin:/home/fraimondo/miniconda3/condabin:/home/fraimondo/.dotfiles/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/local/games:/usr/games

Relevant log output

No response

Anything else?

No response

### Is there an existing issue for this? - [X] I have searched the existing issues ### Current Behavior I want to _register_ the Glasser parcellation: https://afni.nimh.nih.gov/pub/dist/atlases/MNI_HCP/MNI_Glasser_HCP_2021_v1.0a/ However, I get this error: ``` File "/home/fraimondo/dev/tbox/junifer/junifer/data/parcellations.py", line 269, in load_parcellation raise_error( File "/home/fraimondo/dev/tbox/junifer/junifer/utils/logging.py", line 289, in raise_error raise klass(msg) ValueError: Parcellation Glasser must have all the values in the range [0, 361]. ``` This is because so far, junifer expects that parcellation values are continuous. Some parcellations are not, like this one. The values are 1-180 for one hemisphere, and 1001-1180 for the other. This was a restriction added when merging parcellations, as we have to "shift" the values to merge them, and this is done by adding the number of labels: https://github.com/juaml/junifer/blob/3fd1877ddaa45c5d44d32a6f4d0ed43fff6fa6bf/junifer/data/parcellations.py#L1362-L1364 ### Expected Behavior Parcellations without continuous numbering should be able to be included in junifer (and merged) ### Steps To Reproduce 1. Get junifer latest 2. Register the Glasser parcellation 3. Try to compute any marker that uses a parcel (or even `load_parcellation`) ### Environment ```markdown junifer: version: 0.0.3.dev101 python: version: 3.11.3 implementation: CPython dependencies: click: 8.1.3 numpy: 1.23.5 datalad: 0.18.2+59.gc5054cb91 pandas: 1.5.3 nibabel: 4.0.2 nilearn: 0.10.0 sqlalchemy: 1.4.48 ruamel.yaml: 0.17.31 system: platform: Linux-6.1.0-12-amd64-x86_64-with-glibc2.36 environment: LC_CTYPE: en_US.UTF-8 PATH: /home/fraimondo/miniconda3/envs/junifer/bin:/home/fraimondo/miniconda3/condabin:/home/fraimondo/.dotfiles/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/local/games:/usr/games ``` ### Relevant log output _No response_ ### Anything else? _No response_
github-actions[bot] commented 2025-09-24 13:39:24 +00:00 (Migrated from github.com)
PR Preview Action v1.6.2
Preview removed because the pull request was closed.
2025-10-07 10:47 UTC
[PR Preview Action](https://github.com/rossjrw/pr-preview-action) v1.6.2 :---: Preview removed because the pull request was closed. 2025-10-07 10:47 UTC <!-- Sticky Pull Request Commentpr-preview -->
synchon commented 2025-10-06 15:18:33 +00:00 (Migrated from github.com)

CI passing on juseless.

CI passing on juseless.
fraimondo (Migrated from github.com) approved these changes 2025-10-07 08:53:37 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
juaml/junifer!257
No description provided.