Skip to content

Instantly share code, notes, and snippets.

View arokem's full-sized avatar
🎯
Focusing

Ariel Rokem arokem

🎯
Focusing
View GitHub Profile
@arokem
arokem / fmri_tnsr.py
Created April 22, 2011 20:29
This is a program for calculating TSNR images from fMRI nifti files
"""
Compute the TSNR of a bunch of nifti files and generate the equivalent nifti
SNR 3Ds.
Depends on nibabel, matplotlib and scipy
"""
import os
@arokem
arokem / dicom2nifti.py
Created April 22, 2011 20:33
This runs FSL motion correction on a bunch of epis and plots the motion correction params
"""
This script takes the raw dicoms as they come off the scanner,
converts to nifti and runs FSL motion correction.
Also makes a plot of the motion correction parameters.
Depends on matplotlib, FSL, dcm2nii
"""
@arokem
arokem / tensor.py
Created June 14, 2012 18:52
Representation of tensor
import warnings
import numpy as np
import scipy.linalg as la
class Tensor(object):
"""
Represent a diffusion tensor.
"""
@arokem
arokem / simulation.py
Created June 14, 2012 18:54
Simulation
import numpy as np
import tensor as ozt
# Global constants for this module:
AD = 1.5
RD = 0.5
# This converts b values from the data, so that it matches the units of ADC we
@arokem
arokem / spherical_harmonics
Created September 27, 2012 00:00
spherical harmonics
function Ymn = spherical_harmonics(degree, order, theta, phi)
% Compute the spherical harmonics of given degree and order at theta,phi
%
% Parameters
% ----------
% degree: int, the degree of the underlying Legendre polynomial
% order: int, the order of the r
%
% theta: bounded between 0 and pi
@arokem
arokem / sklearn_EN_example.py
Created September 29, 2012 15:52
Demonstrate that ElasticNet doesn't fit all the way, even for rather strict convergence criteria
This file has been truncated, but you can view the full file.
import numpy as np
import sklearn.linear_model as lm
X = np.array([[ -2.18252949e-01, -8.21949578e-02, -4.64055457e-02,
-1.78405908e-01, -1.93863740e-01, 5.30667625e-02,
1.83851107e-01, 1.23426449e-01, 1.97396315e-01,
-2.12615837e-01, 7.06452283e-02, -1.94509405e-01,
-9.77929516e-02, 2.07135018e-01, -3.40368338e-02,
2.02970673e-01, -2.28669466e-01, 4.17398420e-02,
1.80163132e-01, 3.24254938e-02, -2.41198452e-03,
from __future__ import division
from warnings import warn
import numpy as np
from .recspeed import local_maxima, remove_similar_vertices, _filter_peaks
from ..core.onetime import auto_attr
from dipy.core.sphere import unique_edges, unit_icosahedron, HemiSphere
#Classes OdfModel and OdfFit are using API ReconstModel and ReconstFit from .base
default_sphere = HemiSphere.from_sphere(unit_icosahedron.subdivide(3))
@arokem
arokem / t_mrdTensor.ipynb
Created December 8, 2012 14:59
t_mrdTensor
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@arokem
arokem / gist:4242011
Created December 8, 2012 21:19
TensorModel
{
"metadata": {
"name": "TensorModel"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@arokem
arokem / gist:4287207
Created December 14, 2012 17:37
Calculation of the bias of the standard deviation (with the proof of it from http://stats.stackexchange.com/questions/11707/why-is-sample-standard-deviation-a-biased-estimator-of-sigma)
{
"metadata": {
"name": "std_bias"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{