Skip to content

Instantly share code, notes, and snippets.

View vsoch's full-sized avatar
💭
rawr

Vanessasaurus vsoch

💭
rawr
View GitHub Profile
@vsoch
vsoch / mapASD.R
Created February 6, 2014 20:55
mapASD.R: Use the foursquare API to create a resource map for a search term of interest
# foursquareASD will create a map of ASD locations across the United States
library(RJSONIO)
library(RCurl)
options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))
# First, read in file with latitudes and longitudes of major cities
# Obtained from http://notebook.gaslampmedia.com/download-zip-code-latitude-longitude-city-state-county-csv/
ll = read.csv('zip_codes_states.csv',sep=",",head=TRUE)
@vsoch
vsoch / pseq_startup_script.sh
Created February 7, 2014 21:11
Startup script for pseq-instance on GCE
#!/bin/bash
# Key off existence of the "data" mount point to determine whether
# this is the first boot.
if [[ ! -e /mnt/data ]]; then
# Basic setup - get the JRE installed
apt-get update
apt-get install --fix-broken
mkdir -p /mnt/data
fi
@vsoch
vsoch / imaging_scientist_scores.txt
Created November 17, 2014 00:14
Imaging Scientist Avatar Scoring
domain total_points earned_points
domain expertise, source 4 2
domain expertise,value 4 2
domain expertise, impact 4 1
programming, breadth 5 4
programming, depth 5 4
programming, software 7 5
methods, implementation 5 3
methods,understanding 7 4
communication, verbal 6 4
@vsoch
vsoch / print_dr_report.m
Last active December 21, 2015 14:59
visual_dr creates and prints a web report for a dual regression run with FSL. The figures print exactly the size of the open figure 1, so you might want to open and size it to your liking before running the script. visual_dr is the main script to run, and it uses print_dr_report to create a web report, and imoverlay to overlay maps on the backgr…
function print_dr_report(imgfolder)
% This function takes a folder of images produced by visual_dr
% and prints and html report page
filey = fopen([imgfolder 'index.html' ],'w');
% Print top of html file
fprintf(filey,'%s\n','<html><body><h2>Dual Regression Report</h2>');
% Get all images in folder
@vsoch
vsoch / cytoscapeExport.m
Created September 13, 2013 20:13
Functions for exporting graph data (a list of connected nodes and corresponding attribute values) for functional neuroimaging data. Currently includes cytoscape and gephi. You must provide a list of anatomical labels (the variable AAL_labels).
function cytoscapeExport(links,weights,threshold,exptype)
% This function will take a list of links and weights, and create a file to
% import into Cytoscape for further graph analysis
% exptype is the export type - 'all' means voxelwise above a threshold,
% 'region' means creating graph of average regional values
% links is an n by 2 list of connections, each a voxel id
% weights is a correlation value corresponding to each link set
@vsoch
vsoch / flattenSphere.m
Last active December 23, 2015 11:28
flattenSphere.m takes a 3D image with x y z coordinates defined on the circumference of a circle, and flattens it to a 2D representation (with some obvious distortion). unwrapSphere.m estimates a radius and centroid with least squares, and then writes data to a 3D matrix defined by azimuth, elevation, and radius. Since this sphere is hollow, the…
function flat = flattenSphere(mr)
% First read in sphere files and vox mapping
%vox = spm_read_vols(spm_vol('NDARAK333GZA.lh.vtxvol.nii'));
mr = spm_read_vols(spm_vol(mr));
% First create a random maximum length - we will crop at the end
maxlength = floor(pi*size(mr,1));
% Now go through vox image and save vector of x,y,z coordinates
@vsoch
vsoch / nc_spatial_kurtosis.m
Last active December 24, 2015 12:19
NoiseCloud Features
function feature = nc_kurtosis_spatial(spatialMap)
% FEATURE NAME: Kurtosis
% FEATURE TYPE: spatial.gist
% We take a component image, sum the voxel values quadrupled, and divide by the
% number of voxels, subtract 3. We then normalize the value by linear scaling transform of abs(ln(kurtosis))
% This does the same thing as doing kurtosis(curr_network(:))
ICkurt = sum(power(spatialMap,4)) / length(spatialMap(:));
@vsoch
vsoch / plotly.R
Last active December 26, 2015 00:09
R Functions in the Cloud!
# This function will use plotly to create an online boxplot!
plotlyBox = function(username,key,datastore) {
# Username is your plotly username
# API key is found via plot.ly, login --> Access plotly --> settings
# datalist is a list of data
# The number of plots, N, is determined by length(N)
# Eg, put your data into a list
@vsoch
vsoch / searchNdarLocal.py
Last active December 29, 2015 03:28
searchNdarLocal.py takes an input file (input.txt) with single keywords on each line, and searches a local database of NDAR behavioral data. Output includes: 1) outfile_vars.txt, with questions containing the search term(s) of interests on single lines, followed by an estimate of the min, max, and variable type 2) outfile_data.txt, with subject …
#!/usr/bin/python
"""
searchNdar: reads in a set of strings from file, and search behavioral metrics
to find questions / subscales that might be of interest
python searchNdarLocal.py --o outfile --i /home
/vanessa/Documents/Work/NDAR/behavioral -w input.txt
--o is the outfile name, without extension
@vsoch
vsoch / exportRWeka.R
Last active December 29, 2015 07:08
Export a data matrix and associated demographic variables to arff file for import into Weka. All variables are assumed to be numeric, and columns are features (with column names the feature names), and rows data objects (with appropriate rownames). Missing values, currently set as -9999 and NA, are recoded as "?" Change this section (line 28) to…
exportRWeka = function(data,relation_name,outname) {
# Data is a data matrix, with features in columns, data in rows
# Edit the script to match whatever is the missing value for your data
# Rownames will be exported as well, and should be data labels
# relation_name is the name of the relation in Weka
# outname is the output file
# If you have a nominal outcome variable (eg, you want to color
# your data by a label in Weka) change the variable type as follows:
# @attribute groupVar {1,2}