Skip to content

Instantly share code, notes, and snippets.

View satra's full-sized avatar

Satrajit Ghosh satra

View GitHub Profile
@satra
satra / laplacians.py
Created February 25, 2014 01:58
variance laplacians
def _laplacian_dense2(graph, normalization=None, return_diag=False,
max_iters=100, tol=1e-5):
"""Compute different graph Laplacians
"""
dd = np.sum(graph, axis=0)
dd_idx = np.nonzero(dd)[0]
dd_inv = dd
dd_inv[dd_idx] = np.power(dd_inv[dd_idx], -1.)
@satra
satra / ro.ttl
Last active August 29, 2015 13:58
RO and prov:Bundle
@prefix daniel: <http://mayor2.dia.fi.upm.es/oeg-upm/files/dgarijo/motifAnalysis/> .
@prefix dc: <http://purl.org/dc/terms/> .
@prefix ore: <http://www.openarchives.org/ore/terms/> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ro: <http://purl.org/wf4ever/ro#> .
@prefix schema: <http://schema.org/> .
@prefix xhv: <http://www.w3.org/1999/xhtml/vocab#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@satra
satra / joinnode.ipynb
Last active August 29, 2015 14:06
Nipype JoinNode Example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@satra
satra / directory.txt
Created October 6, 2014 02:26
resting preprocessing output structure
$ find SUB_1024011/resting -type f
SUB_1024011/resting/mask_files/median_brain_mask.nii
SUB_1024011/resting/mask_files/T1_out_brain_pve_0_maths_warped.nii
SUB_1024011/resting/mask_files/T1_out_brain_pve_1_maths_warped.nii
SUB_1024011/resting/mask_files/T1_out_brain_pve_2_maths_warped.nii
SUB_1024011/resting/mask_files/target/output_warped_image_maths.nii
SUB_1024011/resting/parcellations/aparc/smooth/rest_01_avgwf.txt
SUB_1024011/resting/parcellations/aparc/smooth/rest_01_summary.stats
SUB_1024011/resting/parcellations/aparc/smooth/rest_02_avgwf.txt
SUB_1024011/resting/parcellations/aparc/smooth/rest_02_summary.stats
@satra
satra / test.py
Created October 8, 2014 16:28
passing pythonic outputs in nipype
from nipype import Workflow, Node, Function
def myrandomfunc(N):
import numpy as np
return np.random.random_integers(1, 10, N)
def mysumfunc(X):
return X.sum()
@satra
satra / test.html
Created November 14, 2014 15:13
papaya + local file reading.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Photo Viewer for Local Files and Directories</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://static.jstree.com/3.0.4/assets/dist/themes/default/style.min.css" />
<link rel="stylesheet" type="text/css" href="http://rii.uthscsa.edu/mango/papaya/papaya.css?version=0.6.5&build=692" />
<script type="text/javascript" src="http://rii.uthscsa.edu/mango/papaya/papaya.js?version=0.6.5&build=692"></script>
#!/bin/bash
for sub in '315' '318' '332' ; do
for run in 1 2 3 4 ; do
mkdir /om/project/gates/wmfilt/openfmri/ds001/${sub}
mkdir /om/project/gates/wmfilt/openfmri/ds001/${sub}/model
mkdir /om/project/gates/wmfilt/openfmri/ds001/${sub}/model/model001
mkdir /om/project/gates/wmfilt/openfmri/ds001/${sub}/model/model001/onsets
mkdir /om/project/gates/wmfilt/openfmri/ds001/${sub}/model/model001/onsets/task001_run00${run}
mkdir /om/project/gates/wmfilt/openfmri/ds001/${sub}/BOLD
@satra
satra / image_mask.py
Last active August 29, 2015 14:14
QQA: compute the volume of contrasts and sort them by size
from glob import glob
import os
import numpy as np
fl = glob('model01/task001/SAD_???/copes/mni/model001/task001_cope01.nii.gz')
os.system('fslmerge -t output.nii.gz %s' % ' '.join(fl))
os.system('fslmaths output.nii.gz -abs -thr 1 -bin output2')
os.system('fslstats -t output2 -V > output2.txt')
foo = np.genfromtxt('output2.txt')
idx = np.argsort(foo[:, 1])
zip(np.array(fl)[idx], foo[idx, 1])
(ipythonenv)unwarped:temp satra$ which ipython
/software/pysoft/ipythonenv/bin/ipython
(ipythonenv)unwarped:temp satra$ ipython
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
Type "copyright", "credits" or "license" for more information.
IPython 0.10 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
class TraitedSpec2(traits.HasTraits):
trigger = traits.Event
hashval = traits.Property(depends_on='trigger')
@traits.cached_property
def _get_hashval(self):
print "calc hash"
import numpy as np
return np.random.random()