Skip to content

Instantly share code, notes, and snippets.

import h5py, sys, io, numpy as np
from mapalign import embed, dist, align
from sklearn.metrics import pairwise_distances
import scipy.io
from scipy.sparse.linalg import eigsh, eigs
num = '313'
hcp = h5py.File('/scr/animals1/hcp_RS_all/hcp.all.%s.rowise.all.mat' % num)
## For PCA:
emat = scipy.io.loadmat('economo/ECONO_DATA_ORIG.mat')
labels = []
for x in emat['ECONOMO_regions'][0]:
labels.append(x[0].encode('ascii'))
def read_economo():
data = []
header = []
thresh = 100 # currently arbitrarily high, but could be used to remove data columns with excessive NaNs...
for x in emat.keys():
import xml.etree.ElementTree as ET
import numpy as np
import pandas as pd
from colormap import rgb2hex
path_style = "stroke:#000000;stroke-width:0;stroke-opacity:0;fill-opacity:1;fill:"
SVG_NS = "http://www.w3.org/2000/svg"
def parse_xml(data):
'''
<div>
<a href="https://plot.ly/~margulies/14" target="_blank" title="" style="display: block; text-align: center;"><img src="https://plot.ly/~margulies/14.png" alt="" style="max-width: 100%;width: 600px;" width="600" onerror="this.onerror=null;this.src='https://plot.ly/404.png';" /></a>
<script data-plotly="margulies:14" src="https://plot.ly/embed.js" async></script>
</div>
# changes are in lines with "if mask is not None:"
# "lenient" allows more liberal inclusion for specific cases where needed
# "label" uses median instead of mean to get values (for labels)
def plot_surf_stat_map(coords, faces, stat_map=None,
elev=0, azim=0,
cmap='jet',
threshold=None, bg_map=None,
mask=None,
bg_on_stat=False,
%matplotlib inline
from PIL import Image
i1 = Image.open('smith_dist_plot.png')
i2 = Image.open('smith_brains.png')
# print np.shape(i1)
# print np.shape(i2)
result = Image.new("RGBA", (np.shape(i1)[1]+50, np.shape(i1)[0]))
@margulies
margulies / neuro.tmTheme
Last active August 29, 2015 14:25
Neuro tmTheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.0">
<dict>
<key>name</key>
<string>neuro</string>
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 7 11:49:45 2015
@author: jgolchert
"""
#Run in terminal before staring script
#export AFNI_1D_ZERO_TEXT=YES
import os # system functions\n",
function[] = distance_connectivity_calc()
topPercent=0.1;
surf = SurfStatReadSurf('surf_lh_fs.mgh.obj');
conn = data(1:length(surf.coord),:);
cortex = load('lh.cortex.1D.txt');
cortex = cortex(:,1)+1;
noncortex = ones([1 length(surf.coord)]);
#!/bin/bash
3dSetupGroupInCorr -LRpairs surf_lh_fs.asc surf_rh_fs.asc -prefix group.all \
test_surface_extract/surfaceData_h004_935_lh.niml.dset test_surface_extract/surfaceData_h004_935_rh.niml.dset \
test_surface_extract/surfaceData_w353_935_lh.niml.dset test_surface_extract/surfaceData_w353_935_rh.niml.dset
# Then run:
# suma -spec surf_asc.spec -niml &
# 3dGroupInCorr -setA group.all.grpincorr.niml -suma