From 3ac186be90842a611da40aa6916052e82497ad40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Sat, 22 Jun 2024 10:26:32 -0400 Subject: [PATCH] ENH: Add dMRI covariance model notebook Add dMRI covariance model notebook. --- docs/notebooks/dmri_covariance.ipynb | 88 ++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 docs/notebooks/dmri_covariance.ipynb diff --git a/docs/notebooks/dmri_covariance.ipynb b/docs/notebooks/dmri_covariance.ipynb new file mode 100644 index 00000000..45b98c96 --- /dev/null +++ b/docs/notebooks/dmri_covariance.ipynb @@ -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 +}