View trk2tck.py
import os
import argparse
import nibabel as nib
def build_argparser():
DESCRIPTION = "Convert tractograms (TRK -> TCK)."
p = argparse.ArgumentParser(description=DESCRIPTION)
p.add_argument('tractograms', metavar='bundle', nargs="+", help='list of tractograms.')
p.add_argument('-f', '--force', action="store_true", help='overwrite existing output files.')
View tck2trk.py
import os
import argparse
import nibabel as nib
from nibabel.streamlines import Field
from nibabel.orientations import aff2axcodes
def build_argparser():
DESCRIPTION = "Convert tractograms (TCK -> TRK)."
View sum_of_stack_bug.py
import theano
import theano.tensor as T
import numpy as np
A = theano.shared(np.array([1, 2, 3, 4, 5]))
print "Theano"
print T.sum(T.stack(A, A), axis=0).eval()
print T.sum(T.stack(A, A), axis=1).eval()
View nstreams_bug.py
import theano
import numpy as np
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
theano_rng = RandomStreams(42)
# This one works fine
print np.sum(theano_rng.uniform(size=(10000, 784), dtype=theano.config.floatX, nstreams=10000).eval(), 1)
# This one produces NaN at the end
print np.sum(theano_rng.uniform(size=(10000, 784), dtype=theano.config.floatX, nstreams=10000*400).eval(), 1)
View main.py
import numpy as np
import resource
import metric
def test_memory_leak():
NB_LOOPS = 20
NB_LINES = 10000
NB_POINTS = 100
View metric.pyx
ctypedef float[:,:] float2d
ctypedef double[:,:] double2d
ctypedef fused Line:
float2d
double2d
cdef class Metric:
cdef float dist(Metric self, Line line) nogil:
pass
View length_per_voxel.py
from dipy.viz import fvtk
import numpy as np
from numpy.testing import measure
from nose.tools import assert_equal, assert_almost_equal
from numpy.testing import assert_array_equal, assert_array_almost_equal
norm = lambda x: np.sqrt(np.sum(x**2))
View save_trk_with_color.py
import numpy as np
from nibabel import trackvis as tv
from dipy.segment.quickbundles import QuickBundles
from dipy.data import get_data
fname = get_data('fornix')
streams, hdr = tv.read(fname)
streamlines = [i[0] for i in streams]
qb = QuickBundles(streamlines, dist_thr=10., pts=12)
View tensor_dot.py
import numpy as np
import theano
import theano.tensor as T
print "Version:", theano.version.version
print "=Theano="
A = T.zeros((2,10))
B = T.zeros((30, 10))
print "Shape of A:", A.eval().shape
View cumsum_leak.py
import resource
import numpy as np
from scipy import weave
x = np.ones(1e6, dtype=np.float32)
# There is no memory leak, when we let PyArray_CumSum creates the output array, i.e. when out=NULL.
code_good = r"""
npy_intp shape[1] = { PyArray_SIZE(x_array) };
int dtype = PyArray_DTYPE(x_array)->type_num;