Skip to content

Instantly share code, notes, and snippets.

@arokem
Created May 2, 2015 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arokem/51239fe55c07da101633 to your computer and use it in GitHub Desktop.
Save arokem/51239fe55c07da101633 to your computer and use it in GitHub Desktop.
"""
To use:
load_ext line_profiler
import profile_near_roi as p
lprun -f p.ut.near_roi p.func()
"""
import dipy.data as dpd
import nibabel.trackvis as trk
import dipy.tracking.utils as ut
import numpy as np
fornix_file = dpd.get_data('fornix')
fornix_content = trk.read(fornix_file)
streamlines = [t[0] for t in fornix_content[0]]
mask = np.zeros((150, 150, 100), dtype=bool)
mask[90:100, 100:110, 90] = 1
def func():
ans = ut.near_roi(streamlines, mask, affine=None, tol=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment