Skip to content

Instantly share code, notes, and snippets.

@arokem
Created January 29, 2016 18:55
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/648909e1943011de661b to your computer and use it in GitHub Desktop.
Save arokem/648909e1943011de661b to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import dipy.core.gradients as dpg\n",
"import dipy.data as dpd\n",
"import dipy.reconst.dti as dti\n",
"import nibabel as nib"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%load_ext memory_profiler"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"img = nib.load('/Users/arokem/.dipy/stanford_hardi/HARDI150.nii')\n",
"gtab = dpg.gradient_table('/Users/arokem/.dipy/stanford_hardi/HARDI150.bval', \n",
" '/Users/arokem/.dipy/stanford_hardi/HARDI150.bvec')\n",
"data = img.get_data()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"peak memory: 919.16 MiB, increment: 836.98 MiB\n",
"peak memory: 996.80 MiB, increment: 614.00 MiB\n",
"peak memory: 985.32 MiB, increment: 502.35 MiB\n",
"peak memory: 1025.04 MiB, increment: 538.19 MiB\n",
"peak memory: 1054.46 MiB, increment: 541.49 MiB\n"
]
}
],
"source": [
"for step in [1, 10, 100, 1000, 10000]:\n",
" tenmodel = dti.TensorModel(gtab, step=step)\n",
" %memit tenfit = tenmodel.fit(data)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment