Created
July 21, 2016 21:14
-
-
Save quantshah/46ec2606e2f37f8f7efc4ddaa8c7e7d4 to your computer and use it in GitHub Desktop.
scipy 17 fail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"0.17.1\n", | |
"Dataset is already in place. If you want to fetch it again please first remove the folder /home/shahnawaz/.dipy/ivim \n" | |
] | |
}, | |
{ | |
"ename": "ValueError", | |
"evalue": "`x0` is infeasible.", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", | |
"\u001b[1;32m<ipython-input-3-e49b25282f7f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 20\u001b[0m ivimmodel1 = IvimModel(gtab, x0= np.array([1000., 0.1, 0.001, 0.0001]), bounds=([0., 0., 0., 0.],\n\u001b[0;32m 21\u001b[0m [np.inf, 1., 1., 1.]))\n\u001b[1;32m---> 22\u001b[1;33m \u001b[0mivifit\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mivimmodel1\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mflat_data\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m8\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", | |
"\u001b[1;32m/home/shahnawaz/dev/gsoc16/dipy/dipy/reconst/ivim.py\u001b[0m in \u001b[0;36mfit\u001b[1;34m(self, data, mask)\u001b[0m\n\u001b[0;32m 198\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msplit_b\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 199\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbounds\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtol\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 200\u001b[1;33m self.options)\n\u001b[0m\u001b[0;32m 201\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 202\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mmask\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m/home/shahnawaz/dev/gsoc16/dipy/dipy/reconst/ivim.py\u001b[0m in \u001b[0;36mtwo_stage\u001b[1;34m(data, gtab, x0, split_b, bounds, tol, options)\u001b[0m\n\u001b[0;32m 396\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 397\u001b[0m _leastsq(flat_data, bvals, flat_x0,\n\u001b[1;32m--> 398\u001b[1;33m ivim_params, options, tol, bounds)\n\u001b[0m\u001b[0;32m 399\u001b[0m \u001b[0mivim_params\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m-\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 400\u001b[0m \u001b[0mivim_params\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mivim_params\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m*\u001b[0m \u001b[0mS_normalization\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m/home/shahnawaz/dev/gsoc16/dipy/dipy/reconst/ivim.py\u001b[0m in \u001b[0;36m_leastsq\u001b[1;34m(flat_data, bvals, flat_x0, ivim_params, options, tol, bounds)\u001b[0m\n\u001b[0;32m 321\u001b[0m \u001b[0mgtol\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mgtol\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 322\u001b[0m \u001b[0mmax_nfev\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmaxfev\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 323\u001b[1;33m args=(bvals, flat_data[vox]))\n\u001b[0m\u001b[0;32m 324\u001b[0m \u001b[0mivim_params\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mvox\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m:\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mres\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 325\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mvox\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mres\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m/usr/local/lib/python3.4/dist-packages/scipy/optimize/_lsq/least_squares.py\u001b[0m in \u001b[0;36mleast_squares\u001b[1;34m(fun, x0, jac, bounds, method, ftol, xtol, gtol, x_scale, loss, f_scale, diff_step, tr_solver, tr_options, jac_sparsity, max_nfev, verbose, args, kwargs)\u001b[0m\n\u001b[0;32m 755\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 756\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0min_bounds\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx0\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlb\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mub\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 757\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"`x0` is infeasible.\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 758\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 759\u001b[0m \u001b[0mx_scale\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcheck_x_scale\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx_scale\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mx0\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;31mValueError\u001b[0m: `x0` is infeasible." | |
] | |
} | |
], | |
"source": [ | |
"from dipy.reconst.ivim import IvimModel\n", | |
"from dipy.data.fetcher import read_ivim\n", | |
"import matplotlib.pyplot as plt\n", | |
"import numpy as np\n", | |
"import scipy\n", | |
"\n", | |
"print (scipy.__version__)\n", | |
"\n", | |
"img, gtab = read_ivim()\n", | |
"data = img.get_data()\n", | |
"\n", | |
"x1, x2 = 160, 180\n", | |
"y1, y2 = 90, 110\n", | |
"z = 33\n", | |
"data_slice = data[x1:x2, y1:y2, z, :]\n", | |
"\n", | |
"flat_data = data_slice.reshape((-1, data.shape[-1]))\n", | |
"plt.scatter(gtab.bvals, flat_data[8])\n", | |
"\n", | |
"ivimmodel1 = IvimModel(gtab, x0= np.array([1000., 0.1, 0.001, 0.0001]), bounds=([0., 0., 0., 0.],\n", | |
" [np.inf, 1., 1., 1.]))\n", | |
"ivifit = ivimmodel1.fit(flat_data[8])" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.4.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment