Skip to content

Instantly share code, notes, and snippets.

View AReineberg's full-sized avatar

Andrew Reineberg AReineberg

View GitHub Profile
@AReineberg
AReineberg / anatomical_stats_scraper.sh
Created July 15, 2018 18:50
Grabs output from mris_anatomical_stats
usage() { echo "Usage: $0 [-i <mris_anatomical_stats output>]" 1>&2; exit 1; }
while getopts ":i:" o; do
case "${o}" in
i)
i=${OPTARG}
;;
*)
usage
;;
@AReineberg
AReineberg / fs_roi_to_txt.sh
Created July 6, 2018 15:03
Get thickness from freesurfer label file
#!/bin/bash
usage() { echo "Usage: $0 [-s <subject>]" 1>&2; exit 1; }
while getopts ":s:" o; do
case "${o}" in
s)
s=${OPTARG}
;;
*)
@AReineberg
AReineberg / volumes_from_labels.sh
Last active October 4, 2017 20:54
Takes freesurfer label files and creates MNI 2mm volumes. Set for left hemisphere labels.
#!/bin/bash
# execute one directory above labeldir and volumedir
# usage: ./volumes_from_labels.sh
volumedir='volumedir'
if [ ! -d $volumedir ]; then
mkdir volumedir
fi
for lab in `ls labeldir/l*.label`; do
#!/bin/bash
# Usage: make_design.sh -s subjects.txt -b behavior.txt -f 5 -n workingmemory
# behavior file should be space delimited with subject in first field
usage() { echo "Usage: $0 [-s <subject list>] [-b <behavior file>] [-f <behavior field>] [-n <behavior name>]" 1>&2; exit 1; }
while getopts ":s:b:f:n:" o; do
case "${o}" in
s)
s=${OPTARG}
@AReineberg
AReineberg / asc_to_mgh.m
Created September 11, 2017 03:29
Converts freesurfer asc file to mgh file format.
overlay = MRIread('lh.thickness.fsaverage.mgh');
asc = load('lh_thickness_data.asc');
asc_reshaped = reshape(asc(:,5), overlay.volsize)
overlay.vol = fast_mat2vol(asc_reshaped, overlay.volsize);
MRIwrite(overlay, 'lh_thickness_data.mgh');
#!/bin/bash
#
# Use fslmaths with -thr and -uthr options to extract
# each individual network value and save in net/value.
# Concatenate networks temporally.
#
# 2016-02-20
# Banich Lab
# University of Colorado Boulder
#
#!/bin/bash
#
# Convert Yeo's 7 network liberal parcellation from FreeSurfer space to FSL MNI 2mm space.
# Reference network source:
# https://surfer.nmr.mgh.harvard.edu/fswiki/CorticalParcellation_Yeo2011
#
# 2016-02-20
# Banich Lab
# University of Colorado Boulder
#
@AReineberg
AReineberg / hover_brain_graph_bokeh.py
Created September 23, 2014 07:21
Makes an interactive connectivity matrix with hovering. Code adapted from bokeh package heatmap example.
import numpy as np
import pandas as pd
from bokeh.plotting import *
from bokeh.objects import HoverTool, ColumnDataSource
#
########## Load data ##########
#
data_path = '/path/to/data/'
node_file = data_path + '/nodes.csv' # 1 column of node names - header = "name"
@AReineberg
AReineberg / partial_participation.m
Last active August 29, 2015 14:06
Calculates partial and full participation coefficient for many participants' brain graphs.
% requires brain connectivity toolbox in path
files = dir('*.csv');
n = size(files, 1);
%
modules = csvread('modules.txt');
mods_of_interest = [1, 4, 6, 7, 8, 10, 11, 14];
keep_list = find(ismember(modules, mods_of_interest));
mods_short = modules(keep_list);