Skip to content
Athanasia Monika Mowinckel edited this page Aug 28, 2018 · 18 revisions

Welcome to the ggbrain wiki!

In this wiki, we will focus on describing how to provide the package with more atlases.

With this wiki, you can create your own atlas to work with ggbrain package or send us atlas you'd like to incorporate in the package. We will add more atlas images to ggbrain in the near future but we appreciate any suggestions or contributions you may have.

Creating new data.frames with atlas information, is a slightly labourious task, as it involved several steps.

1. Create a base raster image (png) that will serve as your template. This will need to as "flat" an image as possible. i.e. have no shading effects or the like. You should also know the actual number of colours the image contains for the next step.

for instance: Notice how the colours are flat, without any shading.

2. Turning raster image to vector (svg) This step requires the use of a program that can detect the contours of the colours in the raster image, and convert each into a vector. We have tried using online converters, Inkscape and several packages in R to do this, but by far Adobe Illustrator is the most effective in doing this. We recommend this video tutorial on how to do this in illustrator, if you have the program available.

As noted, we have tried several other options, Inkscape does a fair job with its trace bitmap function, but requires much more manual labour after conversion. Illustrator requires minimal to none.

If you know of any other solution that may work, please let us know, so we can test it out.

3. Turn vector graphic to GIS Working with vector graphics in R is possible, but we found it to be a little tedious. This is why we opted for converting the vector graphic into shape-files that use geograpical coordinates.

This step requires: i) conversion of vector images to AutoCAD DXF (Drawing Interchange Format, or Drawing Exchange Format). One has plenty of options here. You can export svg images to AutoCAD DXF from Illustrator or even use any online converter.
ii) conversion of *DXF files into shape-files. Here we used QGIS a GIS Free and Open Source Software.

4. Turn GIS to data.frame The GIS data may be loaded into R using OGR reading packages, and then fortified into a data.frame using ggplot2 (alternatively you can use the broom package). This will create a data.frame ready for plotting! Something like:

library(rgdal)
library(ggplot)

#Open shape-file object
geobrain <- readOGR(dsn = ".", layer = "dka")

# fortify (transform to data.frame)
geobrain <- fortify(geobrain, region="GEO_ID")

5. Add information on regarding the polygons. Each polygon (id) in the data.frame represents on of the vectors from the svg. Each of these need information on their hemispheres, side (lateral,medial etc), in addition to the name of either the topographical area or the network they belong to. This step often requires some manual editing depending on the quality of the vectorization.

As a minimum, the data.frame must contain the columns:
lat = x-axis coordinates
long = y-axis coordinates
area = name of network or topographical region
hemi = hemisphere the polygon is in
side = which side the of the brain the polygon is viewed from (lateral, medial, axial or sagittal)
label = the label used in the software the atlas is taken from (Freesurfer for instance has internal labels for its atlases like lh_transverse for left transverse in the DKT atlas.)

As a cherry on the cake, you can send us a label to HEX color relation so we can add an option to plot the atlas with the palette you are used to.

Clone this wiki locally