{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# I- DESCRIPTION" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "qMRinfo('inversion_recovery'); % Describe the model" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# II- MODEL PARAMETERS\n", "## a- Create object" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "Model = inversion_recovery;" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download sample data from OSF\n", "> The current `Model` is an instance of `inversion_recovery` class.\n", " \n", "You can manually download the sample data for `inversion_recovery` [by clicking here](https:\/\/osf.io\/cmg9z\/download?version=3)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "dataDir = downloadData(Model,pwd);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## b- Set protocol\n", "> Protocol is set according to the example data\n", " \n", "% |- inversion_recovery object needs 2 protocol field(s) to be assigned:\n", "% |- IRData\n", "% |- TimingTable" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "TI = [350.0000; 500.0000; 650.0000; 800.0000; 950.0000; 1100.0000; 1250.0000; 1400.0000; 1700.0000];\n", "% TI(ms) is a vector of [9X1]\n", "Model.Prot.IRData.Mat = [ TI];\n", "%% \n", "TR = 2500;\n", "Model.Prot.TimingTable.Mat = [ TR];\n", "%% " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# III- FIT EXPERIMENTAL DATASET\n", "## a- Load experimental data\n", "% |- inversion_recovery object needs 2 data input(s) to be assigned:\n", "% |- IRData\n", "% |- Mask" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ " \n", "% IRData.mat contains [128 128 1 9] data.\n", " load('inversion_recovery_data\/IRData.mat');\n", "% Mask.mat contains [128 128] data.\n", " load('inversion_recovery_data\/Mask.mat');\n", " data.IRData= double(IRData);\n", " data.Mask= double(Mask);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## b- Fit experimental data\n", "> This section will fit data." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "FitResults = FitData(data,Model,0);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## c- Show fitting results\n", "> * Output map will be displayed.\n", " \n", "> * If available, a graph will be displayed to show fitting in a voxel." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "qMRshowOutput(FitResults,data,Model);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## d- Save results\n", "> * qMR maps are saved in NIFTI and in a structure `FitResults.mat` that can be loaded in qMRLab graphical user interface.\n", "> * Model object stores all the options and protocol\n", "> * These objects can be easily shared or be used for simulation." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "FitResultsSave_nii(FitResults);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# IV- SIMULATIONS\n", "> This section can be executed to run simulations for vfa_t1.\n", " \n", "## a- Single Voxel Curve\n", "> Simulates single voxel curves:\n", " \n", " 1. Use equation to generate synthetic MRI data\n", " 2. Add rician noise\n", " 3. Fit and plot curve" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ " x = struct;\n", " x.T1 = 600;\n", " x.rb = -1000;\n", " x.ra = 500;\n", " % Set simulation options\n", " Opt.SNR = 50;\n", " Opt.T1 = 600;\n", " Opt.M0 = 1000;\n", " Opt.TR = 3000;\n", " Opt.FAinv = 180;\n", " Opt.FAexcite = 90;\n", " Opt.Updateinputvariables = false;\n", " % run simulation\n", " figure('Name','Single Voxel Curve Simulation');\n", " FitResult = Model.Sim_Single_Voxel_Curve(x,Opt);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## b- Sensitivity analysis\n", "> Simulates sensitivity to fitted parameters: \n", " \n", " 1. Vary fitting parameters from lower (lb) to upper (ub) bound.\n", " 2. Run Sim_Single_Voxel_Curve Nofruns times\n", " 3. Compute mean and std across runs" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ " % T1 rb ra \n", " OptTable.st = [6e+02 -1e+03 5e+02]; % nominal values\n", " OptTable.fx = [0 1 1]; %vary T1...\n", " OptTable.lb = [0.0001 -1e+04 0.0001]; %...from 0.0001\n", " OptTable.ub = [5e+03 0 1e+04]; %...to 5000\n", " Opt.SNR = 50;\n", " Opt.Nofrun = 5;\n", " % run simulation\n", " SimResults = Model.Sim_Sensitivity_Analysis(OptTable,Opt);\n", " figure('Name','Sensitivity Analysis');\n", " SimVaryPlot(SimResults, 'T1' ,'T1' );" ] } ], "metadata": { "kernelspec": { "display_name": "Octave", "language": "octave", "name": "octave" }, "language_info": { "file_extension": ".m", "help_links": [ { "text": "GNU Octave", "url": "https:\/\/www.gnu.org\/software\/octave\/support.html" }, { "text": "Octave Kernel", "url": "https:\/\/github.com\/Calysto\/octave_kernel" }, { "text": "MetaKernel Magics", "url": "https:\/\/github.com\/calysto\/metakernel\/blob\/master\/metakernel\/magics\/README.md" } ], "mimetype": "text\/x-octave", "name": "octave", "version": "4.2.1" }, "toc": { "nav_menu": null, "number_sections": true, "sideBar": false, "skip_h1_title": false, "toc_cell": false, "toc_position": null, "toc_section_display": "block", "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }