Skip to content

Instantly share code, notes, and snippets.

View oesteban's full-sized avatar
🦄

Oscar Esteban oesteban

🦄
View GitHub Profile
# -*- coding: utf-8 -*-
# Author: Douglas Creager <[email protected]>
# This file is placed into the public domain.
# Calculates the current version number. If possible, this is the
# output of “git describe”, modified to conform to the versioning
# scheme that setuptools uses. If “git describe” returns an error
# (most likely because we're in an unpacked copy of a release tarball,
# rather than in a git working copy), then we fall back on reading the
# contents of the RELEASE-VERSION file.
@oesteban
oesteban / mayavi&notebook.py
Created September 2, 2013 17:16
A short file to load an vtk and show a surface in iPython notebooks
from mayavi import mlab
from tvtk.api import tvtk
import numpy as np
surfname = os.path.join( model_path, 'fixed.csf.vtk' )
reader =tvtk.PolyDataReader( file_name=surfname )
mesh = reader.get_output()
reader.update()
@oesteban
oesteban / SurfaceTransforms.py
Created September 10, 2013 19:40
Old code for transforming surfaces from freesurfer
# http://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferTrackVisTransforms
tkr1_tfm = fsbt.mri_info( op.join( tpms_dir, 'wm_volume_fraction.nii.gz' ), 'vox2ras-tkr' )
r2v_tfm = fsbt.mri_info( op.join( tpms_dir, 'wm_volume_fraction.nii.gz' ), 'ras2vox' )
tkr2_tfm = fsbt.mri_info( op.join( tpms_dir, 'wm_volume_fraction.nii.gz' ), 'ras2vox-tkr' )
v2r_tfm = fsbt.mri_info( op.join( tpms_dir, 'wm_volume_fraction.nii.gz' ), 'vox2ras' )
tfm = np.dot( tkr2_tfm, v2r_tfm )
M = tfm[0:3,0:3]
O = tfm[0:3,3]
#http://stackoverflow.com/questions/15880367/python-uniform-distribution-of-points-on-4-dimensional-sphere
dim = 3
norm = np.random.normal
normal_deviates = norm(size=(dim, N))
radius = np.sqrt((normal_deviates**2).sum(axis=0))
points = normal_deviates/radius
points = points.reshape(-1,3)
@oesteban
oesteban / myhmc.sch
Last active August 29, 2015 14:06
A FLIRT schedule file for head-motion correction
# 4mm scale
setscale 4
setoption smoothing 6
clear U
clear UA
clear UB
clear US
clear UP
# try the identity transform as a starting point at this resolution
clear UQ
@oesteban
oesteban / myecc.sch
Created September 5, 2014 09:11
A FLIRT schedule for eddy correction
# 4mm scale
setscale 4
setoption smoothing 6
setoption paramsubset 1 0 0 0 0 0 0 1 1 1 1 1 1
clear U
clear UA
clear UB
clear US
clear UP
# try the identity transform as a starting point at this resolution
@oesteban
oesteban / slice_contours.cpp
Last active August 29, 2015 14:10
A sliced 3D volume writer, with contours
// --------------------------------------------------------------------------------------
// File: slice_contours.cxx
// Date: Nov 18, 2014
// Author: [email protected] (Oscar Esteban)
// Version: 1.0 beta
// License: GPLv3 - 29 June 2007
// Short Summary:
// --------------------------------------------------------------------------------------
//
// Copyright (c) 2014, [email protected] (Oscar Esteban)
#!/bin/bash
# A universal helper to enable NeuroDebian repository for a travis
# environment.
#
# Its purpose to remove all repetative actions from various .travis.yml spread
# across projects and gain control in the future to point to an alternative,
# more appropriate for travis deployments, mirror.
# for the protocol
@oesteban
oesteban / remove_output.py
Created June 6, 2016 18:51 — forked from damianavila/remove_output.py
Remove output from IPython notebook from the command line (dev version 1.0)
"""
Usage: python remove_output.py notebook.ipynb [ > without_output.ipynb ]
Modified from remove_output by Minrk
"""
import sys
import io
import os
from IPython.nbformat.current import read, write
@oesteban
oesteban / autossh init.d
Created July 26, 2016 17:10 — forked from atr000/autossh init.d
launches and maintains uniquely named autossh tunnels alive
#! /bin/sh
#
# Author: Andreas Olsson <[email protected]>
# Version: @(#)autossh_tunnel.foo 0.1 27-Aug-2008 [email protected]
#
# For each tunnel; make a uniquely named copy of this template.
## SETTINGS
#