@@ -111,12 +111,15 @@ def fetch_parcellation(
111111 The surface template. Valid values are "fsaverage", "fsaverage5",
112112 "fsaverage6", "fslr32k", "civet41k", "civet164k", by default "fsaverage5".
113113 atlas : str
114- Name of the atlas. Valid names are "cammoun", "glasser", "schaefer", "yeo".
114+ Name of the atlas. Valid names are "cammoun", "destrieux", "glasser",
115+ "schaefer", "yeo".
115116 n_regions : int
116117 Number of regions of the requested atlas. Valid values for the cammoun
117118 atlas are 33, 60, 125, 250, 500. Valid values for the glasser atlas are
118119 360. Valid values for the "schaefer" atlas are 100, 200, 300, 400, 500,
119- 600, 800, 1000. Valid values for "yeo" are 7 and 17.
120+ 600, 800, 1000. Valid values for "yeo" are 7 and 17. The
121+ "destrieux" atlas (a2009s, FreeSurfer's 75 cortical labels per
122+ hemisphere) ignores ``n_regions``.
120123 join : bool, optional
121124 If true, returns parcellation as a single array, if false, returns an
122125 array per hemisphere, by default True.
@@ -154,6 +157,8 @@ def fetch_parcellation(
154157 parcellations = _fetch_glasser_parcellation (template , data_dir )
155158 elif atlas == "yeo" :
156159 parcellations = _fetch_yeo_parcellation (template , n_regions , data_dir )
160+ elif atlas == "destrieux" :
161+ parcellations = _fetch_destrieux_parcellation (template , data_dir )
157162 else :
158163 raise ValueError (f"Invalid atlas: { atlas } " )
159164
@@ -537,6 +542,48 @@ def _fetch_glasser_parcellation(template: str, data_dir: Path) -> List[np.ndarra
537542 return parcellations
538543
539544
545+ def _fetch_destrieux_parcellation (
546+ template : str , data_dir : Path
547+ ) -> List [np .ndarray ]:
548+ """Fetches the Destrieux 2009 (FreeSurfer ``aparc.a2009s``) parcellation.
549+
550+ Uses :func:`nilearn.datasets.fetch_atlas_surf_destrieux`, which provides
551+ the parcellation on the ``fsaverage5`` surface. For other ``fsaverage*``
552+ templates we resample with nearest-neighbour interpolation; ``fslr32k``
553+ is not supported because the destrieux atlas is FreeSurfer-specific.
554+ """
555+ from nilearn .datasets import fetch_atlas_surf_destrieux
556+
557+ if template == "fslr32k" :
558+ raise ValueError (
559+ "The destrieux atlas is FreeSurfer-specific; fslr32k is not "
560+ "supported. Use a fsaverage* template instead."
561+ )
562+
563+ bunch = fetch_atlas_surf_destrieux (data_dir = str (data_dir ))
564+ # nilearn returns int32 arrays for fsaverage5 (10242 vertices/hemi).
565+ parcellations = [np .asarray (bunch ["map_left" ]), np .asarray (bunch ["map_right" ])]
566+
567+ if template != "fsaverage5" :
568+ # Nearest-neighbour resample fsaverage5 -> requested fsaverage*.
569+ from brainstat .mesh .interpolate import _surf2surf
570+
571+ src_left , src_right = fetch_template_surface (
572+ "fsaverage5" , layer = "white" , join = False
573+ )
574+ dst_left , dst_right = fetch_template_surface (
575+ template , layer = "white" , join = False
576+ )
577+ parcellations [0 ] = _surf2surf (
578+ src_left , dst_left , parcellations [0 ], interpolation = "nearest"
579+ ).astype (parcellations [0 ].dtype )
580+ parcellations [1 ] = _surf2surf (
581+ src_right , dst_right , parcellations [1 ], interpolation = "nearest"
582+ ).astype (parcellations [1 ].dtype )
583+
584+ return parcellations
585+
586+
540587def _fetch_yeo_parcellation (
541588 template : str , n_regions : int , data_dir : Path
542589) -> List [np .ndarray ]:
0 commit comments