Skip to content

Instantly share code, notes, and snippets.

@mwaskom
mwaskom / evc_flat_patch.ipynb
Created April 18, 2017 15:33
WIP notes on creating flat patches of visual cortex for Jupyter notebook visualization (and manipulation?)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mwaskom
mwaskom / matplotlib_surfaces.ipynb
Created March 30, 2017 19:39
Notes on cortical surface visualization without Mayavi
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mwaskom
mwaskom / continuous_colormap.ipynb
Created March 17, 2017 17:20
Good colormap for plotting unthresholded fMRI activations
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mwaskom
mwaskom / find_clean_subjects.py
Created March 7, 2017 21:14
Define a list of subjects with low motion/number of artifact TRs
import numpy as np
import pandas as pd
import lyman
MOTION_THRESH = 1
ARTIFACT_THRESH = 6
if __name__ == "__main__":
all_subjects = lyman.determine_subjects()
@mwaskom
mwaskom / read_edf.py
Created October 9, 2016 13:30
Read eyelink data file into a useful structure
import os
import subprocess
import tempfile
import shutil
import numpy as np
import pandas as pd
class EyeData(object):
@mwaskom
mwaskom / pedestalelementarray.py
Last active August 18, 2016 18:22
Extend the PsychoPy ElementArrayStim object to allow non-zero pedestal value.
#!/usr/bin/env python2
"""Extend ElementArrayStim to allow nonzero pedestal values of gratings.
This adapts a prior solution for adding a non-zero pedestal value to GratingStim:
https://github.com/nwilming/PedestalGrating/blob/master/pedestal_grating.py
Covered under the PsychoPy license, as it is a simple extension of the prior code:
Copyright (C) 2015 Jonathan Peirce
Distributed under the terms of the GNU General Public License (GPL).
@mwaskom
mwaskom / run_deface.sh
Created June 6, 2016 17:32
Anonymize structural MRI images for sharing data
#! /bin/bash
# Script for removing facial information from subject anatomical
# images before sharing the data.
# This required downloading the mri_deface binary and the face.gca and
# talairach_mixed_with_skull.gca atlas files from here:
# https://surfer.nmr.mgh.harvard.edu/fswiki/mri_deface
for s in $SUBJECTS; do
mkdir -p $s/anat
@mwaskom
mwaskom / vernalis.py
Created May 29, 2016 01:00
Colormap with a similar aesthetic to viridis but with a broader luminance range.
from matplotlib.colors import ListedColormap
from numpy import nan, inf
# Used to reconstruct the colormap in viscm
parameters = {'xp': [3.559581561226338, 17.887066941343306, -44.539833643452027, -35.329307327662548, -2.5807693159666485],
'yp': [-7.9678362573099264, -64.766081871344994, -32.529239766081844, 43.201754385964932, 6.359649122807042],
'min_Jp': 2.08370436331,
'max_Jp': 99.3232413179}
@mwaskom
mwaskom / bostock_rainbow.png
Last active April 28, 2016 22:21
Cubehelix rainbow values from https://bl.ocks.org/mbostock/310c99e53880faec2434 as RGB lut
bostock_rainbow.png
@mwaskom
mwaskom / bkr.py
Created March 26, 2016 03:02
Diverging cool - warm colormap.
import matplotlib as mpl
lut =[[0.97535488, 0.96717973, 0.97826556],
[0.96210335, 0.958145, 0.96901356],
[0.94896295, 0.94912471, 0.96025478],
[0.93577938, 0.94018409, 0.95192643],
[0.92251197, 0.93134405, 0.94395255],
[0.9091769, 0.92260072, 0.93627962],
[0.89579025, 0.91394725, 0.92888411],
[0.88237732, 0.90537279, 0.92174829],