Skip to content

Instantly share code, notes, and snippets.

View satra's full-sized avatar

Satrajit Ghosh satra

View GitHub Profile
@satra
satra / susan_fwhm.ipynb
Last active March 28, 2018 15:06
FSL SUSAN: FWHM to Gaussian kernel parameter
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@satra
satra / fix_bvecs.py
Created January 24, 2013 14:46
fix mri_convert produced gradients
img = nib.load(imgfile)
bvecs = np.genfromtxt(bvecs)
def get_trackvis_mat(aff):
"""based on input from ruopeng @ tracvkis
"""
for i in range(10):
#aff = aff.dot(np.linalg.inv(np.eye(3) + 3*aff.T.dot(aff)).dot(3*np.eye(3) + aff.T.dot(aff)))
aff = 0.5 * (aff + np.linalg.inv(aff.T))
return np.dot(aff, np.array([[1,0,0],[0,-1,0],[0,0,1]]))
@satra
satra / serve_files.py
Created February 26, 2013 22:02
serve files that exist only in a specific directory.
#!/usr/bin/env python
#
# Demo to return a file with a uri delivered by a virtuoso server
import md5
import json
import os
from urlparse import urlparse
import cherrypy
@satra
satra / dicom2streamlines.py
Created May 14, 2013 19:49
dicom2trackvis streamlines via dipy
#!/usr/bin/env python
# Convert dicom 2 nrrd
def dicom2nrrd(dicomdir, out_prefix):
import os
from nipype.interfaces.base import CommandLine
cmd = CommandLine('DWIConvert --inputDicomDirectory %s --outputVolume %s.nrrd' % (dicomdir, out_prefix))
cmd.run()
return os.path.abspath('%s.nrrd' % out_prefix)
@satra
satra / save_imageinfo_to_rdf.py
Created May 25, 2013 01:27
example to save info about a saved file to rdf
import os
from hashlib import md5
import rdflib
from rdflib.namespace import Namespace, NamespaceManager, RDF, FOAF, XSD
from rdflib import URIRef, BNode, Literal
from uuid import uuid1
from socket import getfqdn
db_location = os.path.join(os.getcwd(), 'database.ttl')
@satra
satra / hdf5_test.py
Last active December 17, 2015 20:49
Testing multiprocessing with hdf5.
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
from glob import glob
import os
import numpy as np
@satra
satra / test.ipynb
Created June 12, 2013 16:22
testing slideshow mode with markdown code
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@satra
satra / recon-all-output.txt
Created July 5, 2013 13:47
recon-all T2 pial refinement fails
Step 0: recon-all -subjid H0351.1015 -all -i /data/allen/H0351.1015/T1.nii.gz -openmp 8 -notalairach
Step 1: recon-all -subjid H0351.1015 -T2 /data/allen/H0351.1015/T2.nii.gz -openmp 8
Step 2: recon-all -subjid H0351.1015 -T2pial -openmp 8
WARNING: tcsh v6.17.06 has an exit code bug! Please update tcsh!
Subject Stamp: freesurfer-Linux-centos6_x86_64-stable-pub-v5.3.0
Current Stamp: freesurfer-Linux-centos6_x86_64-stable-pub-v5.3.0
@satra
satra / bedpostx.py
Created July 7, 2013 15:48
BespostX using Nipype
import argparse
import os
from nipype.pipeline.engine import Workflow, Node, MapNode
from nipype.interfaces.utility import IdentityInterface
from nipype.interfaces.fsl.utils import ImageMaths
from nipype.interfaces.fsl.utils import Split
from nipype.interfaces.fsl.dti import XFibres
from nipype.interfaces.fsl.utils import Merge
from nipype.interfaces.fsl.dti import MakeDyadicVectors
@satra
satra / twohemi.py
Created July 9, 2013 20:21
show two hemispheres with pysurfer
from surfer import Brain
lh = Brain('fs404', 'lh', 'pial')
rh = Brain('fs404', 'rh', 'pial', figure=lh._f)
lh.add_annotation('aparc', borders=False, alpha=0)
rh.add_annotation('aparc', borders=False, alpha=0.5)
"""
lh._geo_surf.actor.property.opacity = 0.3
rh._geo_surf.actor.property.opacity = 0.3
lh._geo_surf.contour.contours = [0.5]
lh._geo_surf.actor.mapper.progress = 1.0