Code
# install.packages(c("plotly","ggseg.formats","ggseg.meshes","R.matlab"))
library(plotly)Lie still in an MRI scanner with nothing to do, and the brain does not go quiet. Its parts keep working, and parts far apart rise and fall together, as if they kept in touch (Biswal et al. 1995). Parts that keep time this way form networks. Yeo and colleagues measured this in 1,000 healthy young adults and divided the cortex into seven networks, and more finely into seventeen (Yeo et al. 2011). This data story draws them on the same average brain as Inside the Human Brain, with the same tools. Six questions:
The networks come from the repository of Yeo’s lab on GitHub (CBIG), under the MIT license. For each of the 10,242 points of each hemisphere of fsaverage5, FreeSurfer’s average brain, its files give the network of the point among seven and among seventeen, how surely it belongs there, and how strong the scanner’s signal was there. The page downloads the six files, 0.6 MB in all, once. The brain and the Desikan–Killiany atlas of its regions and lobes come with the R packages ggseg.meshes and ggseg.formats, as on Inside the Human Brain.
The words of this page:
# short labels of numbers and lists for the text
number<-function(x) {
result<-format(round(x),big.mark=",",trim=TRUE)
return(result)
}
one<-function(x) {
result<-format(round(x,1),nsmall=1,trim=TRUE)
return(result)
}
# a correlation or a silhouette, to two decimals, with a minus sign rather than a hyphen
two<-function(x) {
result<-sub("^-","−",format(round(x,2),nsmall=2,trim=TRUE))
return(result)
}
percent<-function(x) {
result<-paste0(round(x),"%")
return(result)
}
and_list<-function(x) {
result<-if(length(x)<2) paste(x) else paste(paste(x[-length(x)],collapse=", "),"and",
x[length(x)])
return(result)
}
count_words<-function(n) {
words<-c("one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve")
result<-if(n<=12) words[n] else number(n)
return(result)
}
upper_first<-function(x) {
result<-paste0(toupper(substr(x,1,1)),substring(x,2))
return(result)
}
lower_first<-function(x) {
result<-paste0(tolower(substr(x,1,1)),substring(x,2))
return(result)
}# a surface of the cortex of one hemisphere of fsaverage5, 10,242 points joined in 20,480 triangles.
# ggseg.meshes keeps it turned a quarter round, with x from the back to the front: here x runs from
# left to right, y from the back to the front and z from the bottom to the top, in mm, as on Inside
# the Human Brain
read_surface<-function(hemisphere,surface) {
mesh<-ggseg.meshes::get_cortical_mesh(hemisphere,surface)
vertices<-cbind(x=-mesh$vertices$y,y=mesh$vertices$x,z=mesh$vertices$z)
result<-list(vertices=vertices,faces=as.matrix(mesh$faces))
return(result)
}
# the area of each triangle of a surface, in mm²
triangle_area<-function(vertices,faces) {
a<-vertices[faces[,2],]-vertices[faces[,1],]
b<-vertices[faces[,3],]-vertices[faces[,1],]
result<-sqrt((a[,2]*b[,3]-a[,3]*b[,2])^2+(a[,3]*b[,1]-a[,1]*b[,3])^2+
(a[,1]*b[,2]-a[,2]*b[,1])^2)/2
return(result)
}
# the Desikan-Killiany atlas: the points of each region (numbered from 0), and the lobe of each
atlas<-ggseg.formats::dk()
atlas_points<-atlas$data$vertices
atlas_lobes<-unique(as.data.frame(atlas$core)[,c("label","lobe")])
hemispheres<-c(lh="left",rh="right")
faces<-list()
points<-data.frame()
for(h in names(hemispheres)) {
pial<-read_surface(h,"pial")
middle<-read_surface(h,"midthickness")$vertices
# the inflated surface comes from ggseg.formats, already in this frame but with each hemisphere
# around x = 0: they move apart, their inner sides 4 mm from the middle
inflated<-as.matrix(ggseg.formats::get_brain_mesh(h,"inflated")$vertices)
inflated[,1]<-if(h=="lh") inflated[,1]-max(inflated[,1])-4 else inflated[,1]-min(inflated[,1])+4
faces[[h]]<-pial$faces
# the region of each point; the points of no region, and those that the atlas calls corpus
# callosum, are the medial wall, where the hemisphere is cut away from the structures under it
region<-rep("medialwall",nrow(pial$vertices))
for(k in grep(paste0("^",h,"_"),atlas_points$label))
region[atlas_points$vertices[[k]]+1]<-sub("^[lr]h_","",atlas_points$label[k])
region[region=="corpuscallosum"]<-"medialwall"
# the area of the cortex around each point, measured halfway through its thickness: a third of
# each triangle that the point is a corner of
area<-as.vector(rowsum(rep(triangle_area(middle,pial$faces)/3,3),as.vector(pial$faces)))
points<-rbind(points,data.frame(hemisphere=hemispheres[[h]],region=region,pial$vertices,
inflated_x=inflated[,1],inflated_y=inflated[,2],
inflated_z=inflated[,3],area=area))
}
points$lobe<-atlas_lobes$lobe[match(paste0(substr(points$hemisphere,1,1),"h_",points$region),
atlas_lobes$label)]
xyz<-as.matrix(points[,c("x","y","z")])download_file<-function(url,file,tries=3) {
for(k in seq_len(tries)) {
done<-tryCatch(download.file(url,file,mode="wb",quiet=TRUE)==0,error=function(e) FALSE)
if(done)
return(invisible(file))
Sys.sleep(10)
}
stop("Could not download ",url)
}
cache<-tools::R_user_dir("illustration","cache")
dir.create(cache,recursive=TRUE,showWarnings=FALSE)
# the files of the networks, from the repository of Yeo's lab at the commits that last changed them;
# the page keeps its downloads, and the checksums make sure that they are the files the page was
# written for
cbig<-paste0("https://raw.githubusercontent.com/ThomasYeoLab/CBIG/%s/stable_projects/",
"brain_parcellation/Yeo2011_fcMRI_clustering/1000subjects_reference/%s")
maps_commit<-"ef8e1feba9ee1d7cb8940c4ec27ce3d34941ad62" # 14 October 2016
names_commit<-"703454dba7b6e0b1cfb97beb449e1593c5170547" # 23 March 2021
yeo_files<-data.frame(
file=c("1000subjects_clusters007_ref.mat","1000subjects_clusters017_ref.mat",
"lh.1000subjects.snr.nii.gz","rh.1000subjects.snr.nii.gz","7NetworksOrderedNames.csv",
"17NetworksOrderedNames.csv"),
commit=c(rep(maps_commit,4),rep(names_commit,2)),
md5=c("ab6ce12471152c81083a51e31a294bfb","2c79682024442e9262f7e148d1c795e0",
"ce375053ee2d4be430cb74e97c9fa10e","578926c5ad4103bb321b6c559f1ef78e",
"7de3f05a2d2002f1ba56a8d2fc6875b7","775709611220219eb4385f44c2272f00"))
yeo_files$path<-file.path(cache,paste0("yeo2011_",yeo_files$file))
for(k in seq_len(nrow(yeo_files))) {
if(!file.exists(yeo_files$path[k]))
download_file(sprintf(cbig,yeo_files$commit[k],yeo_files$file[k]),yeo_files$path[k])
stopifnot(unname(tools::md5sum(yeo_files$path[k]))==yeo_files$md5[k])
}
# the network of each point among 7 and among 17 (0: none, on the medial wall), and its silhouette
# in the map of 7. R.matlab reads the MATLAB files; each holds both hemispheres
maps<-list(R.matlab::readMat(yeo_files$path[1]),R.matlab::readMat(yeo_files$path[2]))
points$network<-c(maps[[1]]$lh.labels,maps[[1]]$rh.labels)
points$network17<-c(maps[[2]]$lh.labels,maps[[2]]$rh.labels)
points$silhouette<-c(maps[[1]]$lh.s,maps[[1]]$rh.s)
# the signal-to-noise ratio of the scans at each point, averaged over the 1,000 people: a NIfTI file
# of one value per point, 4-byte numbers that start where its header says
read_values<-function(file) {
connection<-gzfile(file,"rb")
bytes<-readBin(connection,"raw",1e7)
close(connection)
dims<-readBin(bytes[41:56],"integer",8,size=2,endian="little")
stopifnot(readBin(bytes[71:72],"integer",size=2,endian="little")==16)
offset<-readBin(bytes[109:112],"numeric",size=4,endian="little")
result<-readBin(bytes[(offset+1):length(bytes)],"numeric",prod(dims[1+seq_len(dims[1])]),size=4,
endian="little")
return(result)
}
points$snr<-c(read_values(yeo_files$path[3]),read_values(yeo_files$path[4]))
# the names of the networks, in the order of their numbers in the files
names7<-trimws(read.csv(yeo_files$path[5])[[2]])
names17<-trimws(read.csv(yeo_files$path[6])[[2]])
# the networks and the mesh should number their points alike: the points that the atlas puts in the
# cortex should have a network, and those of its medial wall none
in_cortex<-points$region!="medialwall"
with_network<-100*mean(points$network[in_cortex]>0)
wall_without<-100*mean(points$network[!in_cortex]==0)The networks fit the mesh: 99.9% of the points that the atlas puts in the cortex have a network, and 85% of the points of its medial wall have none. The others lie along the edge of the medial wall, which the two maps draw a little differently.
# the seven networks: what they do, simplified from the studies in the sources
networks<-read.csv(sep="|",text="code|name|role
visual|Visual|Seeing: from the first visual areas to shapes, faces and motion
somatomotor|Somatomotor|Moving and feeling the body, and hearing
dorsal|Dorsal attention|Turning attention to places and things, and moving the eyes
ventral|Salience / ventral attention|Noticing what matters: sudden sounds, pain, the body's feelings
limbic|Limbic|Value and emotion: under the frontal lobe and at the tip of the temporal lobe
control|Control|Keeping a goal in mind, planning, and switching between tasks
default|Default|Busy at rest: remembering, imagining, thinking about oneself and others")
stopifnot(tolower(networks$name)==tolower(names7))
# the names of the regions of the atlas, for the pieces of the networks
regions<-read.csv(sep="|",text="code|name
bankssts|Superior temporal sulcus
caudalanteriorcingulate|Caudal anterior cingulate
caudalmiddlefrontal|Caudal middle frontal gyrus
cuneus|Cuneus
entorhinal|Entorhinal cortex
fusiform|Fusiform gyrus
inferiorparietal|Inferior parietal lobule
inferiortemporal|Inferior temporal gyrus
isthmuscingulate|Isthmus of the cingulate
lateraloccipital|Lateral occipital cortex
lateralorbitofrontal|Lateral orbitofrontal cortex
lingual|Lingual gyrus
medialorbitofrontal|Medial orbitofrontal cortex
middletemporal|Middle temporal gyrus
parahippocampal|Parahippocampal gyrus
paracentral|Paracentral lobule
parsopercularis|Pars opercularis
parsorbitalis|Pars orbitalis
parstriangularis|Pars triangularis
pericalcarine|Pericalcarine cortex
postcentral|Postcentral gyrus
posteriorcingulate|Posterior cingulate
precentral|Precentral gyrus
precuneus|Precuneus
rostralanteriorcingulate|Rostral anterior cingulate
rostralmiddlefrontal|Rostral middle frontal gyrus
superiorfrontal|Superior frontal gyrus
superiorparietal|Superior parietal lobule
superiortemporal|Superior temporal gyrus
supramarginal|Supramarginal gyrus
frontalpole|Frontal pole
temporalpole|Temporal pole
transversetemporal|Transverse temporal gyrus
insula|Insula
medialwall|Medial wall")
lobes<-c(frontal="frontal lobe",parietal="parietal lobe",temporal="temporal lobe",
occipital="occipital lobe",cingulate="cingulate gyrus",insula="insula")
# the cortex of the networks: every point with a network. A network's area in cm² on each side, and
# its share of the cortex
cortex<-points[points$network>0,]
side_area<-tapply(cortex$area,list(cortex$network,cortex$hemisphere),sum)/100
networks$left<-side_area[,"left"]
networks$right<-side_area[,"right"]
networks$area<-networks$left+networks$right
networks$share<-100*networks$area/sum(networks$area)
# the share of each network's area in each lobe (the few points that the atlas leaves on its medial
# wall have no lobe)
lobe_area<-tapply(cortex$area,list(cortex$network,cortex$lobe),sum)
lobe_area[is.na(lobe_area)]<-0
lobe_share<-100*prop.table(lobe_area[,names(lobes)],1)# the pieces of a network on one hemisphere: points joined by a side of a triangle, both in that
# network. Every point starts as a piece of its own, numbered by its row; at each round it takes the
# smallest number among its own and its neighbors', and then the number held by the point whose
# number it took, which halves the rounds needed; it stops when nothing changes
pieces_of<-function(network,faces) {
sides<-rbind(faces[,1:2],faces[,2:3],faces[,c(1,3)])
sides<-sides[network[sides[,1]]==network[sides[,2]]&network[sides[,1]]>0,,drop=FALSE]
sides<-rbind(sides,sides[,2:1])
piece<-seq_along(network)
repeat {
smallest<-tapply(piece[sides[,2]],sides[,1],min)
rows<-as.integer(names(smallest))
new<-piece
new[rows]<-pmin(piece[rows],smallest)
new<-new[new]
if(all(new==piece))
break
piece<-new
}
result<-ifelse(network>0,piece,NA)
return(result)
}
points$piece<-NA
for(h in names(hemispheres)) {
rows<-which(points$hemisphere==hemispheres[[h]])
piece<-pieces_of(points$network[rows],faces[[h]])
points$piece[rows]<-ifelse(is.na(piece),NA,paste(h,piece))
}
cortex<-points[points$network>0,]
# each piece: its hemisphere, its network, its area in cm², and the region that holds most of it. A
# piece counts from 1 cm²; the smaller ones are specks along the borders between networks
piece_area<-tapply(cortex$area,cortex$piece,sum)/100
pieces<-data.frame(piece=names(piece_area),area=as.vector(piece_area))
pieces$hemisphere<-cortex$hemisphere[match(pieces$piece,cortex$piece)]
pieces$network<-cortex$network[match(pieces$piece,cortex$piece)]
region_area<-tapply(cortex$area,list(cortex$piece,cortex$region),sum)
region_area[is.na(region_area)]<-0
main_region<-colnames(region_area)[apply(region_area[pieces$piece,,drop=FALSE],1,which.max)]
pieces$region<-regions$name[match(main_region,regions$code)]
pieces<-pieces[pieces$area>=1,]
pieces<-pieces[order(pieces$network,pieces$hemisphere,-pieces$area),]
piece_count<-table(factor(pieces$network,1:7),factor(pieces$hemisphere,c("left","right")))
# a point at a border: a side of one of its triangles joins it to a point of another network
points$border<-FALSE
for(h in names(hemispheres)) {
rows<-which(points$hemisphere==hemispheres[[h]])
network<-points$network[rows]
sides<-rbind(faces[[h]][,1:2],faces[[h]][,2:3],faces[[h]][,c(1,3)])
across<-network[sides[,1]]!=network[sides[,2]]&network[sides[,1]]>0&network[sides[,2]]>0
points$border[rows[unique(as.vector(sides[across,]))]]<-TRUE
}
cortex<-points[points$network>0,]
# a value of each network, averaged over its points and weighted by the area around each point
network_mean<-function(value) {
result<-as.vector(rowsum(value*cortex$area,cortex$network)/rowsum(cortex$area,cortex$network))
return(result)
}
networks$silhouette<-network_mean(cortex$silhouette)
networks$unsure<-100*network_mean(cortex$silhouette<0.2)
networks$snr<-network_mean(cortex$snr)# the clustering that made the networks gives each of them an average profile: how its points
# correlate with the 1,175 points spread over the cortex. Two networks are alike when their profiles
# are, measured by the correlation between the two profiles
profiles<-maps[[1]]$mtc
stopifnot(nrow(profiles)==7)
alike<-cor(t(profiles))
dimnames(alike)<-list(networks$code,networks$code)# the cortex in pieces for the 3D charts, one for each pair of networks (of the 7 and of the 17) on
# each hemisphere, so that a button can color it either way and the pointer can name both: the rows
# of its points in `points`, and its triangles numbered from 0 within the piece. A triangle belongs
# to the networks of its first corner. The pieces of the medial wall come first, then the networks
# in Yeo's order
cut_cortex<-function(key) {
result<-list()
for(h in names(hemispheres)) {
rows<-which(points$hemisphere==hemispheres[[h]])
corner<-key[rows][faces[[h]][,1]]
codes<-do.call(rbind,lapply(strsplit(unique(corner)," "),as.integer))
for(pair in unique(corner)[order(codes[,1],codes[,ncol(codes)])]) {
triangles<-faces[[h]][corner==pair,,drop=FALSE]
used<-sort(unique(as.vector(triangles)))
codes_here<-as.integer(strsplit(pair," ")[[1]])
result[[length(result)+1]]<-list(hemisphere=hemispheres[[h]],network=codes_here[1],
network17=codes_here[length(codes_here)],rows=rows[used],
faces=matrix(match(triangles,used)-1,ncol=3))
}
}
return(result)
}
shapes<-cut_cortex(paste(points$network,points$network17))
shapes7<-cut_cortex(paste(points$network))dark_gray<-"#6b6b6b" # also the color of the notes and the labels
wall_gray<-"#cdcdcd" # the medial wall, which has no network
# Yeo's colors of the seven networks, from the file, but with the violet of the salience network
# lighter (#BB62FF for #C43AFA) and the gray of the medial wall darker, so that color-blind readers
# can tell every pair apart
network_colours<-setNames(rgb(maps[[1]]$colors[-1,],maxColorValue=255),networks$code)
network_colours[["ventral"]]<-"#BB62FF"
# Yeo's colors of the 17 networks, from the file; with so many, some look alike to color-blind
# readers, and the pointer names each
colours17<-rgb(maps[[2]]$colors[-1,],maxColorValue=255)
# the color scales of the silhouette (pale where the map is unsure) and of the signal-to-noise
# ratio (pale where the signal is weak), and the one of the correlations, blue below 0 and red above
silhouette_scale<-list(list(0,"#fde725"),list(0.25,"#5ec962"),list(0.5,"#21918c"),
list(0.75,"#3b528b"),list(1,"#440154"))
snr_scale<-list(list(0,"#deebf7"),list(0.25,"#9ecae1"),list(0.5,"#4292c6"),list(0.75,"#2171b5"),
list(1,"#08306b"))
correlation_scale<-list(list(0,"#2166ac"),list(0.25,"#92c5de"),list(0.5,"#f7f7f7"),
list(0.75,"#f4a582"),list(1,"#b2182b"))
# the source of a chart, as a note under it, and the common layout; note_shift moves the note down
# by a number of pixels, which stays the same however tall the plot is
chart<-function(p,title,source,annotations=list(),margin=list(t=70,b=90),note_y=-0.16,
note_shift=0,...) {
note<-list(text=paste("Source:",source),xref="paper",yref="paper",x=0,y=note_y,xanchor="left",
yanchor="top",yshift=note_shift,align="left",showarrow=FALSE,
font=list(size=11,color=dark_gray))
result<-layout(p,
title=list(text=title,x=0.02,xanchor="left",y=0.97,yanchor="top"),
margin=margin,
annotations=c(annotations,list(note)),
...) %>%
config(displaylogo=FALSE)
return(result)
}
legend_top<-list(orientation="h",x=0,y=1.02,yanchor="bottom")
yeo<-"Yeo et al. (2011), from the repository of Yeo's lab (CBIG), on FreeSurfer's fsaverage5."
# 3D charts. A mesh of triangles, numbered from 0, in tenths of a mm as whole numbers: plotly for R
# writes any other number with 17 digits, -38.700000000000003 for -38.7. The axes are hidden
tenths<-function(x) {
result<-round(10*x)
return(result)
}
add_mesh<-function(p,vertices,faces,name,...) {
result<-add_trace(p,type="mesh3d",x=tenths(vertices[,1]),y=tenths(vertices[,2]),
z=tenths(vertices[,3]),i=faces[,1],j=faces[,2],k=faces[,3],name=name,...)
return(result)
}
# the last step of a 3D chart: build it, drop its second copy of every number ("attrs"), and give
# each trace its color and its text for the pointer, which plotly for R would leave out (the
# color of a mesh, in whose place it puts a color scale) or repeat for every point (the text); NA
# leaves a trace as it is
finish_3d<-function(p,colours,meta) {
result<-plotly_build(p)
result$x$attrs<-NULL
for(k in seq_along(result$x$data)) {
if(!is.na(colours[k])) {
result$x$data[[k]]$color<-colours[[k]]
result$x$data[[k]]$colorscale<-NULL
}
if(!is.na(meta[k])) {
result$x$data[[k]]$meta<-meta[[k]]
result$x$data[[k]]$hovertemplate<-"%{meta}<extra></extra>"
}
}
return(result)
}
# the light, from above, and the scene: no axes, the brain in its true shape, turned by dragging
lighting<-list(ambient=0.45,diffuse=0.75,specular=0.15,roughness=0.6,fresnel=0.1)
above<-list(x=0,y=0,z=1e5)
scene<-function(eye=list(x=-1.35,y=0.25,z=0.3),domain=list(x=c(0,1),y=c(0,1))) {
axis<-list(visible=FALSE)
result<-list(xaxis=axis,yaxis=axis,zaxis=axis,aspectmode="data",dragmode="turntable",
camera=list(eye=eye),domain=domain)
return(result)
}
# buttons under a 3D chart that turn the brain to one of six views
views<-list(Left=c(-1.5,0,0.1),Right=c(1.5,0,0.1),Front=c(0,1.5,0.1),Back=c(0,-1.5,0.1),
Top=c(0,0,1.6),Below=c(0,0,-1.6))
view_buttons<-list()
for(v in names(views)) {
up<-if(v%in%c("Top","Below")) list(x=0,y=1,z=0) else list(x=0,y=0,z=1)
eye<-list(x=views[[v]][1],y=views[[v]][2],z=views[[v]][3])
camera<-list(eye=eye,up=up,center=list(x=0,y=0,z=0))
view_buttons[[v]]<-list(label=v,method="relayout",args=list(list(scene.camera=camera)))
}
view_menu<-list(type="buttons",direction="right",x=0,y=0,xanchor="left",yanchor="top",
showactive=FALSE,buttons=unname(view_buttons))
# the text for the pointer: a name in bold, and lines under it
pointer_text<-function(name,...) {
result<-paste0("<b>",name,"</b><br>",paste(...,sep="<br>"))
return(result)
}
# "one piece" or "five pieces"
piece_words<-function(n) {
result<-if(n==1) "one piece" else paste(count_words(n),"pieces")
return(result)
}
# where a network lies: its share in each lobe that holds at least 5% of it, largest first
lobe_words<-function(code) {
share<-sort(lobe_share[match(code,networks$code),],decreasing=TRUE)
share<-share[share>=5]
result<-and_list(paste0(percent(share)," in the ",lobes[names(share)]))
return(result)
}Two networks for the senses and movement, five for everything else. Each network is named after what its parts do together in the studies that first found them:
# the color of each piece in the map of 7 and in the map of 17, its text for the pointer, and its
# points folded and inflated, for the buttons
p<-plot_ly()
trace7<-c()
trace17<-c()
meta<-c()
inflated<-list(x=list(),y=list(),z=list())
folded<-list(x=list(),y=list(),z=list())
shown<-c()
for(shape in shapes) {
folded$x[[length(folded$x)+1]]<-tenths(points$x[shape$rows])
folded$y[[length(folded$y)+1]]<-tenths(points$y[shape$rows])
folded$z[[length(folded$z)+1]]<-tenths(points$z[shape$rows])
inflated$x[[length(inflated$x)+1]]<-tenths(points$inflated_x[shape$rows])
inflated$y[[length(inflated$y)+1]]<-tenths(points$inflated_y[shape$rows])
inflated$z[[length(inflated$z)+1]]<-tenths(points$inflated_z[shape$rows])
if(shape$network==0) {
p<-add_mesh(p,xyz[shape$rows,],shape$faces,"Medial wall",flatshading=FALSE,lighting=lighting,
lightposition=above,showlegend=FALSE)
trace7<-c(trace7,wall_gray)
trace17<-c(trace17,wall_gray)
wall_text<-"No network: where the hemisphere is cut away from the parts under it"
meta<-c(meta,pointer_text(paste0("Medial wall, ",shape$hemisphere),wall_text))
} else {
network<-networks[shape$network,]
p<-add_mesh(p,xyz[shape$rows,],shape$faces,network$name,legendgroup=network$code,
showlegend=!network$code%in%shown,flatshading=FALSE,lighting=lighting,
lightposition=above)
shown<-c(shown,network$code)
trace7<-c(trace7,network_colours[[network$code]])
trace17<-c(trace17,colours17[shape$network17])
count<-piece_count[shape$network,shape$hemisphere]
meta<-c(meta,pointer_text(paste0(network$name," network, ",shape$hemisphere),
paste("Of the 17:",names17[shape$network17]),network$role,
paste0(number(network[[shape$hemisphere]])," cm² on this side, in ",
piece_words(count)," of at least 1 cm²")))
}
}
colour_menu<-list(type="buttons",direction="right",x=0,y=1,xanchor="left",yanchor="bottom",
buttons=list(list(label="7 networks",method="update",
args=list(list(color=as.list(trace7)),
list(showlegend=TRUE))),
list(label="17 networks",method="update",
args=list(list(color=as.list(trace17)),
list(showlegend=FALSE)))))
surface_menu<-list(type="buttons",direction="right",x=1,y=1,xanchor="right",yanchor="bottom",
buttons=list(list(label="Folded",method="restyle",args=list(folded)),
list(label="Inflated",method="restyle",args=list(inflated))))
p %>%
chart("The seven networks of the cortex",
paste(yeo,"Drag to turn, scroll to zoom."),
margin=list(t=100,b=80,l=0,r=0),note_y=0,note_shift=-40,
scene=scene(domain=list(x=c(0,0.8),y=c(0,1))),
legend=list(x=1,xanchor="right",y=0.9,itemsizing="constant"),
updatemenus=list(colour_menu,surface_menu,view_menu)) %>%
finish_3d(trace7,meta)The buttons above the brain color it by the seven networks or by the seventeen of question 6, and show it folded or inflated, blown up like a balloon until its folds open out, so that the parts of the networks hidden in the folds come into view. A click on a network in the legend hides it, and a double click shows it alone. The pointer over the cortex names the network, what it does and how large it is on that side.
total<-sum(networks$area)
wall<-sum(points$area[points$network==0])/100
largest<-networks[which.max(networks$area),]
smallest<-networks[which.min(networks$area),]
senses<-c("visual","somatomotor")
association<-sum(networks$share[!networks$code%in%senses])
networks$ratio<-networks$left/networks$right
more_left<-networks[which.max(networks$ratio),]
more_right<-networks[which.min(networks$ratio),]The default network is the largest, with 22% of the cortex. The seven networks cover 1,304 cm² of cortex in the two hemispheres; the medial wall, 120 cm², has none. The two networks of the senses and movement take 36% of it, and the five that serve no one sense 64%: in the human brain these association networks take up much more of the cortex than in a monkey’s, and they grew most as the brain grew larger in evolution (Buckner and Krienen 2013). The smallest network is the dorsal attention one, 9%. The two hemispheres differ most in the default network, which is 37% larger on the left, and in the control network, 36% larger on the right.
sizes<-networks[order(networks$share),]
p<-plot_ly(sizes,y=~name,x=~round(share,1),type="bar",orientation="h",
marker=list(color=unname(network_colours[sizes$code]),
line=list(color=dark_gray,width=0.5)),
customdata=~paste0(number(left)," cm² on the left, ",number(right)," on the right"),
hovertemplate="%{y}: %{x:.1f}% of the cortex<br>%{customdata}<extra></extra>")
chart(p,"The share of the cortex in each network, both hemispheres, %",
paste(yeo,"<br>The area is measured halfway through the cortex."),
margin=list(t=60,b=80,l=10),note_y=-0.2,xaxis=list(title="",ticksuffix="%"),
yaxis=list(title="",categoryorder="array",categoryarray=sizes$name,automargin=TRUE))Each bar is the area of a network over the area of all seven; the pointer gives its area on each side.
one_piece<-networks$code[piece_count[,"left"]==1&piece_count[,"right"]==1]
counts<-piece_count[,"left"]+piece_count[,"right"]
most<-networks[which.max(counts),]
most_count<-piece_count[which.max(counts),]
default_left<-pieces[pieces$network==match("default",networks$code)&pieces$hemisphere=="left",]The networks of the senses are one piece in each hemisphere; the others are scattered. The visual and the somatomotor networks are one piece of at least 1 cm² in each hemisphere. The most scattered is the control network, in eight pieces on the left and seven on the right. The largest pieces of the default network on the left lie mostly in the superior frontal gyrus, middle temporal gyrus, precuneus and inferior parietal lobule: far apart, at the front, on the side and on the inner surface of the brain, and yet they rise and fall together. Bundles of white matter join them, such as the cingulum along the inner surface (Greicius et al. 2009; see question 6 of Inside the Human Brain).
order_count<-networks$name[order(counts)]
p<-plot_ly()
for(side in c("left","right")) {
listed<-sapply(seq_len(nrow(networks)),function(k) {
x<-pieces[pieces$network==k&pieces$hemisphere==side,]
paste0(x$region," (",number(x$area)," cm²)",collapse="<br>")
})
p<-add_bars(p,y=networks$name,x=as.vector(piece_count[,side]),orientation="h",
name=paste(upper_first(side),"hemisphere"),customdata=listed,
marker=list(color=if(side=="left") "#4a4a4a" else "#a8a8a8"),
hovertemplate=paste0("%{y}, ",side,": %{x} pieces, mostly in<br>%{customdata}",
"<extra></extra>"))
}
chart(p,"The pieces of each network, at least 1 cm² each",
paste(yeo,"<br>A piece is named after the region of the Desikan-Killiany atlas",
"with most of it."),
barmode="group",legend=legend_top,margin=list(t=90,b=80,l=10),note_y=-0.2,
xaxis=list(title="",dtick=1),
yaxis=list(title="",categoryorder="array",categoryarray=order_count,automargin=TRUE))The pointer over a bar lists the pieces of that network on that side, each named after the region of the atlas that holds most of it. The legend of the first chart shows a network alone with a double click, and its pieces with it.
The default network is the opposite of the networks that face the world. The most alike are the control and the default networks, whose profiles correlate at 0.38; the most unlike are the somatomotor and the control networks, at −0.50. The default network is unlike all four networks of the senses and of attention, from −0.44 to −0.33: when the visual, somatomotor and attention networks talk with one part of the cortex, the default network tends not to. Its activity falls when attention turns to the world outside, and rises when it turns inwards (Shulman et al. 1997; Fox et al. 2005).
shown_alike<-alike
diag(shown_alike)<-NA
labels<-networks$name
p<-plot_ly(x=labels,y=labels,z=round(shown_alike,2),type="heatmap",colorscale=correlation_scale,
zmin=-0.6,zmax=0.6,xgap=2,ygap=2,
text=ifelse(is.na(shown_alike),"",two(shown_alike)),texttemplate="%{text}",
colorbar=list(title=list(text="Correlation"),len=0.6,thickness=12),
hovertemplate="%{y} and %{x}: %{text}<extra></extra>")
chart(p,"How alike the networks' profiles are",
paste(yeo,"<br>The correlation between the average profiles of two networks."),
margin=list(t=60,b=110,l=10),note_y=-0.3,
xaxis=list(title="",tickangle=-30),yaxis=list(title="",autorange="reversed",automargin=TRUE))The profile of a network is how its points, on average, correlate with 1,175 points spread over the cortex. Two networks with alike profiles talk with the same parts of the cortex; two with opposite profiles talk with different parts. The diagonal, each network with itself, is left blank.
overall<-weighted.mean(cortex$silhouette,cortex$area)
at_border<-weighted.mean(cortex$silhouette[cortex$border],cortex$area[cortex$border])
inside<-weighted.mean(cortex$silhouette[!cortex$border],cortex$area[!cortex$border])
border_share<-100*sum(cortex$area[cortex$border])/sum(cortex$area)
below_zero<-100*sum(cortex$area[cortex$silhouette<0])/sum(cortex$area)
surest<-networks[which.max(networks$silhouette),]
least_sure<-networks[which.min(networks$silhouette),]
weakest<-networks[which.min(networks$snr),]
others<-networks$snr[networks$code!=weakest$code]Surest inside a network, least sure at its borders. The silhouette of the points averages 0.40: inside a network 0.47, but 0.13 at its borders, where 23% of the cortex lies. Only 2.0% of the cortex has a silhouette below 0, a better fit with another network than with its own. The surest network is the visual one (0.56 on average), the least sure the control network (0.21), 49% of whose area has a silhouette below 0.2. The limbic network lies where the scanner’s signal is weakest: its points have a signal-to-noise ratio of 31 on average, against 66 to 78 for the other networks. The underside of the frontal lobe and the tip of the temporal lobe lie next to the air of the sinuses and of the ear canals, which bends the magnetic field of the scanner and weakens the signal there (Ojemann et al. 1997): the limbic network may partly be the cortex that the scans could not see well, as Yeo’s team warned.
silhouette_range<-c(10*floor(quantile(100*cortex$silhouette,0.01)/10),
10*ceiling(quantile(100*cortex$silhouette,0.99)/10))
silhouette_ticks<-seq(20*ceiling(silhouette_range[1]/20),20*floor(silhouette_range[2]/20),by=20)
snr_range<-c(10*floor(quantile(cortex$snr,0.01)/10),10*ceiling(quantile(cortex$snr,0.99)/10))
p<-plot_ly()
colours<-c()
meta<-c()
coloured<-c()
silhouette_values<-list()
snr_values<-list()
for(k in seq_along(shapes7)) {
shape<-shapes7[[k]]
vertices<-as.matrix(points[shape$rows,c("inflated_x","inflated_y","inflated_z")])
if(shape$network==0) {
p<-add_mesh(p,vertices,shape$faces,"Medial wall",flatshading=FALSE,lighting=lighting,
lightposition=above,showlegend=FALSE)
colours<-c(colours,wall_gray)
meta<-c(meta,pointer_text(paste0("Medial wall, ",shape$hemisphere),"No network"))
} else {
network<-networks[shape$network,]
silhouette<-round(100*points$silhouette[shape$rows])
p<-add_mesh(p,vertices,shape$faces,network$name,intensity=silhouette,
colorscale=silhouette_scale,cmin=silhouette_range[1],cmax=silhouette_range[2],
showscale=length(coloured)==0,flatshading=FALSE,
colorbar=list(title=list(text="Silhouette"),len=0.5,thickness=12,
tickmode="array",tickvals=silhouette_ticks,
ticktext=two(silhouette_ticks/100)),
lighting=lighting,lightposition=above,showlegend=FALSE)
colours<-c(colours,NA)
meta<-c(meta,pointer_text(paste0(network$name," network, ",shape$hemisphere),
paste0("Silhouette ",two(network$silhouette)," on average, ",
percent(network$unsure)," of its area below 0.2"),
paste0("Signal-to-noise ratio ",number(network$snr)," on average")))
coloured<-c(coloured,k)
silhouette_values[[length(silhouette_values)+1]]<-silhouette
snr_values[[length(snr_values)+1]]<-round(points$snr[shape$rows])
}
}
silhouette_button<-list(label="Silhouette",method="restyle",
args=list(list(intensity=silhouette_values,
colorscale=list(silhouette_scale),
cmin=silhouette_range[1],cmax=silhouette_range[2],
colorbar.title.text="Silhouette",
colorbar.tickmode="array",
colorbar.tickvals=list(silhouette_ticks),
colorbar.ticktext=list(two(silhouette_ticks/100))),
coloured-1))
snr_button<-list(label="Signal",method="restyle",
args=list(list(intensity=snr_values,colorscale=list(snr_scale),cmin=snr_range[1],
cmax=snr_range[2],colorbar.title.text="Signal to<br>noise",
colorbar.tickmode="auto"),
coloured-1))
measure_menu<-list(type="buttons",direction="right",x=0,y=1,xanchor="left",yanchor="bottom",
buttons=list(silhouette_button,snr_button))
p %>%
chart("How sure the map is at each point of the cortex, blown up",
paste(yeo,"Grey: the medial wall."),
margin=list(t=100,b=80,l=0,r=0),note_y=0,note_shift=-40,scene=scene(),
updatemenus=list(measure_menu,view_menu)) %>%
finish_3d(colours,meta)The cortex is inflated, as with the button of the first chart, so that the whole of it shows. The yellow lines are the borders between networks, where a point fits two networks almost equally well. The button Signal colors the cortex by the strength of the scanner’s signal instead. Seen from below (the button Below), it is pale under the frontal lobe and at the tip of the temporal lobe, where the limbic network lies.
flows<-tapply(cortex$area,list(cortex$network,cortex$network17),sum)/100
flows[is.na(flows)]<-0
# the network of the 7 that holds most of each of the 17, and the share of it that lies there
parent<-apply(flows,2,which.max)
inside_parent<-100*apply(flows,2,max)/colSums(flows)
nested<-sum(inside_parent>=90)
# the cortex whose network of the 17 belongs mostly to another network of the 7 than its own
moved<-100*sum(cortex$area[parent[cortex$network17]!=cortex$network])/sum(cortex$area)
children<-function(code) {
result<-names17[parent==match(code,networks$code)]
return(result)
}
split_most<-networks[which.max(tabulate(parent,7)),]Mostly by splitting. Nine of the 17 networks lie for 90% or more inside one of the seven. The visual network splits into Visual Central (Visual A) and Visual Peripheral (Visual B); the default network into the most, four: Temporal Parietal, Default C, Default A and Default B. The two maps were made separately, though, not one by cutting up the other, so they do not fit exactly: 14% of the cortex belongs to a network of the 17 that lies mostly in another network of the seven than its own.
links<-which(flows>=1,arr.ind=TRUE)
link_colour<-function(colour,alpha) {
rgb_values<-col2rgb(colour)
result<-sprintf("rgba(%d,%d,%d,%.2f)",rgb_values[1],rgb_values[2],rgb_values[3],alpha)
return(result)
}
p<-plot_ly(type="sankey",orientation="h",arrangement="snap",
node=list(label=c(networks$name,names17),
color=c(unname(network_colours),colours17),pad=12,thickness=16,
line=list(color=dark_gray,width=0.5),
hovertemplate="%{label}: %{value:.0f} cm²<extra></extra>"),
link=list(source=links[,1]-1,target=6+links[,2],value=round(flows[links],1),
color=unname(sapply(network_colours[links[,1]],link_colour,alpha=0.45)),
hovertemplate=paste0("%{source.label} to %{target.label}: %{value:.0f} cm²",
"<extra></extra>")))
chart(p,"From seven networks to seventeen, cm² of cortex",
paste(yeo,"Bands under 1 cm² are left out."),
margin=list(t=60,b=60,l=10,r=10),note_y=-0.04)Each band is as wide as the area of cortex that a network of the seven shares with one of the seventeen. The button 17 networks of the first chart shows the seventeen on the brain.
The cortex works as a handful of networks, most of them spread over the whole brain.
What this does not show. The networks are an average of 1,000 young adults. In each person the networks lie a little differently, and studied one person at a time they turn out finer, interleaved like the fingers of two hands (Braga and Buckner 2017). Their parts rise and fall together, which does not prove that a tract joins them directly. Seven and seventeen are choices: they were the numbers of networks that came out most stable in Yeo’s analyses, and the networks were found again in the second half of the 1,000 people, but the cortex can be divided more coarsely or more finely. The names of the networks come from what their parts do in tasks studied elsewhere, and what each does is simplified here. Finally, the map is drawn on the 10,242 points of fsaverage5, the average brain with which Yeo’s team made it, and its colors are Yeo’s, but for one.
For the anatomy of the same brain, its regions, the structures under the cortex and the tracts of white matter, see Inside the Human Brain.
The networks, their silhouettes and the signal-to-noise ratios come from the repository of the Computational Brain Imaging Group of Thomas Yeo, © 2016 CBIG, under the MIT license below. The page draws them on the surfaces of FreeSurfer’s average brain, fsaverage5, from the R packages ggseg.formats and ggseg.meshes, © 2026 their authors, under the MIT license. The surfaces drawn on this page are modified from FreeSurfer’s: they are turned into one frame and cut into pieces by network; they are not FreeSurfer’s original files. The colors of the networks are Yeo’s, but for the violet of the salience network, which is lighter here.
Copyright (c) 2016 Computational Brain Imaging Group (CBIG)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
All or portions of this licensed product (such portions are the “Software”) have been obtained under license from The General Hospital Corporation “MGH” and are subject to the following terms and conditions:
PART B. DOWNLOADING AGREEMENT - License from MGH with Right to Sublicense
("Software License").
1. As used in this Software License, "you" means the individual
downloading and/or using, reproducing, modifying, displaying and/or
distributing the Software and the institution or entity which
employs or is otherwise affiliated with such individual in
connection therewith. The General Hospital Corporation ("MGH")
hereby grants you, with right to sublicense, with
respect to MGH's rights in the software, and data, if any,
which is the subject of this Software License (collectively, the
"Software"), a royalty-free, non-exclusive license to use,
reproduce, make derivative works of, display and distribute the
Software, provided that:
(a) you accept and adhere to all of the terms and conditions of this
Software License;
(b) in connection with any copy of or sublicense of all or any portion
of the Software, all of the terms and conditions in this Software
License shall appear in and shall apply to such copy and such
sublicense, including without limitation all source and executable
forms and on any user documentation, prefaced with the following
words: "All or portions of this licensed product (such portions are
the "Software") have been obtained under license from The General Hospital
Corporation "MGH" and are subject to the following terms and
conditions:"
(c) you preserve and maintain all applicable attributions, copyright
notices and licenses included in or applicable to the Software;
(d) modified versions of the Software must be clearly identified and
marked as such, and must not be misrepresented as being the original
Software; and
(e) you consider making, but are under no obligation to make, the
source code of any of your modifications to the Software freely
available to others on an open source basis.
2. The license granted in this Software License includes without
limitation the right to (i) incorporate the Software into
proprietary programs (subject to any restrictions applicable to
such programs), (ii) add your own copyright statement to your
modifications of the Software, and (iii) provide additional or
different license terms and conditions in your sublicenses of
modifications of the Software; provided that in each case your use,
reproduction or distribution of such modifications otherwise
complies with the conditions stated in this Software License.
3. This Software License does not grant any rights with respect to
third party software, except those rights that MGH has been
authorized by a third party to grant to you, and accordingly you
are solely responsible for (i) obtaining any permissions from third
parties that you need to use, reproduce, make derivative works of,
display and distribute the Software, and (ii) informing your
sublicensees, including without limitation your end-users, of their
obligations to secure any such required permissions.
4. The Software has been designed for research purposes only and has
not been reviewed or approved by the Food and Drug Administration
or by any other agency. YOU ACKNOWLEDGE AND AGREE THAT CLINICAL
APPLICATIONS ARE NEITHER RECOMMENDED NOR ADVISED. Any
commercialization of the Software is at the sole risk of the party
or parties engaged in such commercialization. You further agree to
use, reproduce, make derivative works of, display and distribute
the Software in compliance with all applicable governmental laws,
regulations and orders, including without limitation those relating
to export and import control.
5. The Software is provided "AS IS" and neither MGH nor any
contributor to the software (each a "Contributor") shall have any
obligation to provide maintenance, support, updates, enhancements
or modifications thereto. MGH AND ALL CONTRIBUTORS SPECIFICALLY
DISCLAIM ALL EXPRESS AND IMPLIED WARRANTIES OF ANY KIND INCLUDING,
BUT NOT LIMITED TO, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR
A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
MGH OR ANY CONTRIBUTOR BE LIABLE TO ANY PARTY FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY ARISING IN ANY WAY
RELATED TO THE SOFTWARE, EVEN IF MGH OR ANY CONTRIBUTOR HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. TO THE MAXIMUM
EXTENT NOT PROHIBITED BY LAW OR REGULATION, YOU FURTHER ASSUME ALL
LIABILITY FOR YOUR USE, REPRODUCTION, MAKING OF DERIVATIVE WORKS,
DISPLAY, LICENSE OR DISTRIBUTION OF THE SOFTWARE AND AGREE TO
INDEMNIFY AND HOLD HARMLESS MGH AND ALL CONTRIBUTORS FROM AND
AGAINST ANY AND ALL CLAIMS, SUITS, ACTIONS, DEMANDS AND JUDGMENTS
ARISING THEREFROM.
6. None of the names, logos or trademarks of MGH or any of
MGH's affiliates or any of the Contributors, or any funding
agency, may be used to endorse or promote products produced in
whole or in part by operation of the Software or derived from or
based on the Software without specific prior written permission
from the applicable party.
7. Any use, reproduction or distribution of the Software which is not
in accordance with this Software License shall automatically revoke
all rights granted to you under this Software License and render
Paragraphs 1 and 2 of this Software License null and void.
8. This Software License does not grant any rights in or to any
intellectual property owned by MGH or any Contributor except
those rights expressly granted hereunder.
The whole agreement is on FreeSurfer’s website.
Rendered with R 4.6.2 · plotly · ggseg.formats · ggseg.meshes · R.matlab
---
title: "The Brain's Seven Networks: Which Parts of the Cortex Work Together"
description: "The seven networks of the human cortex whose parts rise and fall together even at rest, found by Yeo and colleagues in the brain scans of 1,000 young adults and drawn in 3D with plotly on FreeSurfer's average brain: where each network lies and what it does, how much of the cortex it takes, how many pieces it is made of, which networks are alike and which are opposites, how sure the map is, and how the seven split into seventeen."
author: ""
---
```{r setup, include=FALSE}
directory<-""
if(rstudioapi::isAvailable())
directory<-paste0(dirname(rstudioapi::getActiveDocumentContext()$path),"/")
source(paste0(directory,"R/code_options.R"))
```
## What is this?
Lie still in an MRI scanner with nothing to do, and the brain does not go quiet. Its parts keep working, and parts far apart rise and fall together, as if they kept in touch ([Biswal et al. 1995](https://doi.org/10.1002/mrm.1910340409)). Parts that keep time this way form **networks**. Yeo and colleagues measured this in 1,000 healthy young adults and divided the cortex into seven networks, and more finely into seventeen ([Yeo et al. 2011](https://doi.org/10.1152/jn.00338.2011)). This data story draws them on the same average brain as [Inside the Human Brain](ILLUSTRATION_BRAIN.html), with the same tools. Six questions:
1. **Where are the seven networks?**
2. **How much of the cortex does each take?**
3. **Is each network one piece?**
4. **Which networks are alike?**
5. **How sure is the map?**
6. **Seven or seventeen?**
The networks come from the repository of Yeo's lab on GitHub ([CBIG](https://github.com/ThomasYeoLab/CBIG)), under the MIT license. For each of the 10,242 points of each hemisphere of **fsaverage5**, FreeSurfer's average brain, its files give the network of the point among seven and among seventeen, how surely it belongs there, and how strong the scanner's signal was there. The page downloads the six files, 0.6 MB in all, once. The brain and the Desikan–Killiany atlas of its regions and lobes come with the R packages ggseg.meshes and ggseg.formats, as on [Inside the Human Brain](ILLUSTRATION_BRAIN.html).
**The words of this page:**
- **functional MRI** (fMRI) measures, every few seconds, the oxygen in the blood of each small part of the brain, which rises a few seconds after the nerve cells there get busier;
- **at rest**: lying still in the scanner, awake, with nothing to do;
- **functional connectivity**: how closely the signals of two places rise and fall together over time, their correlation. Two places can be connected in this way without a tract of white matter between them, through others;
- a **network**: places whose connectivity with the whole cortex follows the same pattern. Yeo's team took, for each point of the cortex, its correlation with 1,175 points spread over the cortex, and sorted the points into groups with similar patterns: once into seven groups, once into seventeen;
- the **silhouette** of a point: how much better its own network fits it than the next best one, from −1 to 1. Near 0, the point lies between two networks ([Rousseeuw 1987](https://doi.org/10.1016/0377-0427(87)90125-7)).
---
## Packages
```{r packages}
# install.packages(c("plotly","ggseg.formats","ggseg.meshes","R.matlab"))
library(plotly)
```
```{r labels}
# short labels of numbers and lists for the text
number<-function(x) {
result<-format(round(x),big.mark=",",trim=TRUE)
return(result)
}
one<-function(x) {
result<-format(round(x,1),nsmall=1,trim=TRUE)
return(result)
}
# a correlation or a silhouette, to two decimals, with a minus sign rather than a hyphen
two<-function(x) {
result<-sub("^-","−",format(round(x,2),nsmall=2,trim=TRUE))
return(result)
}
percent<-function(x) {
result<-paste0(round(x),"%")
return(result)
}
and_list<-function(x) {
result<-if(length(x)<2) paste(x) else paste(paste(x[-length(x)],collapse=", "),"and",
x[length(x)])
return(result)
}
count_words<-function(n) {
words<-c("one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve")
result<-if(n<=12) words[n] else number(n)
return(result)
}
upper_first<-function(x) {
result<-paste0(toupper(substr(x,1,1)),substring(x,2))
return(result)
}
lower_first<-function(x) {
result<-paste0(tolower(substr(x,1,1)),substring(x,2))
return(result)
}
```
## The data
### The cortex
```{r cortex}
# a surface of the cortex of one hemisphere of fsaverage5, 10,242 points joined in 20,480 triangles.
# ggseg.meshes keeps it turned a quarter round, with x from the back to the front: here x runs from
# left to right, y from the back to the front and z from the bottom to the top, in mm, as on Inside
# the Human Brain
read_surface<-function(hemisphere,surface) {
mesh<-ggseg.meshes::get_cortical_mesh(hemisphere,surface)
vertices<-cbind(x=-mesh$vertices$y,y=mesh$vertices$x,z=mesh$vertices$z)
result<-list(vertices=vertices,faces=as.matrix(mesh$faces))
return(result)
}
# the area of each triangle of a surface, in mm²
triangle_area<-function(vertices,faces) {
a<-vertices[faces[,2],]-vertices[faces[,1],]
b<-vertices[faces[,3],]-vertices[faces[,1],]
result<-sqrt((a[,2]*b[,3]-a[,3]*b[,2])^2+(a[,3]*b[,1]-a[,1]*b[,3])^2+
(a[,1]*b[,2]-a[,2]*b[,1])^2)/2
return(result)
}
# the Desikan-Killiany atlas: the points of each region (numbered from 0), and the lobe of each
atlas<-ggseg.formats::dk()
atlas_points<-atlas$data$vertices
atlas_lobes<-unique(as.data.frame(atlas$core)[,c("label","lobe")])
hemispheres<-c(lh="left",rh="right")
faces<-list()
points<-data.frame()
for(h in names(hemispheres)) {
pial<-read_surface(h,"pial")
middle<-read_surface(h,"midthickness")$vertices
# the inflated surface comes from ggseg.formats, already in this frame but with each hemisphere
# around x = 0: they move apart, their inner sides 4 mm from the middle
inflated<-as.matrix(ggseg.formats::get_brain_mesh(h,"inflated")$vertices)
inflated[,1]<-if(h=="lh") inflated[,1]-max(inflated[,1])-4 else inflated[,1]-min(inflated[,1])+4
faces[[h]]<-pial$faces
# the region of each point; the points of no region, and those that the atlas calls corpus
# callosum, are the medial wall, where the hemisphere is cut away from the structures under it
region<-rep("medialwall",nrow(pial$vertices))
for(k in grep(paste0("^",h,"_"),atlas_points$label))
region[atlas_points$vertices[[k]]+1]<-sub("^[lr]h_","",atlas_points$label[k])
region[region=="corpuscallosum"]<-"medialwall"
# the area of the cortex around each point, measured halfway through its thickness: a third of
# each triangle that the point is a corner of
area<-as.vector(rowsum(rep(triangle_area(middle,pial$faces)/3,3),as.vector(pial$faces)))
points<-rbind(points,data.frame(hemisphere=hemispheres[[h]],region=region,pial$vertices,
inflated_x=inflated[,1],inflated_y=inflated[,2],
inflated_z=inflated[,3],area=area))
}
points$lobe<-atlas_lobes$lobe[match(paste0(substr(points$hemisphere,1,1),"h_",points$region),
atlas_lobes$label)]
xyz<-as.matrix(points[,c("x","y","z")])
```
### The networks
```{r networks}
download_file<-function(url,file,tries=3) {
for(k in seq_len(tries)) {
done<-tryCatch(download.file(url,file,mode="wb",quiet=TRUE)==0,error=function(e) FALSE)
if(done)
return(invisible(file))
Sys.sleep(10)
}
stop("Could not download ",url)
}
cache<-tools::R_user_dir("illustration","cache")
dir.create(cache,recursive=TRUE,showWarnings=FALSE)
# the files of the networks, from the repository of Yeo's lab at the commits that last changed them;
# the page keeps its downloads, and the checksums make sure that they are the files the page was
# written for
cbig<-paste0("https://raw.githubusercontent.com/ThomasYeoLab/CBIG/%s/stable_projects/",
"brain_parcellation/Yeo2011_fcMRI_clustering/1000subjects_reference/%s")
maps_commit<-"ef8e1feba9ee1d7cb8940c4ec27ce3d34941ad62" # 14 October 2016
names_commit<-"703454dba7b6e0b1cfb97beb449e1593c5170547" # 23 March 2021
yeo_files<-data.frame(
file=c("1000subjects_clusters007_ref.mat","1000subjects_clusters017_ref.mat",
"lh.1000subjects.snr.nii.gz","rh.1000subjects.snr.nii.gz","7NetworksOrderedNames.csv",
"17NetworksOrderedNames.csv"),
commit=c(rep(maps_commit,4),rep(names_commit,2)),
md5=c("ab6ce12471152c81083a51e31a294bfb","2c79682024442e9262f7e148d1c795e0",
"ce375053ee2d4be430cb74e97c9fa10e","578926c5ad4103bb321b6c559f1ef78e",
"7de3f05a2d2002f1ba56a8d2fc6875b7","775709611220219eb4385f44c2272f00"))
yeo_files$path<-file.path(cache,paste0("yeo2011_",yeo_files$file))
for(k in seq_len(nrow(yeo_files))) {
if(!file.exists(yeo_files$path[k]))
download_file(sprintf(cbig,yeo_files$commit[k],yeo_files$file[k]),yeo_files$path[k])
stopifnot(unname(tools::md5sum(yeo_files$path[k]))==yeo_files$md5[k])
}
# the network of each point among 7 and among 17 (0: none, on the medial wall), and its silhouette
# in the map of 7. R.matlab reads the MATLAB files; each holds both hemispheres
maps<-list(R.matlab::readMat(yeo_files$path[1]),R.matlab::readMat(yeo_files$path[2]))
points$network<-c(maps[[1]]$lh.labels,maps[[1]]$rh.labels)
points$network17<-c(maps[[2]]$lh.labels,maps[[2]]$rh.labels)
points$silhouette<-c(maps[[1]]$lh.s,maps[[1]]$rh.s)
# the signal-to-noise ratio of the scans at each point, averaged over the 1,000 people: a NIfTI file
# of one value per point, 4-byte numbers that start where its header says
read_values<-function(file) {
connection<-gzfile(file,"rb")
bytes<-readBin(connection,"raw",1e7)
close(connection)
dims<-readBin(bytes[41:56],"integer",8,size=2,endian="little")
stopifnot(readBin(bytes[71:72],"integer",size=2,endian="little")==16)
offset<-readBin(bytes[109:112],"numeric",size=4,endian="little")
result<-readBin(bytes[(offset+1):length(bytes)],"numeric",prod(dims[1+seq_len(dims[1])]),size=4,
endian="little")
return(result)
}
points$snr<-c(read_values(yeo_files$path[3]),read_values(yeo_files$path[4]))
# the names of the networks, in the order of their numbers in the files
names7<-trimws(read.csv(yeo_files$path[5])[[2]])
names17<-trimws(read.csv(yeo_files$path[6])[[2]])
# the networks and the mesh should number their points alike: the points that the atlas puts in the
# cortex should have a network, and those of its medial wall none
in_cortex<-points$region!="medialwall"
with_network<-100*mean(points$network[in_cortex]>0)
wall_without<-100*mean(points$network[!in_cortex]==0)
```
The networks fit the mesh: `r one(with_network)`% of the points that the atlas puts in the cortex have a network, and `r percent(wall_without)` of the points of its medial wall have none. The others lie along the edge of the medial wall, which the two maps draw a little differently.
### The networks and the regions
```{r names}
# the seven networks: what they do, simplified from the studies in the sources
networks<-read.csv(sep="|",text="code|name|role
visual|Visual|Seeing: from the first visual areas to shapes, faces and motion
somatomotor|Somatomotor|Moving and feeling the body, and hearing
dorsal|Dorsal attention|Turning attention to places and things, and moving the eyes
ventral|Salience / ventral attention|Noticing what matters: sudden sounds, pain, the body's feelings
limbic|Limbic|Value and emotion: under the frontal lobe and at the tip of the temporal lobe
control|Control|Keeping a goal in mind, planning, and switching between tasks
default|Default|Busy at rest: remembering, imagining, thinking about oneself and others")
stopifnot(tolower(networks$name)==tolower(names7))
# the names of the regions of the atlas, for the pieces of the networks
regions<-read.csv(sep="|",text="code|name
bankssts|Superior temporal sulcus
caudalanteriorcingulate|Caudal anterior cingulate
caudalmiddlefrontal|Caudal middle frontal gyrus
cuneus|Cuneus
entorhinal|Entorhinal cortex
fusiform|Fusiform gyrus
inferiorparietal|Inferior parietal lobule
inferiortemporal|Inferior temporal gyrus
isthmuscingulate|Isthmus of the cingulate
lateraloccipital|Lateral occipital cortex
lateralorbitofrontal|Lateral orbitofrontal cortex
lingual|Lingual gyrus
medialorbitofrontal|Medial orbitofrontal cortex
middletemporal|Middle temporal gyrus
parahippocampal|Parahippocampal gyrus
paracentral|Paracentral lobule
parsopercularis|Pars opercularis
parsorbitalis|Pars orbitalis
parstriangularis|Pars triangularis
pericalcarine|Pericalcarine cortex
postcentral|Postcentral gyrus
posteriorcingulate|Posterior cingulate
precentral|Precentral gyrus
precuneus|Precuneus
rostralanteriorcingulate|Rostral anterior cingulate
rostralmiddlefrontal|Rostral middle frontal gyrus
superiorfrontal|Superior frontal gyrus
superiorparietal|Superior parietal lobule
superiortemporal|Superior temporal gyrus
supramarginal|Supramarginal gyrus
frontalpole|Frontal pole
temporalpole|Temporal pole
transversetemporal|Transverse temporal gyrus
insula|Insula
medialwall|Medial wall")
lobes<-c(frontal="frontal lobe",parietal="parietal lobe",temporal="temporal lobe",
occipital="occipital lobe",cingulate="cingulate gyrus",insula="insula")
# the cortex of the networks: every point with a network. A network's area in cm² on each side, and
# its share of the cortex
cortex<-points[points$network>0,]
side_area<-tapply(cortex$area,list(cortex$network,cortex$hemisphere),sum)/100
networks$left<-side_area[,"left"]
networks$right<-side_area[,"right"]
networks$area<-networks$left+networks$right
networks$share<-100*networks$area/sum(networks$area)
# the share of each network's area in each lobe (the few points that the atlas leaves on its medial
# wall have no lobe)
lobe_area<-tapply(cortex$area,list(cortex$network,cortex$lobe),sum)
lobe_area[is.na(lobe_area)]<-0
lobe_share<-100*prop.table(lobe_area[,names(lobes)],1)
```
### The pieces of each network
```{r pieces}
# the pieces of a network on one hemisphere: points joined by a side of a triangle, both in that
# network. Every point starts as a piece of its own, numbered by its row; at each round it takes the
# smallest number among its own and its neighbors', and then the number held by the point whose
# number it took, which halves the rounds needed; it stops when nothing changes
pieces_of<-function(network,faces) {
sides<-rbind(faces[,1:2],faces[,2:3],faces[,c(1,3)])
sides<-sides[network[sides[,1]]==network[sides[,2]]&network[sides[,1]]>0,,drop=FALSE]
sides<-rbind(sides,sides[,2:1])
piece<-seq_along(network)
repeat {
smallest<-tapply(piece[sides[,2]],sides[,1],min)
rows<-as.integer(names(smallest))
new<-piece
new[rows]<-pmin(piece[rows],smallest)
new<-new[new]
if(all(new==piece))
break
piece<-new
}
result<-ifelse(network>0,piece,NA)
return(result)
}
points$piece<-NA
for(h in names(hemispheres)) {
rows<-which(points$hemisphere==hemispheres[[h]])
piece<-pieces_of(points$network[rows],faces[[h]])
points$piece[rows]<-ifelse(is.na(piece),NA,paste(h,piece))
}
cortex<-points[points$network>0,]
# each piece: its hemisphere, its network, its area in cm², and the region that holds most of it. A
# piece counts from 1 cm²; the smaller ones are specks along the borders between networks
piece_area<-tapply(cortex$area,cortex$piece,sum)/100
pieces<-data.frame(piece=names(piece_area),area=as.vector(piece_area))
pieces$hemisphere<-cortex$hemisphere[match(pieces$piece,cortex$piece)]
pieces$network<-cortex$network[match(pieces$piece,cortex$piece)]
region_area<-tapply(cortex$area,list(cortex$piece,cortex$region),sum)
region_area[is.na(region_area)]<-0
main_region<-colnames(region_area)[apply(region_area[pieces$piece,,drop=FALSE],1,which.max)]
pieces$region<-regions$name[match(main_region,regions$code)]
pieces<-pieces[pieces$area>=1,]
pieces<-pieces[order(pieces$network,pieces$hemisphere,-pieces$area),]
piece_count<-table(factor(pieces$network,1:7),factor(pieces$hemisphere,c("left","right")))
# a point at a border: a side of one of its triangles joins it to a point of another network
points$border<-FALSE
for(h in names(hemispheres)) {
rows<-which(points$hemisphere==hemispheres[[h]])
network<-points$network[rows]
sides<-rbind(faces[[h]][,1:2],faces[[h]][,2:3],faces[[h]][,c(1,3)])
across<-network[sides[,1]]!=network[sides[,2]]&network[sides[,1]]>0&network[sides[,2]]>0
points$border[rows[unique(as.vector(sides[across,]))]]<-TRUE
}
cortex<-points[points$network>0,]
# a value of each network, averaged over its points and weighted by the area around each point
network_mean<-function(value) {
result<-as.vector(rowsum(value*cortex$area,cortex$network)/rowsum(cortex$area,cortex$network))
return(result)
}
networks$silhouette<-network_mean(cortex$silhouette)
networks$unsure<-100*network_mean(cortex$silhouette<0.2)
networks$snr<-network_mean(cortex$snr)
```
### How alike the networks are
```{r alike}
# the clustering that made the networks gives each of them an average profile: how its points
# correlate with the 1,175 points spread over the cortex. Two networks are alike when their profiles
# are, measured by the correlation between the two profiles
profiles<-maps[[1]]$mtc
stopifnot(nrow(profiles)==7)
alike<-cor(t(profiles))
dimnames(alike)<-list(networks$code,networks$code)
```
### What is drawn
```{r shapes}
# the cortex in pieces for the 3D charts, one for each pair of networks (of the 7 and of the 17) on
# each hemisphere, so that a button can color it either way and the pointer can name both: the rows
# of its points in `points`, and its triangles numbered from 0 within the piece. A triangle belongs
# to the networks of its first corner. The pieces of the medial wall come first, then the networks
# in Yeo's order
cut_cortex<-function(key) {
result<-list()
for(h in names(hemispheres)) {
rows<-which(points$hemisphere==hemispheres[[h]])
corner<-key[rows][faces[[h]][,1]]
codes<-do.call(rbind,lapply(strsplit(unique(corner)," "),as.integer))
for(pair in unique(corner)[order(codes[,1],codes[,ncol(codes)])]) {
triangles<-faces[[h]][corner==pair,,drop=FALSE]
used<-sort(unique(as.vector(triangles)))
codes_here<-as.integer(strsplit(pair," ")[[1]])
result[[length(result)+1]]<-list(hemisphere=hemispheres[[h]],network=codes_here[1],
network17=codes_here[length(codes_here)],rows=rows[used],
faces=matrix(match(triangles,used)-1,ncol=3))
}
}
return(result)
}
shapes<-cut_cortex(paste(points$network,points$network17))
shapes7<-cut_cortex(paste(points$network))
```
```{r chart_style}
dark_gray<-"#6b6b6b" # also the color of the notes and the labels
wall_gray<-"#cdcdcd" # the medial wall, which has no network
# Yeo's colors of the seven networks, from the file, but with the violet of the salience network
# lighter (#BB62FF for #C43AFA) and the gray of the medial wall darker, so that color-blind readers
# can tell every pair apart
network_colours<-setNames(rgb(maps[[1]]$colors[-1,],maxColorValue=255),networks$code)
network_colours[["ventral"]]<-"#BB62FF"
# Yeo's colors of the 17 networks, from the file; with so many, some look alike to color-blind
# readers, and the pointer names each
colours17<-rgb(maps[[2]]$colors[-1,],maxColorValue=255)
# the color scales of the silhouette (pale where the map is unsure) and of the signal-to-noise
# ratio (pale where the signal is weak), and the one of the correlations, blue below 0 and red above
silhouette_scale<-list(list(0,"#fde725"),list(0.25,"#5ec962"),list(0.5,"#21918c"),
list(0.75,"#3b528b"),list(1,"#440154"))
snr_scale<-list(list(0,"#deebf7"),list(0.25,"#9ecae1"),list(0.5,"#4292c6"),list(0.75,"#2171b5"),
list(1,"#08306b"))
correlation_scale<-list(list(0,"#2166ac"),list(0.25,"#92c5de"),list(0.5,"#f7f7f7"),
list(0.75,"#f4a582"),list(1,"#b2182b"))
# the source of a chart, as a note under it, and the common layout; note_shift moves the note down
# by a number of pixels, which stays the same however tall the plot is
chart<-function(p,title,source,annotations=list(),margin=list(t=70,b=90),note_y=-0.16,
note_shift=0,...) {
note<-list(text=paste("Source:",source),xref="paper",yref="paper",x=0,y=note_y,xanchor="left",
yanchor="top",yshift=note_shift,align="left",showarrow=FALSE,
font=list(size=11,color=dark_gray))
result<-layout(p,
title=list(text=title,x=0.02,xanchor="left",y=0.97,yanchor="top"),
margin=margin,
annotations=c(annotations,list(note)),
...) %>%
config(displaylogo=FALSE)
return(result)
}
legend_top<-list(orientation="h",x=0,y=1.02,yanchor="bottom")
yeo<-"Yeo et al. (2011), from the repository of Yeo's lab (CBIG), on FreeSurfer's fsaverage5."
# 3D charts. A mesh of triangles, numbered from 0, in tenths of a mm as whole numbers: plotly for R
# writes any other number with 17 digits, -38.700000000000003 for -38.7. The axes are hidden
tenths<-function(x) {
result<-round(10*x)
return(result)
}
add_mesh<-function(p,vertices,faces,name,...) {
result<-add_trace(p,type="mesh3d",x=tenths(vertices[,1]),y=tenths(vertices[,2]),
z=tenths(vertices[,3]),i=faces[,1],j=faces[,2],k=faces[,3],name=name,...)
return(result)
}
# the last step of a 3D chart: build it, drop its second copy of every number ("attrs"), and give
# each trace its color and its text for the pointer, which plotly for R would leave out (the
# color of a mesh, in whose place it puts a color scale) or repeat for every point (the text); NA
# leaves a trace as it is
finish_3d<-function(p,colours,meta) {
result<-plotly_build(p)
result$x$attrs<-NULL
for(k in seq_along(result$x$data)) {
if(!is.na(colours[k])) {
result$x$data[[k]]$color<-colours[[k]]
result$x$data[[k]]$colorscale<-NULL
}
if(!is.na(meta[k])) {
result$x$data[[k]]$meta<-meta[[k]]
result$x$data[[k]]$hovertemplate<-"%{meta}<extra></extra>"
}
}
return(result)
}
# the light, from above, and the scene: no axes, the brain in its true shape, turned by dragging
lighting<-list(ambient=0.45,diffuse=0.75,specular=0.15,roughness=0.6,fresnel=0.1)
above<-list(x=0,y=0,z=1e5)
scene<-function(eye=list(x=-1.35,y=0.25,z=0.3),domain=list(x=c(0,1),y=c(0,1))) {
axis<-list(visible=FALSE)
result<-list(xaxis=axis,yaxis=axis,zaxis=axis,aspectmode="data",dragmode="turntable",
camera=list(eye=eye),domain=domain)
return(result)
}
# buttons under a 3D chart that turn the brain to one of six views
views<-list(Left=c(-1.5,0,0.1),Right=c(1.5,0,0.1),Front=c(0,1.5,0.1),Back=c(0,-1.5,0.1),
Top=c(0,0,1.6),Below=c(0,0,-1.6))
view_buttons<-list()
for(v in names(views)) {
up<-if(v%in%c("Top","Below")) list(x=0,y=1,z=0) else list(x=0,y=0,z=1)
eye<-list(x=views[[v]][1],y=views[[v]][2],z=views[[v]][3])
camera<-list(eye=eye,up=up,center=list(x=0,y=0,z=0))
view_buttons[[v]]<-list(label=v,method="relayout",args=list(list(scene.camera=camera)))
}
view_menu<-list(type="buttons",direction="right",x=0,y=0,xanchor="left",yanchor="top",
showactive=FALSE,buttons=unname(view_buttons))
# the text for the pointer: a name in bold, and lines under it
pointer_text<-function(name,...) {
result<-paste0("<b>",name,"</b><br>",paste(...,sep="<br>"))
return(result)
}
# "one piece" or "five pieces"
piece_words<-function(n) {
result<-if(n==1) "one piece" else paste(count_words(n),"pieces")
return(result)
}
# where a network lies: its share in each lobe that holds at least 5% of it, largest first
lobe_words<-function(code) {
share<-sort(lobe_share[match(code,networks$code),],decreasing=TRUE)
share<-share[share>=5]
result<-and_list(paste0(percent(share)," in the ",lobes[names(share)]))
return(result)
}
```
---
## 1. Where are the seven networks?
**Two networks for the senses and movement, five for everything else.** Each network is named after what its parts do together in the studies that first found them:
- **Visual**: seeing, from the first visual areas at the back of the brain to shapes, faces and motion; `r lobe_words("visual")`.
- **Somatomotor**: moving and feeling the body, in a strip on either side of the central sulcus, and hearing; `r lobe_words("somatomotor")`.
- **Dorsal attention**: turning attention to places and things, and moving the eyes towards them ([Corbetta and Shulman 2002](https://doi.org/10.1038/nrn755)); `r lobe_words("dorsal")`.
- **Salience / ventral attention**: noticing what matters, such as a sudden sound, pain or a feeling from inside the body ([Seeley et al. 2007](https://doi.org/10.1523/JNEUROSCI.5587-06.2007)); `r lobe_words("ventral")`.
- **Limbic**: the value of things and emotion, on the underside of the frontal lobe and at the tip of the temporal lobe; `r lobe_words("limbic")`.
- **Control**: keeping a goal in mind, planning, and switching from one task to another ([Vincent et al. 2008](https://doi.org/10.1152/jn.90355.2008)); `r lobe_words("control")`.
- **Default**: busy at rest and quieter during most tasks: remembering, imagining the future, and thinking about oneself and others ([Raichle et al. 2001](https://doi.org/10.1073/pnas.98.2.676); [Buckner et al. 2008](https://doi.org/10.1196/annals.1440.011)); `r lobe_words("default")`.
```{r where, fig.height = 7}
#| fig-alt: "3D model of the cortex of the average human brain, seen from the left and coloured by its seven networks: the visual network at the back, the somatomotor network in a strip across the top and down the side, the dorsal attention network behind it, the control and default networks in patches at the front, on the side and at the back"
# the color of each piece in the map of 7 and in the map of 17, its text for the pointer, and its
# points folded and inflated, for the buttons
p<-plot_ly()
trace7<-c()
trace17<-c()
meta<-c()
inflated<-list(x=list(),y=list(),z=list())
folded<-list(x=list(),y=list(),z=list())
shown<-c()
for(shape in shapes) {
folded$x[[length(folded$x)+1]]<-tenths(points$x[shape$rows])
folded$y[[length(folded$y)+1]]<-tenths(points$y[shape$rows])
folded$z[[length(folded$z)+1]]<-tenths(points$z[shape$rows])
inflated$x[[length(inflated$x)+1]]<-tenths(points$inflated_x[shape$rows])
inflated$y[[length(inflated$y)+1]]<-tenths(points$inflated_y[shape$rows])
inflated$z[[length(inflated$z)+1]]<-tenths(points$inflated_z[shape$rows])
if(shape$network==0) {
p<-add_mesh(p,xyz[shape$rows,],shape$faces,"Medial wall",flatshading=FALSE,lighting=lighting,
lightposition=above,showlegend=FALSE)
trace7<-c(trace7,wall_gray)
trace17<-c(trace17,wall_gray)
wall_text<-"No network: where the hemisphere is cut away from the parts under it"
meta<-c(meta,pointer_text(paste0("Medial wall, ",shape$hemisphere),wall_text))
} else {
network<-networks[shape$network,]
p<-add_mesh(p,xyz[shape$rows,],shape$faces,network$name,legendgroup=network$code,
showlegend=!network$code%in%shown,flatshading=FALSE,lighting=lighting,
lightposition=above)
shown<-c(shown,network$code)
trace7<-c(trace7,network_colours[[network$code]])
trace17<-c(trace17,colours17[shape$network17])
count<-piece_count[shape$network,shape$hemisphere]
meta<-c(meta,pointer_text(paste0(network$name," network, ",shape$hemisphere),
paste("Of the 17:",names17[shape$network17]),network$role,
paste0(number(network[[shape$hemisphere]])," cm² on this side, in ",
piece_words(count)," of at least 1 cm²")))
}
}
colour_menu<-list(type="buttons",direction="right",x=0,y=1,xanchor="left",yanchor="bottom",
buttons=list(list(label="7 networks",method="update",
args=list(list(color=as.list(trace7)),
list(showlegend=TRUE))),
list(label="17 networks",method="update",
args=list(list(color=as.list(trace17)),
list(showlegend=FALSE)))))
surface_menu<-list(type="buttons",direction="right",x=1,y=1,xanchor="right",yanchor="bottom",
buttons=list(list(label="Folded",method="restyle",args=list(folded)),
list(label="Inflated",method="restyle",args=list(inflated))))
p %>%
chart("The seven networks of the cortex",
paste(yeo,"Drag to turn, scroll to zoom."),
margin=list(t=100,b=80,l=0,r=0),note_y=0,note_shift=-40,
scene=scene(domain=list(x=c(0,0.8),y=c(0,1))),
legend=list(x=1,xanchor="right",y=0.9,itemsizing="constant"),
updatemenus=list(colour_menu,surface_menu,view_menu)) %>%
finish_3d(trace7,meta)
```
The buttons above the brain color it by the seven networks or by the seventeen of question 6, and show it folded or **inflated**, blown up like a balloon until its folds open out, so that the parts of the networks hidden in the folds come into view. A click on a network in the legend hides it, and a double click shows it alone. The pointer over the cortex names the network, what it does and how large it is on that side.
---
## 2. How much of the cortex does each take?
```{r size_numbers}
total<-sum(networks$area)
wall<-sum(points$area[points$network==0])/100
largest<-networks[which.max(networks$area),]
smallest<-networks[which.min(networks$area),]
senses<-c("visual","somatomotor")
association<-sum(networks$share[!networks$code%in%senses])
networks$ratio<-networks$left/networks$right
more_left<-networks[which.max(networks$ratio),]
more_right<-networks[which.min(networks$ratio),]
```
**The `r lower_first(largest$name)` network is the largest, with `r percent(largest$share)` of the cortex.** The seven networks cover `r number(total)` cm² of cortex in the two hemispheres; the medial wall, `r number(wall)` cm², has none. The two networks of the senses and movement take `r percent(100-association)` of it, and the five that serve no one sense `r percent(association)`: in the human brain these **association networks** take up much more of the cortex than in a monkey's, and they grew most as the brain grew larger in evolution ([Buckner and Krienen 2013](https://doi.org/10.1016/j.tics.2013.09.017)). The smallest network is the `r lower_first(smallest$name)` one, `r percent(smallest$share)`. The two hemispheres differ most in the `r lower_first(more_left$name)` network, which is `r percent(100*(more_left$ratio-1))` larger on the left, and in the `r lower_first(more_right$name)` network, `r percent(100*(1/more_right$ratio-1))` larger on the right.
```{r size, fig.height = 4.5}
#| fig-alt: "Bar chart of the share of the cortex in each of the seven networks, sorted: the default network has the largest bar, then the somatomotor and the visual networks, and the dorsal attention network the smallest"
sizes<-networks[order(networks$share),]
p<-plot_ly(sizes,y=~name,x=~round(share,1),type="bar",orientation="h",
marker=list(color=unname(network_colours[sizes$code]),
line=list(color=dark_gray,width=0.5)),
customdata=~paste0(number(left)," cm² on the left, ",number(right)," on the right"),
hovertemplate="%{y}: %{x:.1f}% of the cortex<br>%{customdata}<extra></extra>")
chart(p,"The share of the cortex in each network, both hemispheres, %",
paste(yeo,"<br>The area is measured halfway through the cortex."),
margin=list(t=60,b=80,l=10),note_y=-0.2,xaxis=list(title="",ticksuffix="%"),
yaxis=list(title="",categoryorder="array",categoryarray=sizes$name,automargin=TRUE))
```
Each bar is the area of a network over the area of all seven; the pointer gives its area on each side.
---
## 3. Is each network one piece?
```{r pieces_numbers}
one_piece<-networks$code[piece_count[,"left"]==1&piece_count[,"right"]==1]
counts<-piece_count[,"left"]+piece_count[,"right"]
most<-networks[which.max(counts),]
most_count<-piece_count[which.max(counts),]
default_left<-pieces[pieces$network==match("default",networks$code)&pieces$hemisphere=="left",]
```
**`r if(all(senses%in%one_piece)) "The networks of the senses are one piece in each hemisphere; the others are scattered." else "Some networks are one piece, others are scattered."`** `r if(length(one_piece)>0) paste0(upper_first(and_list(paste("the",lower_first(networks$name[networks$code%in%one_piece])))),if(length(one_piece)==1) " network is" else " networks are"," one piece of at least 1 cm² in each hemisphere.") else ""` The most scattered is the `r lower_first(most$name)` network, in `r count_words(most_count[["left"]])` pieces on the left and `r count_words(most_count[["right"]])` on the right. The largest pieces of the default network on the left lie mostly in the `r and_list(lower_first(head(unique(default_left$region),4)))`: far apart, at the front, on the side and on the inner surface of the brain, and yet they rise and fall together. Bundles of white matter join them, such as the cingulum along the inner surface ([Greicius et al. 2009](https://doi.org/10.1093/cercor/bhn059); see question 6 of [Inside the Human Brain](ILLUSTRATION_BRAIN.html)).
```{r pieces_chart, fig.height = 4.5}
#| fig-alt: "Bar chart of the number of pieces of at least 1 square centimetre of each network, in the left and in the right hemisphere: the visual and somatomotor networks have one piece on each side, the control network the most"
order_count<-networks$name[order(counts)]
p<-plot_ly()
for(side in c("left","right")) {
listed<-sapply(seq_len(nrow(networks)),function(k) {
x<-pieces[pieces$network==k&pieces$hemisphere==side,]
paste0(x$region," (",number(x$area)," cm²)",collapse="<br>")
})
p<-add_bars(p,y=networks$name,x=as.vector(piece_count[,side]),orientation="h",
name=paste(upper_first(side),"hemisphere"),customdata=listed,
marker=list(color=if(side=="left") "#4a4a4a" else "#a8a8a8"),
hovertemplate=paste0("%{y}, ",side,": %{x} pieces, mostly in<br>%{customdata}",
"<extra></extra>"))
}
chart(p,"The pieces of each network, at least 1 cm² each",
paste(yeo,"<br>A piece is named after the region of the Desikan-Killiany atlas",
"with most of it."),
barmode="group",legend=legend_top,margin=list(t=90,b=80,l=10),note_y=-0.2,
xaxis=list(title="",dtick=1),
yaxis=list(title="",categoryorder="array",categoryarray=order_count,automargin=TRUE))
```
The pointer over a bar lists the pieces of that network on that side, each named after the region of the atlas that holds most of it. The legend of the first chart shows a network alone with a double click, and its pieces with it.
---
## 4. Which networks are alike?
```{r alike_numbers}
pairs<-which(upper.tri(alike),arr.ind=TRUE)
values<-alike[pairs]
closest<-pairs[which.max(values),]
farthest<-pairs[which.min(values),]
outward<-c("visual","somatomotor","dorsal","ventral")
default_out<-alike["default",outward]
```
**`r if(all(default_out<0)) "The default network is the opposite of the networks that face the world." else "Some networks are alike, and some are opposites."`** The most alike are the `r lower_first(networks$name[closest[1]])` and the `r lower_first(networks$name[closest[2]])` networks, whose profiles correlate at `r two(max(values))`; the most unlike are the `r lower_first(networks$name[farthest[1]])` and the `r lower_first(networks$name[farthest[2]])` networks, at `r two(min(values))`. `r if(all(default_out<0)) paste0("The default network is unlike all four networks of the senses and of attention, from ",two(min(default_out))," to ",two(max(default_out)),": when the visual, somatomotor and attention networks talk with one part of the cortex, the default network tends not to. Its activity falls when attention turns to the world outside, and rises when it turns inwards ([Shulman et al. 1997](https://doi.org/10.1162/jocn.1997.9.5.648); [Fox et al. 2005](https://doi.org/10.1073/pnas.0504136102)).") else ""`
```{r alike_chart, fig.height = 5.5}
#| fig-alt: "Heatmap of the correlations between the profiles of the seven networks, blue where two networks are unlike and red where they are alike: the default network is blue against the visual, somatomotor and attention networks, and red against the control and limbic networks"
shown_alike<-alike
diag(shown_alike)<-NA
labels<-networks$name
p<-plot_ly(x=labels,y=labels,z=round(shown_alike,2),type="heatmap",colorscale=correlation_scale,
zmin=-0.6,zmax=0.6,xgap=2,ygap=2,
text=ifelse(is.na(shown_alike),"",two(shown_alike)),texttemplate="%{text}",
colorbar=list(title=list(text="Correlation"),len=0.6,thickness=12),
hovertemplate="%{y} and %{x}: %{text}<extra></extra>")
chart(p,"How alike the networks' profiles are",
paste(yeo,"<br>The correlation between the average profiles of two networks."),
margin=list(t=60,b=110,l=10),note_y=-0.3,
xaxis=list(title="",tickangle=-30),yaxis=list(title="",autorange="reversed",automargin=TRUE))
```
The profile of a network is how its points, on average, correlate with 1,175 points spread over the cortex. Two networks with alike profiles talk with the same parts of the cortex; two with opposite profiles talk with different parts. The diagonal, each network with itself, is left blank.
---
## 5. How sure is the map?
```{r sure_numbers}
overall<-weighted.mean(cortex$silhouette,cortex$area)
at_border<-weighted.mean(cortex$silhouette[cortex$border],cortex$area[cortex$border])
inside<-weighted.mean(cortex$silhouette[!cortex$border],cortex$area[!cortex$border])
border_share<-100*sum(cortex$area[cortex$border])/sum(cortex$area)
below_zero<-100*sum(cortex$area[cortex$silhouette<0])/sum(cortex$area)
surest<-networks[which.max(networks$silhouette),]
least_sure<-networks[which.min(networks$silhouette),]
weakest<-networks[which.min(networks$snr),]
others<-networks$snr[networks$code!=weakest$code]
```
**`r if(at_border<inside) "Surest inside a network, least sure at its borders." else "About as sure at the borders as inside the networks."`** The silhouette of the points averages `r two(overall)`: inside a network `r two(inside)`, but `r two(at_border)` at its borders, where `r percent(border_share)` of the cortex lies. Only `r one(below_zero)`% of the cortex has a silhouette below 0, a better fit with another network than with its own. The surest network is the `r lower_first(surest$name)` one (`r two(surest$silhouette)` on average), the least sure the `r lower_first(least_sure$name)` network (`r two(least_sure$silhouette)`), `r percent(least_sure$unsure)` of whose area has a silhouette below 0.2. `r if(weakest$code=="limbic") paste0("The **limbic network** lies where the scanner's signal is weakest: its points have a signal-to-noise ratio of ",number(weakest$snr)," on average, against ",number(min(others))," to ",number(max(others))," for the other networks. The underside of the frontal lobe and the tip of the temporal lobe lie next to the air of the sinuses and of the ear canals, which bends the magnetic field of the scanner and weakens the signal there ([Ojemann et al. 1997](https://doi.org/10.1006/nimg.1997.0289)): the limbic network may partly be the cortex that the scans could not see well, as Yeo's team warned.") else paste0("The signal of the scanner is weakest in the ",lower_first(weakest$name)," network.")`
```{r sure, fig.height = 7}
#| fig-alt: "3D model of the inflated cortex of the average brain, seen from the left, coloured by the silhouette of each point: dark purple where the map is sure, inside the networks, and yellow where it is unsure, in thin lines along the borders between networks"
silhouette_range<-c(10*floor(quantile(100*cortex$silhouette,0.01)/10),
10*ceiling(quantile(100*cortex$silhouette,0.99)/10))
silhouette_ticks<-seq(20*ceiling(silhouette_range[1]/20),20*floor(silhouette_range[2]/20),by=20)
snr_range<-c(10*floor(quantile(cortex$snr,0.01)/10),10*ceiling(quantile(cortex$snr,0.99)/10))
p<-plot_ly()
colours<-c()
meta<-c()
coloured<-c()
silhouette_values<-list()
snr_values<-list()
for(k in seq_along(shapes7)) {
shape<-shapes7[[k]]
vertices<-as.matrix(points[shape$rows,c("inflated_x","inflated_y","inflated_z")])
if(shape$network==0) {
p<-add_mesh(p,vertices,shape$faces,"Medial wall",flatshading=FALSE,lighting=lighting,
lightposition=above,showlegend=FALSE)
colours<-c(colours,wall_gray)
meta<-c(meta,pointer_text(paste0("Medial wall, ",shape$hemisphere),"No network"))
} else {
network<-networks[shape$network,]
silhouette<-round(100*points$silhouette[shape$rows])
p<-add_mesh(p,vertices,shape$faces,network$name,intensity=silhouette,
colorscale=silhouette_scale,cmin=silhouette_range[1],cmax=silhouette_range[2],
showscale=length(coloured)==0,flatshading=FALSE,
colorbar=list(title=list(text="Silhouette"),len=0.5,thickness=12,
tickmode="array",tickvals=silhouette_ticks,
ticktext=two(silhouette_ticks/100)),
lighting=lighting,lightposition=above,showlegend=FALSE)
colours<-c(colours,NA)
meta<-c(meta,pointer_text(paste0(network$name," network, ",shape$hemisphere),
paste0("Silhouette ",two(network$silhouette)," on average, ",
percent(network$unsure)," of its area below 0.2"),
paste0("Signal-to-noise ratio ",number(network$snr)," on average")))
coloured<-c(coloured,k)
silhouette_values[[length(silhouette_values)+1]]<-silhouette
snr_values[[length(snr_values)+1]]<-round(points$snr[shape$rows])
}
}
silhouette_button<-list(label="Silhouette",method="restyle",
args=list(list(intensity=silhouette_values,
colorscale=list(silhouette_scale),
cmin=silhouette_range[1],cmax=silhouette_range[2],
colorbar.title.text="Silhouette",
colorbar.tickmode="array",
colorbar.tickvals=list(silhouette_ticks),
colorbar.ticktext=list(two(silhouette_ticks/100))),
coloured-1))
snr_button<-list(label="Signal",method="restyle",
args=list(list(intensity=snr_values,colorscale=list(snr_scale),cmin=snr_range[1],
cmax=snr_range[2],colorbar.title.text="Signal to<br>noise",
colorbar.tickmode="auto"),
coloured-1))
measure_menu<-list(type="buttons",direction="right",x=0,y=1,xanchor="left",yanchor="bottom",
buttons=list(silhouette_button,snr_button))
p %>%
chart("How sure the map is at each point of the cortex, blown up",
paste(yeo,"Grey: the medial wall."),
margin=list(t=100,b=80,l=0,r=0),note_y=0,note_shift=-40,scene=scene(),
updatemenus=list(measure_menu,view_menu)) %>%
finish_3d(colours,meta)
```
The cortex is inflated, as with the button of the first chart, so that the whole of it shows. The yellow lines are the borders between networks, where a point fits two networks almost equally well. The button **Signal** colors the cortex by the strength of the scanner's signal instead. Seen from below (the button **Below**), it is pale under the frontal lobe and at the tip of the temporal lobe, where the limbic network lies.
---
## 6. Seven or seventeen?
```{r split_numbers}
flows<-tapply(cortex$area,list(cortex$network,cortex$network17),sum)/100
flows[is.na(flows)]<-0
# the network of the 7 that holds most of each of the 17, and the share of it that lies there
parent<-apply(flows,2,which.max)
inside_parent<-100*apply(flows,2,max)/colSums(flows)
nested<-sum(inside_parent>=90)
# the cortex whose network of the 17 belongs mostly to another network of the 7 than its own
moved<-100*sum(cortex$area[parent[cortex$network17]!=cortex$network])/sum(cortex$area)
children<-function(code) {
result<-names17[parent==match(code,networks$code)]
return(result)
}
split_most<-networks[which.max(tabulate(parent,7)),]
```
**Mostly by splitting.** `r upper_first(count_words(nested))` of the 17 networks lie for 90% or more inside one of the seven. The visual network splits into `r and_list(children("visual"))`; the `r lower_first(split_most$name)` network into the most, `r count_words(length(children(split_most$code)))`: `r and_list(children(split_most$code))`. The two maps were made separately, though, not one by cutting up the other, so they do not fit exactly: `r percent(moved)` of the cortex belongs to a network of the 17 that lies mostly in another network of the seven than its own.
```{r split, fig.height = 7}
#| fig-alt: "Sankey diagram from the seven networks on the left to the seventeen on the right, with bands as wide as the area that they share: most of the seven split into two or three of the seventeen"
links<-which(flows>=1,arr.ind=TRUE)
link_colour<-function(colour,alpha) {
rgb_values<-col2rgb(colour)
result<-sprintf("rgba(%d,%d,%d,%.2f)",rgb_values[1],rgb_values[2],rgb_values[3],alpha)
return(result)
}
p<-plot_ly(type="sankey",orientation="h",arrangement="snap",
node=list(label=c(networks$name,names17),
color=c(unname(network_colours),colours17),pad=12,thickness=16,
line=list(color=dark_gray,width=0.5),
hovertemplate="%{label}: %{value:.0f} cm²<extra></extra>"),
link=list(source=links[,1]-1,target=6+links[,2],value=round(flows[links],1),
color=unname(sapply(network_colours[links[,1]],link_colour,alpha=0.45)),
hovertemplate=paste0("%{source.label} to %{target.label}: %{value:.0f} cm²",
"<extra></extra>")))
chart(p,"From seven networks to seventeen, cm² of cortex",
paste(yeo,"Bands under 1 cm² are left out."),
margin=list(t=60,b=60,l=10,r=10),note_y=-0.04)
```
Each band is as wide as the area of cortex that a network of the seven shares with one of the seventeen. The button **17 networks** of the first chart shows the seventeen on the brain.
---
## So, what does it mean?
**The cortex works as a handful of networks, most of them spread over the whole brain.**
1. **Seven networks**: two handle the senses and movement, and the other five, `r percent(association)` of the cortex, handle no one sense.
2. **The largest**: the `r lower_first(largest$name)` network, `r percent(largest$share)` of the cortex`r if(largest$code=="default") ", busy when we rest, remember and imagine" else ""`.
3. **Scattered**: the networks of the senses are one piece in each hemisphere, while the `r lower_first(most$name)` network lies in `r count_words(most_count[["left"]])` pieces on the left; far-apart pieces still rise and fall together.
4. **Opposites**: the profile of the default network correlates at `r two(min(default_out))` to `r two(max(default_out))` with those of the networks that face the world.
5. **Fuzzy borders**: the map is surest inside a network (silhouette `r two(inside)`) and least sure at its borders (`r two(at_border)`); the limbic network lies where the scans saw least well.
**What this does not show.** The networks are an average of 1,000 young adults. In each person the networks lie a little differently, and studied one person at a time they turn out finer, interleaved like the fingers of two hands ([Braga and Buckner 2017](https://doi.org/10.1016/j.neuron.2017.06.038)). Their parts rise and fall together, which does not prove that a tract joins them directly. Seven and seventeen are choices: they were the numbers of networks that came out most stable in Yeo's analyses, and the networks were found again in the second half of the 1,000 people, but the cortex can be divided more coarsely or more finely. The names of the networks come from what their parts do in tasks studied elsewhere, and what each does is simplified here. Finally, the map is drawn on the 10,242 points of fsaverage5, the average brain with which Yeo's team made it, and its colors are Yeo's, but for one.
For the anatomy of the same brain, its regions, the structures under the cortex and the tracts of white matter, see [Inside the Human Brain](ILLUSTRATION_BRAIN.html).
---
## Sources
- Biswal, B., Yetkin, F.Z., Haughton, V.M. and Hyde, J.S. (1995), [Functional connectivity in the motor cortex of resting human brain using echo-planar MRI](https://doi.org/10.1002/mrm.1910340409), *Magnetic Resonance in Medicine* 34, 537–541.
- Braga, R.M. and Buckner, R.L. (2017), [Parallel interdigitated distributed networks within the individual estimated by intrinsic functional connectivity](https://doi.org/10.1016/j.neuron.2017.06.038), *Neuron* 95, 457–471.
- Buckner, R.L., Andrews-Hanna, J.R. and Schacter, D.L. (2008), [The brain's default network: anatomy, function, and relevance to disease](https://doi.org/10.1196/annals.1440.011), *Annals of the New York Academy of Sciences* 1124, 1–38.
- Buckner, R.L. and Krienen, F.M. (2013), [The evolution of distributed association networks in the human brain](https://doi.org/10.1016/j.tics.2013.09.017), *Trends in Cognitive Sciences* 17, 648–665.
- Computational Brain Imaging Group (CBIG), [Yeo2011_fcMRI_clustering](https://github.com/ThomasYeoLab/CBIG/tree/master/stable_projects/brain_parcellation/Yeo2011_fcMRI_clustering), the repository of Yeo's lab on GitHub: the files of the networks.
- Corbetta, M. and Shulman, G.L. (2002), [Control of goal-directed and stimulus-driven attention in the brain](https://doi.org/10.1038/nrn755), *Nature Reviews Neuroscience* 3, 201–215.
- Desikan, R.S. and others (2006), [An automated labeling system for subdividing the human cerebral cortex on MRI scans into gyral based regions of interest](https://doi.org/10.1016/j.neuroimage.2006.01.021), *NeuroImage* 31, 968–980.
- Fischl, B., Sereno, M.I., Tootell, R.B.H. and Dale, A.M. (1999), [High-resolution intersubject averaging and a coordinate system for the cortical surface](https://doi.org/10.1002/(SICI)1097-0193(1999)8%3A4%3C272%3A%3AAID-HBM10%3E3.0.CO%3B2-4), *Human Brain Mapping* 8, 272–284: fsaverage.
- Fox, M.D. and others (2005), [The human brain is intrinsically organized into dynamic, anticorrelated functional networks](https://doi.org/10.1073/pnas.0504136102), *Proceedings of the National Academy of Sciences* 102, 9673–9678.
- Greicius, M.D., Supekar, K., Menon, V. and Dougherty, R.F. (2009), [Resting-state functional connectivity reflects structural connectivity in the default mode network](https://doi.org/10.1093/cercor/bhn059), *Cerebral Cortex* 19, 72–78.
- Mowinckel, A.M. and Vidal-Piñeiro, D. (2020), [Visualization of brain statistics with R packages ggseg and ggseg3d](https://doi.org/10.1177/2515245920928009), *Advances in Methods and Practices in Psychological Science* 3, 466–483; the surfaces and the atlas come from the packages [ggseg.formats](https://ggsegverse.github.io/ggseg.formats/) and [ggseg.meshes](https://ggsegverse.github.io/ggseg.meshes/).
- Ojemann, J.G. and others (1997), [Anatomic localization and quantitative analysis of gradient refocused echo-planar fMRI susceptibility artifacts](https://doi.org/10.1006/nimg.1997.0289), *NeuroImage* 6, 156–167.
- Raichle, M.E. and others (2001), [A default mode of brain function](https://doi.org/10.1073/pnas.98.2.676), *Proceedings of the National Academy of Sciences* 98, 676–682.
- Rousseeuw, P.J. (1987), [Silhouettes: a graphical aid to the interpretation and validation of cluster analysis](https://doi.org/10.1016/0377-0427(87)90125-7), *Journal of Computational and Applied Mathematics* 20, 53–65.
- Seeley, W.W. and others (2007), [Dissociable intrinsic connectivity networks for salience processing and executive control](https://doi.org/10.1523/JNEUROSCI.5587-06.2007), *Journal of Neuroscience* 27, 2349–2356.
- Shulman, G.L. and others (1997), [Common blood flow changes across visual tasks: II. Decreases in cerebral cortex](https://doi.org/10.1162/jocn.1997.9.5.648), *Journal of Cognitive Neuroscience* 9, 648–663.
- Vincent, J.L., Kahn, I., Snyder, A.Z., Raichle, M.E. and Buckner, R.L. (2008), [Evidence for a frontoparietal control system revealed by intrinsic functional connectivity](https://doi.org/10.1152/jn.90355.2008), *Journal of Neurophysiology* 100, 3328–3342.
- Yeo, B.T.T. and others (2011), [The organization of the human cerebral cortex estimated by intrinsic functional connectivity](https://doi.org/10.1152/jn.00338.2011), *Journal of Neurophysiology* 106, 1125–1165.
---
## Acknowledgments
The networks, their silhouettes and the signal-to-noise ratios come from the repository of the Computational Brain Imaging Group of Thomas Yeo, © 2016 CBIG, under the MIT license below. The page draws them on the surfaces of FreeSurfer's average brain, fsaverage5, from the R packages ggseg.formats and ggseg.meshes, © 2026 their authors, under the MIT license. The surfaces drawn on this page are modified from FreeSurfer's: they are turned into one frame and cut into pieces by network; they are not FreeSurfer's original files. The colors of the networks are Yeo's, but for the violet of the salience network, which is lighter here.
<details>
<summary>The MIT license of the CBIG repository</summary>
```text
Copyright (c) 2016 Computational Brain Imaging Group (CBIG)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```
</details>
All or portions of this licensed product (such portions are the "Software") have been obtained under license from The General Hospital Corporation "MGH" and are subject to the following terms and conditions:
<details>
<summary>The FreeSurfer Software License Agreement, version 1.0 (February 2011), part B</summary>
```text
PART B. DOWNLOADING AGREEMENT - License from MGH with Right to Sublicense
("Software License").
1. As used in this Software License, "you" means the individual
downloading and/or using, reproducing, modifying, displaying and/or
distributing the Software and the institution or entity which
employs or is otherwise affiliated with such individual in
connection therewith. The General Hospital Corporation ("MGH")
hereby grants you, with right to sublicense, with
respect to MGH's rights in the software, and data, if any,
which is the subject of this Software License (collectively, the
"Software"), a royalty-free, non-exclusive license to use,
reproduce, make derivative works of, display and distribute the
Software, provided that:
(a) you accept and adhere to all of the terms and conditions of this
Software License;
(b) in connection with any copy of or sublicense of all or any portion
of the Software, all of the terms and conditions in this Software
License shall appear in and shall apply to such copy and such
sublicense, including without limitation all source and executable
forms and on any user documentation, prefaced with the following
words: "All or portions of this licensed product (such portions are
the "Software") have been obtained under license from The General Hospital
Corporation "MGH" and are subject to the following terms and
conditions:"
(c) you preserve and maintain all applicable attributions, copyright
notices and licenses included in or applicable to the Software;
(d) modified versions of the Software must be clearly identified and
marked as such, and must not be misrepresented as being the original
Software; and
(e) you consider making, but are under no obligation to make, the
source code of any of your modifications to the Software freely
available to others on an open source basis.
2. The license granted in this Software License includes without
limitation the right to (i) incorporate the Software into
proprietary programs (subject to any restrictions applicable to
such programs), (ii) add your own copyright statement to your
modifications of the Software, and (iii) provide additional or
different license terms and conditions in your sublicenses of
modifications of the Software; provided that in each case your use,
reproduction or distribution of such modifications otherwise
complies with the conditions stated in this Software License.
3. This Software License does not grant any rights with respect to
third party software, except those rights that MGH has been
authorized by a third party to grant to you, and accordingly you
are solely responsible for (i) obtaining any permissions from third
parties that you need to use, reproduce, make derivative works of,
display and distribute the Software, and (ii) informing your
sublicensees, including without limitation your end-users, of their
obligations to secure any such required permissions.
4. The Software has been designed for research purposes only and has
not been reviewed or approved by the Food and Drug Administration
or by any other agency. YOU ACKNOWLEDGE AND AGREE THAT CLINICAL
APPLICATIONS ARE NEITHER RECOMMENDED NOR ADVISED. Any
commercialization of the Software is at the sole risk of the party
or parties engaged in such commercialization. You further agree to
use, reproduce, make derivative works of, display and distribute
the Software in compliance with all applicable governmental laws,
regulations and orders, including without limitation those relating
to export and import control.
5. The Software is provided "AS IS" and neither MGH nor any
contributor to the software (each a "Contributor") shall have any
obligation to provide maintenance, support, updates, enhancements
or modifications thereto. MGH AND ALL CONTRIBUTORS SPECIFICALLY
DISCLAIM ALL EXPRESS AND IMPLIED WARRANTIES OF ANY KIND INCLUDING,
BUT NOT LIMITED TO, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR
A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
MGH OR ANY CONTRIBUTOR BE LIABLE TO ANY PARTY FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY ARISING IN ANY WAY
RELATED TO THE SOFTWARE, EVEN IF MGH OR ANY CONTRIBUTOR HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. TO THE MAXIMUM
EXTENT NOT PROHIBITED BY LAW OR REGULATION, YOU FURTHER ASSUME ALL
LIABILITY FOR YOUR USE, REPRODUCTION, MAKING OF DERIVATIVE WORKS,
DISPLAY, LICENSE OR DISTRIBUTION OF THE SOFTWARE AND AGREE TO
INDEMNIFY AND HOLD HARMLESS MGH AND ALL CONTRIBUTORS FROM AND
AGAINST ANY AND ALL CLAIMS, SUITS, ACTIONS, DEMANDS AND JUDGMENTS
ARISING THEREFROM.
6. None of the names, logos or trademarks of MGH or any of
MGH's affiliates or any of the Contributors, or any funding
agency, may be used to endorse or promote products produced in
whole or in part by operation of the Software or derived from or
based on the Software without specific prior written permission
from the applicable party.
7. Any use, reproduction or distribution of the Software which is not
in accordance with this Software License shall automatically revoke
all rights granted to you under this Software License and render
Paragraphs 1 and 2 of this Software License null and void.
8. This Software License does not grant any rights in or to any
intellectual property owned by MGH or any Contributor except
those rights expressly granted hereunder.
```
</details>
The whole agreement is on [FreeSurfer's website](https://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferSoftwareLicense).
---
*Rendered with R `r getRversion()` · plotly · ggseg.formats · ggseg.meshes · R.matlab*