This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from jhlegarreta/AddCovModelNotebook
ENH: Add dMRI covariance model notebook
- Loading branch information
Showing
1 changed file
with
88 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"metadata": {}, | ||
"cell_type": "markdown", | ||
"source": "Plot the exponential and spherical covariance models.", | ||
"id": "68526eb57440fb0e" | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "markdown", | ||
"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.", | ||
"id": "a124686bde634d64" | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"source": [ | ||
"import numpy as np\n", | ||
"\n", | ||
"from eddymotion.model.dmri_covariance import (\n", | ||
" compute_exponential_covariance,\n", | ||
" compute_spherical_covariance,\n", | ||
")\n", | ||
"\n", | ||
"theta_lin = np.linspace(0, np.pi/2, num=1000)\n", | ||
"\n", | ||
"a_exp = 0.5\n", | ||
"cov_exp = compute_exponential_covariance(theta_lin, a_exp)\n", | ||
"\n", | ||
"a_sph = 1.23\n", | ||
"cov_sph = compute_spherical_covariance(theta_lin, a_sph)" | ||
], | ||
"id": "457b781088e1cae2", | ||
"outputs": [], | ||
"execution_count": null | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "markdown", | ||
"source": "Plot the exponential and spherical covariance functions.", | ||
"id": "1c5f9da8b3a9394e" | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"source": [ | ||
"import matplotlib.pyplot as plt\n", | ||
"\n", | ||
"# Plot the exponential and spherical model covariances\n", | ||
"plt.plot(theta_lin, cov_exp, label=\"Exponential cov\")\n", | ||
"plt.plot(theta_lin, cov_sph, label=\"Spherical cov\")\n", | ||
"\n", | ||
"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", | ||
"\n", | ||
"plt.xlabel(\"Angular distance\")\n", | ||
"plt.ylabel(\"Covariance (arbitrary scaling)\")\n", | ||
"\n", | ||
"plt.legend()\n", | ||
"plt.show()" | ||
], | ||
"id": "9f8abf14503066e0", | ||
"outputs": [], | ||
"execution_count": null | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |