{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# I- DESCRIPTION" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "qMRinfo('mwf'); % 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 = mwf;" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download sample data from OSF\n", "> The current `Model` is an instance of `mwf` class.\n", " \n", "You can manually download the sample data for `mwf` [by clicking here](https:\/\/osf.io\/bes6f\/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", "% |- mwf object needs 1 protocol field(s) to be assigned:\n", "% |- MET2data" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "EchoTime = [10.0000; 20.0000; 30.0000; 40.0000; 50.0000; 60.0000; 70.0000; 80.0000; 90.0000; 100.0000; 110.0000; 120.0000; 130.0000; 140.0000; 150.0000; 160.0000; 170.0000; 180.0000; 190.0000; 200.0000; 210.0000; 220.0000; 230.0000; 240.0000; 250.0000; 260.0000; 270.0000; 280.0000; 290.0000; 300.0000; 310.0000; 320.0000];\n", "% EchoTime (ms) is a vector of [32X1]\n", "Model.Prot.MET2data.Mat = [ EchoTime ];\n", "%% " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# III- FIT EXPERIMENTAL DATASET\n", "## a- Load experimental data\n", "% |- mwf object needs 2 data input(s) to be assigned:\n", "% |- MET2data\n", "% |- Mask" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ " \n", "% MET2data.mat contains [64 64 1 32] data.\n", " load('mwf_data\/MET2data.mat');\n", "% Mask.mat contains [64 64] data.\n", " load('mwf_data\/Mask.mat');\n", " data.MET2data= double(MET2data);\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.MWF = 50.0001;\n", " x.T2MW = 20.0001;\n", " x.T2IEW = 120;\n", " % Set simulation options\n", " Opt.SNR = 200;\n", " Opt.T2Spectrumvariance_Myelin = 5;\n", " Opt.T2Spectrumvariance_IEIntraExtracellularWater = 20;\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": [ " % MWF T2MW T2IEW \n", " OptTable.st = [50 20 1.2e+02]; % nominal values\n", " OptTable.fx = [0 1 1]; %vary MWF...\n", " OptTable.lb = [0.0001 0.0001 40]; %...from 0.0001\n", " OptTable.ub = [1e+02 40 2e+02]; %...to 100\n", " % Set simulation options\n", " Opt.SNR = 200;\n", " Opt.T2Spectrumvariance_Myelin = 5;\n", " Opt.T2Spectrumvariance_IEIntraExtracellularWater = 20;\n", " Opt.Nofrun = 5;\n", " % run simulation\n", " SimResults = Model.Sim_Sensitivity_Analysis(OptTable,Opt);\n", " figure('Name','Sensitivity Analysis');\n", " SimVaryPlot(SimResults, 'MWF' ,'MWF' );" ] } ], "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 }