Skip to content

Bug: Flatmap demo produces incorrect results. #1

Description

@wesleymth

Steps to Reproduce

Command used:

uv run scripts/encoding/flatmap_demo.py \
  --subject-dir /data/natural-scenes-dataset/nsddata/freesurfer/fsaverage \
  --hemi both \
  --stat-file /projects/CorticoSemantic/encoding/20260616_142617_b1942f/subj01/backbone_late_features_layers_0_t1/test_corr.npy \
  --symmetric-clim \
  --absthreshold 0.05 \
  --show-colorbar \
  --out draft_outputs/backbone_late_features_layers_0_t1_subj01_corr_thresh005.png

The file scripts/encoding/flatmap_demo.py is EXACTLY the same as the provided examples/flatmap_demo.py.

Here is the test_corr.npy file used : test_corr.npy.zip

Expected vs. Actual Behavior

Expected

produced using nibabel, nilearn and matplotlib:

Image

Actual behavior

Image

Ignore the colorbar label number mismatch, I explicitely set it on the top plot to 0.85 but the actual maximum is the one on the bottom plot.

Environment Details

Python 3.11.15

dependencies = [
  "numpy>=1.24",
  "scipy>=1.10",
  "pandas>=2.0",
  "pillow>=10.0",
  "tqdm>=4.66",
  "pyyaml>=6.0",
  "matplotlib>=3.8",
  "scikit-learn>=1.4",
  "torch>=2.10",
  "torchvision>=0.21.0",
  "h5py>=3.10.0",
  "vllm==0.19.1",
  "datasets>=4.8.4",
  "ultralytics>=8.4.47",
  "sentence-transformers>=5.4.1",
  "usearch>=2.25.2",
  "ipython>=9.13.0",
  "seaborn>=0.13.2",
  "tensorboard>=2.20.0",
  "torchmetrics>=1.9.0",
  "setuptools==81.0.0",
  "pycocotools>=2.0.11",
  "pre-commit>=4.6.0",
  "schedulefree>=1.4.1",
  "fracridge>=2.0",
  "cvnpy>=0.1.0",
  "nilearn>=0.13.1",
]

I use uv as my environment manager. I can share the uv.lock file to be even more precise with my environment used.

Tried fixes

Flipping the hemisphere indices :

import numpy as np
arr = np.load("test_corr.npy")
np.save("test_corr_flip.npy", np.concatenate((arr[163842:], arr[:163842])))
Image

Reversing the entire indices :

import numpy as np
arr = np.load("test_corr.npy")
np.save("test_corr_-1.npy", arr[::-1])
Image

Reversing indices of hemisphere :

import numpy as np
arr = np.load("test_corr.npy")
np.save("test_corr_-1_per_hemi.npy", np.concatenate((arr[:163842][::-1], arr[163842:][::-1])))
Image

Reversing indices of flipped hemisphere :

import numpy as np
arr = np.load("test_corr.npy")
np.save("test_corr_flip_-1_per_hemi.npy", np.concatenate((arr[163842:][::-1], arr[:163842][::-1])))
Image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions