{"id":13498241,"url":"https://github.com/cwatson/brainGraph","last_synced_at":"2025-03-29T00:34:10.572Z","repository":{"id":26254804,"uuid":"29701965","full_name":"cwatson/brainGraph","owner":"cwatson","description":"Graph theory analysis of brain MRI data","archived":false,"fork":false,"pushed_at":"2021-03-26T03:48:48.000Z","size":5929,"stargazers_count":159,"open_issues_count":11,"forks_count":46,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-01-25T05:11:21.239Z","etag":null,"topics":["brain-connectivity","brain-imaging","complex-networks","connectome","connectomics","fmri","graph-theory","mri","network-analysis","neuroimaging","neuroscience","r","statistics","tractography"],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cwatson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-22T21:46:42.000Z","updated_at":"2024-01-05T01:42:26.000Z","dependencies_parsed_at":"2022-07-28T20:10:02.464Z","dependency_job_id":null,"html_url":"https://github.com/cwatson/brainGraph","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwatson%2FbrainGraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwatson%2FbrainGraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwatson%2FbrainGraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwatson%2FbrainGraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cwatson","download_url":"https://codeload.github.com/cwatson/brainGraph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246122259,"owners_count":20726822,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brain-connectivity","brain-imaging","complex-networks","connectome","connectomics","fmri","graph-theory","mri","network-analysis","neuroimaging","neuroscience","r","statistics","tractography"],"created_at":"2024-07-31T21:00:16.585Z","updated_at":"2025-03-29T00:34:10.033Z","avatar_url":"https://github.com/cwatson.png","language":"R","funding_links":[],"categories":["Programming","R"],"sub_categories":["R"],"readme":"# brainGraph\n[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/)\n[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)\n[![Linux Build Status](https://travis-ci.org/cwatson/brainGraph.svg)](https://travis-ci.org/cwatson/brainGraph)\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version-ago/brainGraph)](http://cran.rstudio.com/web/packages/brainGraph/index.html)\n[![Dependencies](https://tinyverse.netlify.com/badge/brainGraph)](https://cran.r-project.org/package=brainGraph)\n[![GPL License](https://img.shields.io/cran/l/brainGraph.svg)](https://opensource.org/licenses/GPL-3.0/)\n[![CRAN Downloads](http://cranlogs.r-pkg.org/badges/grand-total/brainGraph)](http://cran.rstudio.com/web/packages/brainGraph/index.html)\n[![HitCount](http://hits.dwyl.io/cwatson/brainGraph.svg)](http://hits.dwyl.io/cwatson/brainGraph)\n\n`brainGraph` ([RRID: SCR_017260](https://scicrunch.org/resolver/SCR_017260)) is an\n[R package](https://cran.r-project.org/web/packages/brainGraph/index.html) for performing graph theory\nanalyses of brain MRI data. It is most useful in atlas-based analyses (e.g., using an atlas such as\n[AAL](http://www.gin.cnrs.fr/en/tools/aal-aal2/),\nor one from [Freesurfer](https://surfer.nmr.mgh.harvard.edu/)); however, many of\nthe computations (e.g., the *GLM*-based\nfunctions and the network-based statistic) will work with any graph that\nis compatible with [igraph](https://github.com/igraph/rigraph). The package will\nperform analyses for *structural covariance networks (SCN)*, DTI tractography\n(I use *probtrackx2* from [FSL](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki)), and\nresting-state fMRI covariance (I have used the Matlab-based [DPABI](http://rfmri.org/dpabi)\ntoolbox).\n\n\u003c!-- vim-markdown-toc GFM --\u003e\n\n* [Requirements](#requirements)\n    * [Operating Systems](#operating-systems)\n    * [Multi-core processing](#multi-core-processing)\n* [Compatibility](#compatibility)\n    * [Neuroimaging software](#neuroimaging-software)\n    * [Brain atlases](#brain-atlases)\n        * [Other atlases](#other-atlases)\n* [Installation](#installation)\n    * [Multi-core processing](#multi-core-processing-1)\n    * [GUI](#gui)\n    * [Suggested packages](#suggested-packages)\n* [Usage - the User Guide](#usage---the-user-guide)\n* [Major changes in v3.0.0](#major-changes-in-v300)\n* [Graph measures](#graph-measures)\n    * [Group analyses](#group-analyses)\n        * [GLM-based](#glm-based)\n        * [Non-GLM based](#non-glm-based)\n    * [Null graph-related measures](#null-graph-related-measures)\n    * [Other measures](#other-measures)\n* [Visualization](#visualization)\n* [Getting Help](#getting-help)\n* [Future versions](#future-versions)\n\n\u003c!-- vim-markdown-toc --\u003e\n# Requirements\n\n## Operating Systems\nThe package ***should*** work \"out-of-the-box\" on *Linux* systems (at least on Red\nHat-based systems; i.e., CentOS, RHEL, Scientific Linux, etc.) since almost all\ndevelopment (and use, by me) has been on computers running CentOS 6 and (currently)\nCentOS 7. I have also had success running it (and did some development) on\nWindows 7, and have heard from users that it works on some versions of Mac OS\nand on Ubuntu. Please see the User Guide (mentioned below) for more details.\n\n## Multi-core processing\nMany `brainGraph` functions utilize multiple CPU cores. This is primarily done\nvia the [foreach](https://cran.r-project.org/web/packages/foreach/index.html)\npackage. Depending on your OS, you will need to install\n[doMC](https://cran.r-project.org/web/packages/doMC/index.html) (*macOS* and *Linux*)\nor [doSNOW](https://cran.r-project.org/web/packages/doSNOW/index.html)\n(*Windows*).\n\n# Compatibility\n## Neuroimaging software\nI mostly use Freesurfer and FSL, but the following software packages should be suitable.\nNote that this is an incomplete list; any software that can output a connectivity matrix will work.\n* [Freesurfer](https://surfer.nmr.mgh.harvard.edu)\n* [FSL](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki)\n* [DPARSF](http://rfmri.org/DPARSF)\n* [PANDA](https://www.nitrc.org/projects/panda)\n* [TrackVis](http://trackvis.org/)\n\n## Brain atlases\nThere are several brain atlases for which the data are present in `brainGraph`.\nAtlases containing `.scgm` in the name contain both cortical and *SubCortical Gray Matter (SCGM)* regions.\n1. `dk` and `dk.scgm`: [Desikan-Killiany](https://dx.doi.org/10.1016/j.neuroimage.2006.01.021)\n2. `dkt` and `dkt.scgm`: [Desikan-Killiany-Tourville](https://dx.doi.org/10.3389/fnins.2012.00171)\n3. `destrieux` and `destrieux.scgm`: [Destrieux](https://dx.doi.org/10.1016/j.neuroimage.2010.06.010)\n4. `aal90` and `aal116`: [Automated Anatomical Labeling atlas](https://dx.doi.org/10.1006/nimg.2001.0978)\n5. `aal2.94` and `aal2.120`: [AAL-2](https://dx.doi.org/10.1016/j.neuroimage.2015.07.075)\n6. `brainsuite`: [Brainsuite](https://dx.doi.org/10.1016/S1361-8415(02)00054-3)\n7. `craddock200`: [Craddock-200](https://dx.doi.org/10.1002/hbm.21333)\n8. `dosenbach160`: [Dosenbach-160](https://dx.doi.org/10.1126/science.1194144)\n9. `hoa112`: [Harvard-Oxford atlas](https://dx.doi.org/10.1016/j.schres.2005.11.020)\n10. `lpba40`: [LONI Probabilistic Brain Atlas](https://dx.doi.org/10.1016/j.neuroimage.2007.09.031)\n11. `hcp_mmp1.0`: [HCP-1mm](https://doi.org/10.1038/nature18933)\n12. `power264`: [Power-264](https://dx.doi.org/10.1016%2Fj.neuron.2011.09.006)\n13. `gordon333`: [Gordon-333](https://doi.org/10.1093/cercor/bhu239)\n14. `brainnetome`: [Brainnetome](https://doi.org/10.1093/cercor/bhw157)\n\n### Other atlases\nSome functions accept a `custom.atlas` argument, so that you can analyze data that is from an atlas not present in `brainGraph`.\nOther atlases to be added in the future include the following (I would need specific coordinate, region name, and lobe and hemisphere information):\n* [Shen-268](https://doi.org/10.1016/j.neuroimage.2013.05.081)\n* [Von Economo-Koskinas](https://doi.org/10.1016/j.neuroimage.2016.12.069)\n* [Willard-499](https://findlab.stanford.edu/functional_ROIs.html) (see [Richiardi et al., 2015](https://doi.org/10.1126/science.1255905))\n* [Schaefer-400](https://github.com/ThomasYeoLab/CBIG/tree/master/stable_projects/brain_parcellation/Schaefer2018_LocalGlobal)\n    (see [Schaefer et al., 2018](https://doi.org/10.1093/cercor/bhx179))\n\n# Installation\nThere are (primarily) two ways to install this package:\n\n1. Directly from CRAN: (use one of the following commands)\n``` r\ninstall.packages('brainGraph')\ninstall.packages('brainGraph', dependencies=TRUE)\n```\n\n2. From the GitHub repo (for development versions). This requires that the\n[devtools](https://cran.r-project.org/web/packages/devtools/index.html)\npackage be installed:\n``` r\ndevtools::install_github('cwatson/brainGraph')\n```\nThis should install all of the dependencies needed along with the package\nitself. For more details, see the [User Guide (PDF link)](https://cwatson.github.io/files/brainGraph_UserGuide.pdf).\n\n## Multi-core processing\nTo set up your R session for parallel processing, you can use the following code. Note that it is different for *Windows*.\nThis code should be run before any data processing. If you will always use a single OS, you can remove the unnecessary lines.\n``` r\nOS \u003c- .Platform$OS.type\nif (OS == 'windows') {\n  library(snow)\n  library(doSNOW)\n  num.cores \u003c- as.numeric(Sys.getenv('NUMBER_OF_PROCESSORS'))\n  cl \u003c- makeCluster(num.cores, type='SOCK')\n  clusterExport(cl, 'sim.rand.graph.par')   # Or whatever functions you will use\n  registerDoSNOW(cl)\n} else {\n  library(doMC)\n  registerDoMC(detectCores() - 1L)  # Keep 1 core free\n}\n```\n\nFor example, I source the following simple script before I do any parallel processing with `brainGraph`:\n``` r\npacman::p_load(brainGraph, doMC)\nregisterDoMC(detectCores())\n```\n\n## GUI\nOn some systems (e.g., *macOS* and *Windows*) it might be difficult to\ninstall the necessary packages/dependencies for the GUI functions. Since `v2.2.0` (released 2018-05-28),\nthe R packages [RGtk2](https://cran.r-project.org/web/packages/RGtk2/index.html)\nand [cairoDevice](https://cran.r-project.org/web/packages/cairoDevice/index.html)\nhave been changed to *Suggests* (i.e., they are no longer required),\nso it can be installed on a \"headless\" server.\n\nIf you are on *macOS* or *Windows* and would like GUI functionality, please see\n[this GitHub Gist](https://gist.github.com/sebkopf/9405675#macos). The comments\ncontain more recent information.\nYou may also need to install a few additional packages, shown here:\n``` r\ninstall.packages('gWidgets', dependencies=TRUE)\ninstall.packages('gWidgetsRGtk2', dependencies=TRUE)\ninstall.packages('RGtk2Extras', dependencies=TRUE)\n```\n\n## Suggested packages\nThere are a few suggested packages that may be required for certain functions:\n\n* `RGtk2` and `cairoDevice`: as mentioned above, these are required to use the GUI\n* `boot`: required for `brainGraph_boot`\n* `Hmisc`: required for `corr.matrix`\n* `ade4`: required for `loo` and `aop`\n* `expm`: required for `communicability` and `centr_betw_comm`\n\n# Usage - the User Guide\nI have a User Guide that contains *extensive* code examples for analyses common to\nbrain MRI studies. I also include some code for getting your data *into* R *from*\nFreesurfer, FSL, and DPABI, and some suggestions for workflow organization.\n\nThe User Guide is the most complete documentation of this package.\nIf you are a beginner using R, I encourage you to read it thoroughly.\nYou may start with the [Preface](https://cwatson.github.io/files/brainGraph_UserGuide.pdf#chapter*.1)\nor at whichever chapter is suitable for your analyses.\n\n# Major changes in v3.0.0\nThere are several major changes in `v3.0.0`. See the User Guide for more extensive details.\n\n* There are several fewer package dependencies, allowing for a quicker install process\n* There are a few new built-in atlases (see below for the full list)\n* Graph creation is simpler (in terms of code) with the new `brainGraphList` object\n* The GLM-based functions are significantly faster and easily handle large models. The most significant speed improvements are seen in `NBS` and `mtpc`\n* There are more methods to calculate GLM-based statistics (including residuals, coefficient of determination, ANOVA, etc.)\n* There are global options that give the user some more control\n* There are other methods that make manipulating data objects easier/more flexible\n\nTo access the User Guide, a PDF is available at\n[this link.](https://cwatson.github.io/files/brainGraph_UserGuide.pdf)\n\n# Graph measures\nIn addition to the extensive list of measures available in *igraph*, I have\nfunctions for calculating/performing:\n\n## Group analyses\nThere are several analyses based on the *General Linear Model (GLM)*, and others\nthat have different purposes.\n\n### GLM-based\n* Between-group differences in vertex- or graph-level measures (e.g., *degree*,\n    *betweenness centrality*, *global efficiency*, etc.) using the GLM's.\n    See [Chapter 8](https://cwatson.github.io/files/brainGraph_UserGuide.pdf#chapter.8) of the User Guide, which was partly modeled after the\n    GLM page on the [FSL wiki](https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/GLM)\n* The *multi-threshold permutation correction (MTPC)* method for statistical\n    inference (see [Drakesmith et al., 2015](https://dx.doi.org/10.1016%2Fj.neuroimage.2015.05.011)\n    and [Chapter 9](https://cwatson.github.io/files/brainGraph_UserGuide.pdf#chapter.9) of the User Guide)\n* The *network-based statistic (NBS)* (see [Zalesky et al., 2010](https://doi.org/10.1016/j.neuroimage.2010.06.041)\n    and [Chapter 10](https://cwatson.github.io/files/brainGraph_UserGuide.pdf#chapter.10) of the User Guide)\n* Graph- and vertex-level *mediation* analysis (see [Chapter 11](https://cwatson.github.io/files/brainGraph_UserGuide.pdf#chapter.11)\n    of the User Guide, and the [mediation](https://cran.r-project.org/web/packages/mediation/index.html) package in R)\n\n### Non-GLM based\n* Bootstrapping of graph-level metrics (e.g., *modularity*)\n* Permutation analysis of between-group differences in vertex- or graph-level measures\n* \"Individual contributions\" (*leave-one-out [LOO]* and *add-one-patient [AOP]*;\n    see [Saggar et al., 2015](https://dx.doi.org/10.1016%2Fj.neuroimage.2015.07.006))\n\n## Null graph-related measures\n* Null/random graph generation (both the \"standard\" method, and also a method controlling for clustering;\n    see [Bansal et al., 2009](https://doi.org/10.1186/1471-2105-10-405))\n* Small-worldness: the \"original\" of [Watts \u0026 Strogatz, 1998](https://dx.doi.org/10.1515/9781400841356.301)\n    and [Humphries et al., 2008](https://doi.org/10.1371/journal.pone.0002051),\n    and \"omega\" introduced in [Telesford et al., 2011](https://doi.org/10.1089/brain.2011.0038)\n* Rich-club coefficients and normalization (see [Zhou \u0026 Mondragon, 2004](https://doi.org/10.1109/LCOMM.2004.823426); and\n    [Colizza et al., 2006](https://doi.org/10.1038/nphys209))\n\n## Other measures\n* Efficiency (global, nodal, and local; see [Latora \u0026 Marchiori, 2001](https://dx.doi.org/10.1103/PhysRevLett.87.198701))\n* The *rich-core* (see [Ma \u0026 Mondragon, 2015](https://dx.doi.org/10.1371/journal.pone.0119678))\n* Leverage centrality (see [Joyce et al., 2010](https://dx.doi.org/10.1371/journal.pone.0012200))\n* Asymmetry index\n* Robustness (\"targeted attack\" and \"random failure\") and vulnerability\n* Euclidean distances of edges\n* Participation coefficient and within-module degree z-score (see [Guimera \u0026 Amaral, 2005a](https://dx.doi.org/10.1038/nature03288) and [2005b](https://dx.doi.org/10.1088/1742-5468/2005/02/P02001))\n* Gateway coefficient (see [Vargas \u0026 Wahl, 2014](https://dx.doi.org/10.1140/epjb/e2014-40800-7))\n* *Communicability* and *communicability betweenness* (see [Estrada \u0026 Hatano, 2008](https://dx.doi.org/10.1103/PhysRevE.77.036111);\n    [Estrada et al., 2009](https://dx.doi.org/10.1016/j.physa.2008.11.011);\n    [Crofts \u0026 Higham, 2009](https://dx.doi.org/10.1098/rsif.2008.0484))\n* Vertex *s-core* membership (see [Eidsaa \u0026 Almaas, 2013](https://dx.doi.org/10.1103/PhysRevE.88.062819))\n\n# Visualization\nThere is a plotting GUI for fast and easy data exploration that will *not* work\nwithout data from a standard atlas (ideally to be extended some time in the future).\nYou may use a custom atlas if you follow the same format as the other atlases in\nthe package (see [Chapter 4](https://cwatson.github.io/files/brainGraph_UserGuide.pdf#chapter.4)\nof the *User Guide* for instructions).\n\n![brainGraph GUI](http://i.imgur.com/KKZZqI2.png)\n\n# Getting Help\nFor bug reports, feature requests, help with usage/code/etc., please join the\n*Google Group*\n[brainGraph-help](https://groups.google.com/forum/?hl=en#!forum/brainGraph-help).\nYou may also consult the User Guide, and you can\n[open an issue](https://github.com/cwatson/brainGraph/issues) here on GitHub.\n\n# Future versions\nAn *incomplete* list of features/functionality I plan on adding to future versions:\n- Longitudinal modeling (with *linear mixed effects (LME)* models)\n- Thresholding and graph creation using the *minimum spanning tree* as a base\n- Thresholding and graph creation for resting-state fMRI using a technique such as the *graphical lasso*\n- Write functions to print group analysis results in [xtable](https://cran.r-project.org/web/packages/xtable/index.html) format for `LaTeX` documents\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwatson%2FbrainGraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcwatson%2FbrainGraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwatson%2FbrainGraph/lists"}