Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit c1bd3da

Browse files
authored
Merge pull request #214 from jhlegarreta/AddCovModelNotebook
ENH: Add dMRI covariance model notebook
2 parents ba5d692 + 3ac186b commit c1bd3da

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"cells": [
3+
{
4+
"metadata": {},
5+
"cell_type": "markdown",
6+
"source": "Plot the exponential and spherical covariance models.",
7+
"id": "68526eb57440fb0e"
8+
},
9+
{
10+
"metadata": {},
11+
"cell_type": "markdown",
12+
"source": "Compute the exponential and the spherical covariance function matrix values for angles between 0 and $\\pi/2$. The length scale parameters are set to $a=1.23$ and $a=0.5$ for the spherical and the exponential functions respectively.",
13+
"id": "a124686bde634d64"
14+
},
15+
{
16+
"metadata": {},
17+
"cell_type": "code",
18+
"source": [
19+
"import numpy as np\n",
20+
"\n",
21+
"from eddymotion.model.dmri_covariance import (\n",
22+
" compute_exponential_covariance,\n",
23+
" compute_spherical_covariance,\n",
24+
")\n",
25+
"\n",
26+
"theta_lin = np.linspace(0, np.pi/2, num=1000)\n",
27+
"\n",
28+
"a_exp = 0.5\n",
29+
"cov_exp = compute_exponential_covariance(theta_lin, a_exp)\n",
30+
"\n",
31+
"a_sph = 1.23\n",
32+
"cov_sph = compute_spherical_covariance(theta_lin, a_sph)"
33+
],
34+
"id": "457b781088e1cae2",
35+
"outputs": [],
36+
"execution_count": null
37+
},
38+
{
39+
"metadata": {},
40+
"cell_type": "markdown",
41+
"source": "Plot the exponential and spherical covariance functions.",
42+
"id": "1c5f9da8b3a9394e"
43+
},
44+
{
45+
"metadata": {},
46+
"cell_type": "code",
47+
"source": [
48+
"import matplotlib.pyplot as plt\n",
49+
"\n",
50+
"# Plot the exponential and spherical model covariances\n",
51+
"plt.plot(theta_lin, cov_exp, label=\"Exponential cov\")\n",
52+
"plt.plot(theta_lin, cov_sph, label=\"Spherical cov\")\n",
53+
"\n",
54+
"plt.xticks([0.0, np.pi/8, np.pi/4, 3*np.pi/8, np.pi/2], [\"0\", \"pi/8\", \"pi/4\", \"3pi/8\", \"pi/2\"])\n",
55+
"\n",
56+
"plt.xlabel(\"Angular distance\")\n",
57+
"plt.ylabel(\"Covariance (arbitrary scaling)\")\n",
58+
"\n",
59+
"plt.legend()\n",
60+
"plt.show()"
61+
],
62+
"id": "9f8abf14503066e0",
63+
"outputs": [],
64+
"execution_count": null
65+
}
66+
],
67+
"metadata": {
68+
"kernelspec": {
69+
"display_name": "Python 3",
70+
"language": "python",
71+
"name": "python3"
72+
},
73+
"language_info": {
74+
"codemirror_mode": {
75+
"name": "ipython",
76+
"version": 2
77+
},
78+
"file_extension": ".py",
79+
"mimetype": "text/x-python",
80+
"name": "python",
81+
"nbconvert_exporter": "python",
82+
"pygments_lexer": "ipython2",
83+
"version": "2.7.6"
84+
}
85+
},
86+
"nbformat": 4,
87+
"nbformat_minor": 5
88+
}

0 commit comments

Comments
 (0)