@@ -1005,8 +1005,7 @@ def cifti_surfaces_plot(
1005
1005
output_file: :obj:`str`
1006
1006
The file where the figure is saved.
1007
1007
"""
1008
- import surfplot as splt
1009
- from surfplot .utils import add_fslr_medial_wall
1008
+ from nilearn .plotting import plot_surf
1010
1009
1011
1010
def get_surface_meshes (density , surface_type ):
1012
1011
import templateflow .api as tf
@@ -1036,28 +1035,31 @@ def get_surface_meshes(density, surface_type):
1036
1035
# as potential nonsteady states
1037
1036
data = img .dataobj [5 :20 ].mean (axis = 0 )
1038
1037
1039
- cortex_data = _concat_brain_struct_data ((left_cortex , right_cortex ), data )
1040
- if density == "32k" and len (cortex_data ) != 59412 :
1038
+ if density == "32k" and len (data ) != 91282 :
1041
1039
raise ValueError ("Cortex data is not in fsLR space" )
1040
+
1042
1041
# medial wall needs to be added back in
1043
- cortex_data = add_fslr_medial_wall (cortex_data )
1044
- if clip_range :
1045
- cortex_data = np .clip (cortex_data , clip_range [0 ], clip_range [1 ], out = cortex_data )
1042
+ lh_data = np .full (max (left_cortex .vertex_indices ) + 1 , np .nan )
1043
+ rh_data = np .full (max (right_cortex .vertex_indices ) + 1 , np .nan )
1044
+ lh_data [left_cortex .vertex_indices ] = _concat_brain_struct_data ([left_cortex ], data )
1045
+ rh_data [right_cortex .vertex_indices ] = _concat_brain_struct_data ([right_cortex ], data )
1046
1046
1047
- lh_data , rh_data = np .array_split (cortex_data , 2 )
1047
+ if clip_range :
1048
+ lh_data = np .clip (lh_data , clip_range [0 ], clip_range [1 ], out = lh_data )
1049
+ rh_data = np .clip (rh_data , clip_range [0 ], clip_range [1 ], out = rh_data )
1048
1050
1049
1051
# Build the figure
1050
1052
lh_mesh , rh_mesh = get_surface_meshes (density , surface_type )
1051
- p = splt . Plot (
1052
- surf_lh = lh_mesh , surf_rh = rh_mesh , layout = splt_kwargs . pop ( "layout" , "row" ), ** splt_kwargs
1053
- )
1054
- p . add_layer ({ 'left' : lh_data , 'right' : rh_data }, cmap = 'YlOrRd_r ' )
1055
- figure = p . build () # figsize - leave default?
1053
+ figure = plt . figure ( figsize = plt . figaspect ( 0.5 ))
1054
+ ax0 = figure . add_subplot ( 1 , 2 , 1 , projection = '3d' )
1055
+ plot_surf ( lh_mesh , lh_data , cmap = 'YlOrRd_r' , axes = ax0 )
1056
+ ax1 = figure . add_subplot ( 1 , 2 , 2 , projection = '3d ' )
1057
+ plot_surf ( lh_mesh , lh_data , cmap = 'YlOrRd_r' , axes = ax1 )
1056
1058
1057
1059
if output_file is not None :
1058
1060
figure .savefig (output_file , bbox_inches = "tight" )
1059
1061
plt .close (figure )
1060
- figure = None
1062
+ del figure
1061
1063
return output_file
1062
1064
1063
1065
return figure
0 commit comments