Skip to content

Instantly share code, notes, and snippets.

View satra's full-sized avatar

Satrajit Ghosh satra

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / instacorr.py
Created January 15, 2013 13:38
Uses pysurfer to perform interactive display of correlation matrices stored in hdf or matlab or numpy arrays.
# -*- coding: utf-8 -*-
# <nbformat>3</nbformat>
# <codecell>
import argparse
import os
from surfer import Brain
import scipy.io as sio
@satra
satra / ecclog
Created December 28, 2012 18:50
ecclog transformations
rocessing regular_brain_ec_tmp0000
Final result:
1.000000 0.000151 0.000000 -0.017864
0.000000 1.000000 -0.000121 0.007878
0.000000 0.000000 1.000000 -0.000000
0.000000 0.000000 0.000000 1.000000
processing regular_brain_ec_tmp0001
@satra
satra / Siemens private tags
Created December 6, 2012 15:15
Dicom private field tags
['FlowEncodingDirectionString',
'PixelFile',
'OriginalSeriesNumber',
'RepetitionTimeEffective',
'EchoLinePosition',
'Comp_Algorithm',
'ProtocolSliceNumber',
'MoCoQMeasure',
'NumberOfAverages',
'VoxelNormalSag',
@satra
satra / output.txt
Created November 14, 2012 19:18
maven output
[INFO] ------------------------------------------------------------------------
[INFO] Building PROV-N 0.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ prov-n ---
[INFO] Deleting /software/nipy-repo/ProvToolbox/prov-n/target
[INFO]
[INFO] --- antlr3-maven-plugin:3.4:antlr (default) @ prov-n ---
[INFO] ANTLR: Processing source directory /software/nipy-repo/ProvToolbox/prov-n/src/main/antlr3
ANTLR Parser Generator Version 3.4