{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# DSI Deconvolution vs DSI\n\nAn alternative method to DSI is the method proposed by [Canales10]_ which is\ncalled DSI with Deconvolution. This algorithm is using Lucy-Richardson\ndeconvolution in the diffusion propagator with the goal to create sharper ODFs\nwith higher angular resolution.\n\nIn this example we will show with simulated data how this method's ODF\nperforms against standard DSI ODF and a ground truth multi tensor ODF.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nfrom dipy.sims.voxel import multi_tensor, multi_tensor_odf\nfrom dipy.data import get_fnames, get_sphere\nfrom dipy.core.gradients import gradient_table\nfrom dipy.reconst.dsi import (DiffusionSpectrumDeconvModel,\n DiffusionSpectrumModel)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For the simulation we will use a standard DSI acquisition scheme with 514\ngradient directions and 1 S0.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "btable = np.loadtxt(get_fnames('dsi515btable'))\n\ngtab = gradient_table(btable[:, 0], btable[:, 1:])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's create a multi tensor with 2 fiber directions at 60 degrees.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "evals = np.array([[0.0015, 0.0003, 0.0003],\n [0.0015, 0.0003, 0.0003]])\n\ndirections = [(-30, 0), (30, 0)]\n\nfractions = [50, 50]\n\nsignal, _ = multi_tensor(gtab, evals, 100, angles=directions,\n fractions=fractions, snr=None)\n\nsphere = get_sphere('repulsion724').subdivide(1)\n\nodf_gt = multi_tensor_odf(sphere.vertices, evals, angles=directions,\n fractions=fractions)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Perform the reconstructions with standard DSI and DSI with deconvolution.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "dsi_model = DiffusionSpectrumModel(gtab)\n\ndsi_odf = dsi_model.fit(signal).odf(sphere)\n\ndsid_model = DiffusionSpectrumDeconvModel(gtab)\n\ndsid_odf = dsid_model.fit(signal).odf(sphere)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, we can visualize the ground truth ODF, together with the DSI and DSI\nwith deconvolution ODFs and observe that with the deconvolved method it is\neasier to resolve the correct fiber directions because the ODF is sharper.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from dipy.viz import window, actor\n\n# Enables/disables interactive visualization\ninteractive = False\n\n\nscene = window.Scene()\n\n# concatenate data as 4D array\nodfs = np.vstack((odf_gt, dsi_odf, dsid_odf))[:, None, None]\nodf_actor = actor.odf_slicer(odfs, sphere=sphere, scale=0.5, colormap='plasma')\n\nodf_actor.display(y=0)\nodf_actor.RotateX(90)\nscene.add(odf_actor)\nwindow.record(scene, out_path='dsid.png', size=(300, 300))\nif interactive:\n window.show(scene)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ".. figure:: dsid.png\n :align: center\n\n Ground truth ODF (left), DSI ODF (middle), DSI with Deconvolution ODF (right).\n\n.. [Canales10] Canales-Rodriguez et al., Deconvolution in Diffusion Spectrum Imaging,\n Neuroimage, vol 50, no 1, p. 136-149, 2010.\n\n\n" ] } ], "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.9.13" } }, "nbformat": 4, "nbformat_minor": 0 }