Run this notebook
Author: Fernanda Ribeiro
Date: 12 Nov 2025
License:
Note: If this notebook uses neuroimaging tools from Neurocontainers, those tools retain their original licenses. Please see Neurodesk citation guidelines for details.
Citation and Resources¶
Tools included in this workflow¶
deepretinotopy:
Ribeiro, F. L. et al. (2025). Predicting functional topography of the human visual cortex from cortical anatomy at scale. bioRxiv
Dataset¶
NYU Retinotopy Dataset
Himmelberg, Marc M. and Kurzawski, Jan W. and Benson, Noah C. and Carrasco, Marisa and Winawer, Jonathan. “NYU Retinotopy dataset” 2021. doi:10
DeepRetinotopy toolbox¶
This interactive notebook demonstrates how to predict retinotopic maps from anatomical data using a geometric deep learning model of retinotopy. For more details about the toolbox, please check our repository. The accompanying manuscript will be available soon.
Requirements:
freesurfer directory;
HCP “fs_LR-deformed_to-fsaverage” surfaces, available here.
Load Software Tools¶
%%capture
!pip install nilearn==0.13.1 nibabel==5.3.3 numpy==2.3.5# we can use module to load deepretinotopy in a specific version
import module
import os
await module.load('deepretinotopy/1.0.18')
await module.list()['deepretinotopy/1.0.18']# Request a freesurfer license and store it in your homedirectory. This is just an example - please replace with your license id:
!echo "Steffen.Bollmann@cai.uq.edu.au" > ~/.license
!echo "21029" >> ~/.license
!echo "*Cqyn12sqTCxo" >> ~/.license
!echo "FSxgcvGkNR59Y" >> ~/.licenseDownload data¶
Let’s start by downloading some data available on OpenNeuro. DeepRetinotopy only requires a minimal subset of FreeSurfer outputs, which means you can significantly reduce storage requirements by downloading only the following files per subject:
Essential Files¶
<subject_id>/surf/
├── lh.white # White matter surface
├── lh.pial # Pial surface
├── lh.sphere.reg # Spherical surface for resampling
├── rh.white # White matter surface
├── rh.pial # Pial surface
└── rh.sphere.reg # Spherical surface for resamplingNote: The toolbox automatically generates the midthickness surfaces and curvature data from these base files during processing. All other FreeSurfer outputs (thickness maps, parcellations, etc.) are not required for retinotopic mapping prediction.
!mkdir -p ./data
os.chdir('./data')
!datalad install https://github.com/OpenNeuroDatasets/ds003787.git # install NYU retinotopy dataset
os.chdir('ds003787/derivatives/freesurfer') # change directories
list_of_subs = os.listdir('.')
# download required files to run deepretinotopy
for sub in list_of_subs:
for hemisphere in ['lh', 'rh']:
for file in ['pial', 'white', 'sphere', 'sphere.reg', 'thickness']:
cmd=f"""datalad get {sub}/surf/{hemisphere}.{file}"""
os.system(cmd)Since we have preprocessed data available, the only remaining requirements are the HCP template surfaces. Thus, we need to create a “templates” folder (for example, ./templates/) and download the following files from the link above:
“fs_LR-deformed_to-fsaverage.R.sphere.32k_fs_LR.surf.gii”;
“fs_LR-deformed_to-fsaverage.L.sphere.32k_fs_LR.surf.gii”;
# Set up paths relative to current directory
os.environ['PATH_FREESURFER_DIR'] = "."
os.environ['PATH_HCP_TEMPLATE_SURFACE'] = "../../templates"
os.environ['DATASET_NAME'] = "nyu"
os.environ['MAPS'] = "polarAngle,eccentricity"# Create templates directory
os.makedirs(os.environ['PATH_HCP_TEMPLATE_SURFACE'], exist_ok=True)# Download templates to the relative path
!cd $PATH_HCP_TEMPLATE_SURFACE && \
wget -nc https://github.com/Washington-University/HCPpipelines/raw/master/global/templates/standard_mesh_atlases/resample_fsaverage/fs_LR-deformed_to-fsaverage.L.sphere.32k_fs_LR.surf.gii && \
wget -nc https://github.com/Washington-University/HCPpipelines/raw/master/global/templates/standard_mesh_atlases/resample_fsaverage/fs_LR-deformed_to-fsaverage.R.sphere.32k_fs_LR.surf.gii--2026-07-08 07:58:07-- https://github.com/Washington-University/HCPpipelines/raw/master/global/templates/standard_mesh_atlases/resample_fsaverage/fs_LR-deformed_to-fsaverage.L.sphere.32k_fs_LR.surf.gii
Resolving github.com (github.com)... 4.237.22.38
Connecting to github.com (github.com)|4.237.22.38|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/Washington-University/HCPpipelines/master/global/templates/standard_mesh_atlases/resample_fsaverage/fs_LR-deformed_to-fsaverage.L.sphere.32k_fs_LR.surf.gii [following]
--2026-07-08 07:58:08-- https://raw.githubusercontent.com/Washington-University/HCPpipelines/master/global/templates/standard_mesh_atlases/resample_fsaverage/fs_LR-deformed_to-fsaverage.L.sphere.32k_fs_LR.surf.gii
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.108.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 720487 (704K) [text/plain]
Saving to: ‘fs_LR-deformed_to-fsaverage.L.sphere.32k_fs_LR.surf.gii’
fs_LR-deformed_to-f 100%[===================>] 703.60K --.-KB/s in 0.01s
2026-07-08 07:58:08 (69.8 MB/s) - ‘fs_LR-deformed_to-fsaverage.L.sphere.32k_fs_LR.surf.gii’ saved [720487/720487]
--2026-07-08 07:58:08-- https://github.com/Washington-University/HCPpipelines/raw/master/global/templates/standard_mesh_atlases/resample_fsaverage/fs_LR-deformed_to-fsaverage.R.sphere.32k_fs_LR.surf.gii
Resolving github.com (github.com)... 4.237.22.38
Connecting to github.com (github.com)|4.237.22.38|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/Washington-University/HCPpipelines/master/global/templates/standard_mesh_atlases/resample_fsaverage/fs_LR-deformed_to-fsaverage.R.sphere.32k_fs_LR.surf.gii [following]
--2026-07-08 07:58:09-- https://raw.githubusercontent.com/Washington-University/HCPpipelines/master/global/templates/standard_mesh_atlases/resample_fsaverage/fs_LR-deformed_to-fsaverage.R.sphere.32k_fs_LR.surf.gii
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.108.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 707932 (691K) [text/plain]
Saving to: ‘fs_LR-deformed_to-fsaverage.R.sphere.32k_fs_LR.surf.gii’
fs_LR-deformed_to-f 100%[===================>] 691.34K --.-KB/s in 0.01s
2026-07-08 07:58:09 (62.1 MB/s) - ‘fs_LR-deformed_to-fsaverage.R.sphere.32k_fs_LR.surf.gii’ saved [707932/707932]
Running deepRetinotopy for a single subject¶
Here, we illustrate how to run deepRetinotopy for a single subject. Note that, if no output directory is provided, all maps are saved within each subject subdirectory in the freesurfer directory.
## Process single subject without an explicit output directory
!deepRetinotopy -s $PATH_FREESURFER_DIR -t $PATH_HCP_TEMPLATE_SURFACE -d $DATASET_NAME -m $MAPS -i sub-wlsubj001!ls $PATH_FREESURFER_DIR/sub-wlsubj001/deepRetinotopysub-wlsubj001.ROI.lh.native.label.gii
sub-wlsubj001.ROI.rh.native.label.gii
sub-wlsubj001.fs_predicted_eccentricity_lh_curvatureFeat_model.func.gii
sub-wlsubj001.fs_predicted_eccentricity_rh_curvatureFeat_model.func.gii
sub-wlsubj001.fs_predicted_polarAngle_lh_curvatureFeat_model.func.gii
sub-wlsubj001.fs_predicted_polarAngle_rh_curvatureFeat_model.func.gii
sub-wlsubj001.predicted_eccentricity_model.lh.native.func.gii
sub-wlsubj001.predicted_eccentricity_model.rh.native.func.gii
sub-wlsubj001.predicted_polarAngle_model.lh.native.func.gii
sub-wlsubj001.predicted_polarAngle_model.rh.native.func.gii
## Process single subject with an explicit output directory
! mkdir -p ../../../output && \
deepRetinotopy -s $PATH_FREESURFER_DIR -t $PATH_HCP_TEMPLATE_SURFACE -d $DATASET_NAME -m $MAPS -i sub-wlsubj001 -o ../../../outputProcessing single subject: sub-wlsubj001
Log files location: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Output log: deepRetinotopy_20260708_080424_output.log
Error log: deepRetinotopy_20260708_080424_error.log
--------------------------------------------------------------------------------
DeepRetinotopy: retinotopic mapping using deep learning
--------------------------------------------------------------------------------
Log files: /home/jovyan/workspace/books/examples/functional_imaging/data/output/deepRetinotopy_20260708_080424_output.log and deepRetinotopy_20260708_080424_error.log
--------------------------------------------------------------------------------
Directories and parameters:
Path to FreeSurfer directory: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer
Path to fs_LR-deformed_to-fsaverage template surfaces: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/templates
Dataset name: nyu
Maps: polarAngle eccentricity
Processing mode: Single subject (sub-wlsubj001)
Fast midthickness generation: yes
Output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Execution mode: Complete pipeline (Steps 1, 2, and 3)
--------------------------------------------------------------------------------
Processing left hemisphere
--------------------------------------------------------------------------------
[Step 1] Generating mid-thickness surface and curvature data...
Hemisphere: lh
Processing single subject: sub-wlsubj001
Output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Processing subject: sub-wlsubj001
=== Processing Step 1 for subject: sub-wlsubj001 ===
[sub-wlsubj001] Using custom output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001
[sub-wlsubj001] Fast mode enabled.
[sub-wlsubj001] [Step 1.1] Generating mid-thickness surface and curvature data if not available...
[sub-wlsubj001] Converting surfaces...
Saving /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/lh.white.gii as a surface
Saving /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/lh.pial.gii as a surface
[sub-wlsubj001] Generating midthickness surface...
Midthickness surface saved at /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/lh.graymid.gii
** DA[1] has coordsys with intent NIFTI_INTENT_TRIANGLE (should be NIFTI_INTENT_POINTSET)
Saving /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/lh.graymid as a surface
[sub-wlsubj001] Computing curvature...
total integrated curvature = -2.905*4pi (-36.505) --> 4 handles
ICI = 155.2, FI = 1392.0, variation=22879.765
writing Gaussian curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/lh.graymid.K...done.
writing mean curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/lh.graymid.H...done.
[sub-wlsubj001] Mid-thickness surface has been generated
[sub-wlsubj001] [Step 1.2] Preparing native surfaces for resampling...
[sub-wlsubj001] Running freesurfer-resample-prep...
Saving /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/lh.midthickness.surf.gii.temp39153.white.surf.gii as a surface
Saving /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/lh.midthickness.surf.gii.temp39153.pial.surf.gii as a surface
Saving /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/lh.sphere.reg.surf.gii as a surface
[sub-wlsubj001] Converting curvature data...
[sub-wlsubj001] Resampling native data to fsaverage space...
[sub-wlsubj001] Data resampling complete
=== Subject sub-wlsubj001 completed in 0 minutes ===
===============================================
[Step 1] COMPLETED!
Total execution time: 0m 15s
Subject processed: sub-wlsubj001
Output location: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
--------------------------------------------------------------------------------
Map: polarAngle
--------------------------------------------------------------------------------
[Step 2] Retinotopy prediction...
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
Done!
===============================================
[Step 2] STARTING INFERENCE
Prediction type: polarAngle
Hemisphere: lh
Dataset: nyu
Stimulus: original
Output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
Output directory set to: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Data path: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Temporary processed directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/processed_39269_9077fd1f_83941
Processing single subject: sub-wlsubj001
Found 1 subjects to process: ['sub-wlsubj001']
Final subject list after validation: 1 subjects: ['sub-wlsubj001']
Created output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
[Step 2.1] Loading the dataset...
Dataset loaded successfully
Dataset loading time: 0.34 minutes
[Step 2.2] Generating predictions with pre-trained models...
Loading model 1/1...
Using device: cpu
Loading model from: deepRetinotopy_polarAngle_LH_model.pt
Running inference for model 1...
Inference completed in 0.22 minutes
Saving predictions for 1 subjects...
[sub-wlsubj001] Saving predictions to: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/deepRetinotopy
[sub-wlsubj001] Created output directory
[sub-wlsubj001] Completed in 0.0s
Model 1 processing completed in 0.24 minutes
===============================================
[Step 2] COMPLETED!
Total execution time: 0m 35s
Subject processed: sub-wlsubj001
Prediction type: polarAngle | Hemisphere: lh | Dataset: nyu
Output location: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
Cleaned up temporary directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/processed_39269_9077fd1f_83941
[Step 3] Resampling predictions to native space...
Model: model
Map: polarAngle
Hemisphere: lh
Processing single subject: sub-wlsubj001
Output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Processing subject: sub-wlsubj001
=== Processing Step 3 for subject: sub-wlsubj001 ===
[sub-wlsubj001] Using custom output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001
[sub-wlsubj001] Resampling ROI from fsaverage to native space for the left hemisphere...
[sub-wlsubj001] Resampling predicted map from fsaverage to native space for the left hemisphere...
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_lh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
[sub-wlsubj001] Transforming polar angle map of the left hemisphere...
[sub-wlsubj001] Applying mask to the predicted map of the left hemisphere...
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/deepRetinotopy/sub-wlsubj001.ROI.lh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
=== Subject sub-wlsubj001 completed in 0 minutes ===
===============================================
[Step 3] COMPLETED!
Total execution time: 0m 3s
Subject processed: sub-wlsubj001
Map: polarAngle | Model: model | Hemisphere: lh
Output location: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
polarAngle resampling completed for lh hemisphere
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Map: eccentricity
--------------------------------------------------------------------------------
[Step 2] Retinotopy prediction...
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
Done!
===============================================
[Step 2] STARTING INFERENCE
Prediction type: eccentricity
Hemisphere: lh
Dataset: nyu
Stimulus: original
Output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
Output directory set to: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Data path: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Temporary processed directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/processed_39398_f9083f60_26255
Processing single subject: sub-wlsubj001
Found 1 subjects to process: ['sub-wlsubj001']
Final subject list after validation: 1 subjects: ['sub-wlsubj001']
Created output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
[Step 2.1] Loading the dataset...
Dataset loaded successfully
Dataset loading time: 0.34 minutes
[Step 2.2] Generating predictions with pre-trained models...
Loading model 1/1...
Using device: cpu
Loading model from: deepRetinotopy_eccentricity_LH_model.pt
Running inference for model 1...
Inference completed in 0.22 minutes
Saving predictions for 1 subjects...
[sub-wlsubj001] Saving predictions to: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/deepRetinotopy
[sub-wlsubj001] Completed in 0.0s
Model 1 processing completed in 0.24 minutes
===============================================
[Step 2] COMPLETED!
Total execution time: 0m 35s
Subject processed: sub-wlsubj001
Prediction type: eccentricity | Hemisphere: lh | Dataset: nyu
Output location: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
Cleaned up temporary directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/processed_39398_f9083f60_26255
[Step 3] Resampling predictions to native space...
Model: model
Map: eccentricity
Hemisphere: lh
Processing single subject: sub-wlsubj001
Output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Processing subject: sub-wlsubj001
=== Processing Step 3 for subject: sub-wlsubj001 ===
[sub-wlsubj001] Using custom output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001
[sub-wlsubj001] Resampling ROI from fsaverage to native space for the left hemisphere...
[sub-wlsubj001] Resampling predicted map from fsaverage to native space for the left hemisphere...
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_lh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
[sub-wlsubj001] Applying mask to the predicted map of the left hemisphere...
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/deepRetinotopy/sub-wlsubj001.ROI.lh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
=== Subject sub-wlsubj001 completed in 0 minutes ===
===============================================
[Step 3] COMPLETED!
Total execution time: 0m 2s
Subject processed: sub-wlsubj001
Map: eccentricity | Model: model | Hemisphere: lh
Output location: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
eccentricity resampling completed for lh hemisphere
--------------------------------------------------------------------------------
Processing right hemisphere
--------------------------------------------------------------------------------
[Step 1] Generating mid-thickness surface and curvature data...
Hemisphere: rh
Processing single subject: sub-wlsubj001
Output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Processing subject: sub-wlsubj001
=== Processing Step 1 for subject: sub-wlsubj001 ===
[sub-wlsubj001] Using custom output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001
[sub-wlsubj001] Fast mode enabled.
[sub-wlsubj001] [Step 1.1] Generating mid-thickness surface and curvature data if not available...
[sub-wlsubj001] Converting surfaces...
Saving /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/rh.white.gii as a surface
Saving /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/rh.pial.gii as a surface
[sub-wlsubj001] Generating midthickness surface...
Midthickness surface saved at /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/rh.graymid.gii
** DA[1] has coordsys with intent NIFTI_INTENT_TRIANGLE (should be NIFTI_INTENT_POINTSET)
Saving /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/rh.graymid as a surface
[sub-wlsubj001] Computing curvature...
total integrated curvature = -3.967*4pi (-49.856) --> 5 handles
ICI = 149.7, FI = 1361.8, variation=22336.733
writing Gaussian curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/rh.graymid.K...done.
writing mean curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/rh.graymid.H...done.
[sub-wlsubj001] Mid-thickness surface has been generated
[sub-wlsubj001] [Step 1.2] Preparing native surfaces for resampling...
[sub-wlsubj001] Running freesurfer-resample-prep...
Saving /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/rh.midthickness.surf.gii.temp39542.white.surf.gii as a surface
Saving /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/rh.midthickness.surf.gii.temp39542.pial.surf.gii as a surface
Saving /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/surf/rh.sphere.reg.surf.gii as a surface
[sub-wlsubj001] Converting curvature data...
[sub-wlsubj001] Resampling native data to fsaverage space...
[sub-wlsubj001] Data resampling complete
=== Subject sub-wlsubj001 completed in 0 minutes ===
===============================================
[Step 1] COMPLETED!
Total execution time: 0m 15s
Subject processed: sub-wlsubj001
Output location: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
--------------------------------------------------------------------------------
Map: polarAngle
--------------------------------------------------------------------------------
[Step 2] Retinotopy prediction...
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
Done!
===============================================
[Step 2] STARTING INFERENCE
Prediction type: polarAngle
Hemisphere: rh
Dataset: nyu
Stimulus: original
Output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
Output directory set to: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Data path: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Temporary processed directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/processed_39658_83124a66_83067
Processing single subject: sub-wlsubj001
Found 1 subjects to process: ['sub-wlsubj001']
Final subject list after validation: 1 subjects: ['sub-wlsubj001']
Created output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
[Step 2.1] Loading the dataset...
Dataset loaded successfully
Dataset loading time: 0.34 minutes
[Step 2.2] Generating predictions with pre-trained models...
Loading model 1/1...
Using device: cpu
Loading model from: deepRetinotopy_polarAngle_RH_model.pt
Running inference for model 1...
Inference completed in 0.21 minutes
Saving predictions for 1 subjects...
[sub-wlsubj001] Saving predictions to: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/deepRetinotopy
[sub-wlsubj001] Completed in 0.0s
Model 1 processing completed in 0.24 minutes
===============================================
[Step 2] COMPLETED!
Total execution time: 0m 34s
Subject processed: sub-wlsubj001
Prediction type: polarAngle | Hemisphere: rh | Dataset: nyu
Output location: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
Cleaned up temporary directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/processed_39658_83124a66_83067
[Step 3] Resampling predictions to native space...
Model: model
Map: polarAngle
Hemisphere: rh
Processing single subject: sub-wlsubj001
Output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Processing subject: sub-wlsubj001
=== Processing Step 3 for subject: sub-wlsubj001 ===
[sub-wlsubj001] Using custom output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001
[sub-wlsubj001] Resampling ROI from fsaverage to native space for the right hemisphere...
[sub-wlsubj001] Resampling predicted map from fsaverage to native space for the right hemisphere...
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_rh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
[sub-wlsubj001] Applying mask to the predicted map of the right hemisphere...
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/deepRetinotopy/sub-wlsubj001.ROI.rh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
=== Subject sub-wlsubj001 completed in 0 minutes ===
===============================================
[Step 3] COMPLETED!
Total execution time: 0m 3s
Subject processed: sub-wlsubj001
Map: polarAngle | Model: model | Hemisphere: rh
Output location: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
polarAngle resampling completed for rh hemisphere
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Map: eccentricity
--------------------------------------------------------------------------------
[Step 2] Retinotopy prediction...
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
Done!
===============================================
[Step 2] STARTING INFERENCE
Prediction type: eccentricity
Hemisphere: rh
Dataset: nyu
Stimulus: original
Output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
Output directory set to: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Data path: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Temporary processed directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/processed_39763_ab84ef06_24322
Processing single subject: sub-wlsubj001
Found 1 subjects to process: ['sub-wlsubj001']
Final subject list after validation: 1 subjects: ['sub-wlsubj001']
Created output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
[Step 2.1] Loading the dataset...
Dataset loaded successfully
Dataset loading time: 0.35 minutes
[Step 2.2] Generating predictions with pre-trained models...
Loading model 1/1...
Using device: cpu
Loading model from: deepRetinotopy_eccentricity_RH_model.pt
Running inference for model 1...
Inference completed in 0.21 minutes
Saving predictions for 1 subjects...
[sub-wlsubj001] Saving predictions to: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/deepRetinotopy
[sub-wlsubj001] Completed in 0.0s
Model 1 processing completed in 0.23 minutes
===============================================
[Step 2] COMPLETED!
Total execution time: 0m 35s
Subject processed: sub-wlsubj001
Prediction type: eccentricity | Hemisphere: rh | Dataset: nyu
Output location: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
Cleaned up temporary directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/processed_39763_ab84ef06_24322
[Step 3] Resampling predictions to native space...
Model: model
Map: eccentricity
Hemisphere: rh
Processing single subject: sub-wlsubj001
Output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output
Processing subject: sub-wlsubj001
=== Processing Step 3 for subject: sub-wlsubj001 ===
[sub-wlsubj001] Using custom output directory: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001
[sub-wlsubj001] Resampling ROI from fsaverage to native space for the right hemisphere...
[sub-wlsubj001] Resampling predicted map from fsaverage to native space for the right hemisphere...
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_rh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
[sub-wlsubj001] Applying mask to the predicted map of the right hemisphere...
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/output/sub-wlsubj001/deepRetinotopy/sub-wlsubj001.ROI.rh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
=== Subject sub-wlsubj001 completed in 0 minutes ===
===============================================
[Step 3] COMPLETED!
Total execution time: 0m 2s
Subject processed: sub-wlsubj001
Map: eccentricity | Model: model | Hemisphere: rh
Output location: /home/jovyan/workspace/books/examples/functional_imaging/data/output
===============================================
eccentricity resampling completed for rh hemisphere
--------------------------------------------------------------------------------
Execution completed!
All output files have been saved to: /home/jovyan/workspace/books/examples/functional_imaging/data/output
!ls ../../../output/sub-wlsubj001/deepRetinotopy surf
Running deepRetinotopy for multiple subjects¶
If no subject is specified, all subjects within the FreeSurfer directory will be processed. However, for optimal speed, parallelising the processing for multiple subjects across multiple cores is preferred.
## Determine how many cores you have available
os.environ['NUMBER_OF_CORES'] = str(os.cpu_count() - 1)%%bash
SUBJECT_LIST=(sub-wlsubj001 sub-wlsubj004 sub-wlsubj006 sub-wlsubj007)
process_subject() {
local subject=$1
echo "Processing subject: $subject"
deepRetinotopy -s $PATH_FREESURFER_DIR -t $PATH_HCP_TEMPLATE_SURFACE -d $DATASET_NAME -m $MAPS -i "$subject"
}
export -f process_subject
printf "%s\n" "${SUBJECT_LIST[@]}" | xargs -P "$NUMBER_OF_CORES" -I {} bash -c 'process_subject "{}"'/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
** DA[1] has coordsys with intent NIFTI_INTENT_TRIANGLE (should be NIFTI_INTENT_POINTSET)
** DA[1] has coordsys with intent NIFTI_INTENT_TRIANGLE (should be NIFTI_INTENT_POINTSET)
** DA[1] has coordsys with intent NIFTI_INTENT_TRIANGLE (should be NIFTI_INTENT_POINTSET)
Processing...
total integrated curvature = -11.237*4pi (-141.203) --> 12 handles
ICI = 147.3, FI = 1471.0, variation=23704.286
writing Gaussian curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj006/surf/lh.graymid.K...done.
writing mean curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj006/surf/lh.graymid.H...done.
total integrated curvature = -0.559*4pi (-7.022) --> 2 handles
ICI = 144.8, FI = 1382.4, variation=22337.118
writing Gaussian curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj007/surf/lh.graymid.K...done.
writing mean curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj007/surf/lh.graymid.H...done.
total integrated curvature = -7.220*4pi (-90.731) --> 8 handles
ICI = 151.6, FI = 1563.0, variation=24939.408
writing Gaussian curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj004/surf/lh.graymid.K...done.
writing mean curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj004/surf/lh.graymid.H...done.
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
Processing...
Processing...
Done!
Done!
Done!
Done!
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_lh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj001/deepRetinotopy/sub-wlsubj001.ROI.lh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_lh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_lh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj006/deepRetinotopy/sub-wlsubj006.ROI.lh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj007/deepRetinotopy/sub-wlsubj007.ROI.lh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_lh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj004/deepRetinotopy/sub-wlsubj004.ROI.lh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
Processing...
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
Done!
Done!
Done!
Done!
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_lh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj001/deepRetinotopy/sub-wlsubj001.ROI.lh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_lh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_lh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj006/deepRetinotopy/sub-wlsubj006.ROI.lh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj007/deepRetinotopy/sub-wlsubj007.ROI.lh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_lh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj004/deepRetinotopy/sub-wlsubj004.ROI.lh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
** DA[1] has coordsys with intent NIFTI_INTENT_TRIANGLE (should be NIFTI_INTENT_POINTSET)
** DA[1] has coordsys with intent NIFTI_INTENT_TRIANGLE (should be NIFTI_INTENT_POINTSET)
total integrated curvature = -10.888*4pi (-136.823) --> 12 handles
ICI = 152.0, FI = 1487.7, variation=24085.999
writing Gaussian curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj006/surf/rh.graymid.K...done.
writing mean curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj006/surf/rh.graymid.H...done.
** DA[1] has coordsys with intent NIFTI_INTENT_TRIANGLE (should be NIFTI_INTENT_POINTSET)
total integrated curvature = -0.184*4pi (-2.317) --> 1 handles
ICI = 151.2, FI = 1466.0, variation=23585.355
writing Gaussian curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj007/surf/rh.graymid.K...done.
writing mean curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj007/surf/rh.graymid.H...done.
Done!
total integrated curvature = -8.002*4pi (-100.554) --> 9 handles
ICI = 152.9, FI = 1618.7, variation=25701.339
writing Gaussian curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj004/surf/rh.graymid.K...done.
writing mean curvature to /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj004/surf/rh.graymid.H...done.
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
Processing...
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_rh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj001/deepRetinotopy/sub-wlsubj001.ROI.rh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
Done!
Done!
Done!
Done!
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_rh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_rh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj006/deepRetinotopy/sub-wlsubj006.ROI.rh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj007/deepRetinotopy/sub-wlsubj007.ROI.rh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_rh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
Processing...
Processing...
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj004/deepRetinotopy/sub-wlsubj004.ROI.rh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:68: UserWarning: An issue occurred while importing 'pyg-lib'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'pyg-lib'. "
/opt/miniconda-latest/lib/python3.12/site-packages/torch_geometric/typing.py:124: UserWarning: An issue occurred while importing 'torch-sparse'. Disabling its usage. Stacktrace: /usr/lib64/libm.so.6: version `GLIBC_2.29' not found (required by /opt/miniconda-latest/lib/python3.12/site-packages/libpyg.so)
warnings.warn(f"An issue occurred while importing 'torch-sparse'. "
Processing...
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_rh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj001/deepRetinotopy/sub-wlsubj001.ROI.rh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
Done!
Done!
Done!
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_rh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_rh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj006/deepRetinotopy/sub-wlsubj006.ROI.rh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj007/deepRetinotopy/sub-wlsubj007.ROI.rh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /opt/deepRetinotopy_TheToolbox/main/../labels/ROI_WangPlusFovea/ROI.fs_rh.label.gii contains data array with NIFTI_INTENT_LABEL !!!
WARNING: Metric File: /home/jovyan/workspace/books/examples/functional_imaging/data/ds003787/derivatives/freesurfer/sub-wlsubj004/deepRetinotopy/sub-wlsubj004.ROI.rh.native.label.gii contains data array with NIFTI_INTENT_LABEL !!!
!ls ./sub-wlsubj004/deepRetinotopysub-wlsubj004.ROI.lh.native.label.gii
sub-wlsubj004.ROI.rh.native.label.gii
sub-wlsubj004.fs_predicted_eccentricity_lh_curvatureFeat_model.func.gii
sub-wlsubj004.fs_predicted_eccentricity_rh_curvatureFeat_model.func.gii
sub-wlsubj004.fs_predicted_polarAngle_lh_curvatureFeat_model.func.gii
sub-wlsubj004.fs_predicted_polarAngle_rh_curvatureFeat_model.func.gii
sub-wlsubj004.predicted_eccentricity_model.lh.native.func.gii
sub-wlsubj004.predicted_eccentricity_model.rh.native.func.gii
sub-wlsubj004.predicted_polarAngle_model.lh.native.func.gii
sub-wlsubj004.predicted_polarAngle_model.rh.native.func.gii
Maps visualization¶
Finally, we can visualize the predicted maps in the individual’s native space using nilearn.
from nilearn import plotting
from ipywidgets import Dropdown, interact
import nibabel as nib
import numpy as np
from IPython.display import display
def plot_data(subject, retinotopic_map):
background = np.array(nib.load(f"./{subject}/surf/lh.graymid.H.gii").agg_data())[:]
background[background < 0] = -1
background[background > 1] = 1
threshold = 1
data = np.array(nib.load(f"./{subject}/deepRetinotopy/{subject}.predicted_{retinotopic_map}_model.lh.native.func.gii").agg_data())[:]
data[data != 0] = data[data != 0] + threshold
if retinotopic_map == 'eccentricity':
max_value = 8
else:
max_value = 360
view = plotting.view_surf(
surf_mesh=f"./{subject}/surf/lh.midthickness.surf.gii",
surf_map=np.reshape(data[:], (-1)),
cmap="gist_rainbow_r", black_bg=False, symmetric_cmap=False, bg_map = background,
threshold=threshold, vmax=max_value + threshold, vmin = threshold)
return view
⚠️ Note: ipywidgets that rely on Python callbacks (observe, on_click) require a running kernel and do not function in the static HTML version of this notebook. Widgets using client-side trait linking (jslink) remain interactive without a kernel.
subjects = ['sub-wlsubj001', 'sub-wlsubj004', 'sub-wlsubj006', 'sub-wlsubj007']
retinotopic_maps = ['eccentricity', 'polarAngle']
@interact(subject = subjects, retinotopic_map = retinotopic_maps)
def plot1(subject, retinotopic_map):
view = plot_data(subject, retinotopic_map)
display(view)Dependencies in Jupyter/Python¶
Using the package watermark to document system environment and software versions used in this notebook, alongside the Neurodesktop version extracted from the
JUPYTER_IMAGEorNEURODESKTOP_VERSIONenvironment variables.
import os
%load_ext watermark
%watermark
%watermark --iversions
neurodesktop_version = (
os.environ.get('JUPYTER_IMAGE', '').split(':')[-1] or
os.environ.get('NEURODESKTOP_VERSION', 'unknown')
)
print(f"Neurodesktop version: {neurodesktop_version}")Last updated: 2026-07-08T08:11:23.644260+00:00
Python implementation: CPython
Python version : 3.13.13
IPython version : 9.12.0
Compiler : GCC 14.3.0
OS : Linux
Release : 6.8.0-111-generic
Machine : x86_64
Processor : x86_64
CPU cores : 16
Architecture: 64bit
IPython : 9.12.0
ipywidgets: 8.1.8
nibabel : 5.3.3
nilearn : 0.13.1
numpy : 2.3.5
Neurodesktop version: 2026-06-04