|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "source": [ |
| 6 | + "# Compressed-sensing reconstruction" |
| 7 | + ], |
| 8 | + "metadata": {} |
| 9 | + }, |
| 10 | + { |
| 11 | + "cell_type": "markdown", |
| 12 | + "source": [ |
| 13 | + "## Description\n", |
| 14 | + "\n", |
| 15 | + "This example describes how to perform a compressed-sensingreconstruction of a CS-2 accelerated acquisition." |
| 16 | + ], |
| 17 | + "metadata": {} |
| 18 | + }, |
| 19 | + { |
| 20 | + "cell_type": "markdown", |
| 21 | + "source": [ |
| 22 | + "## Loading Package" |
| 23 | + ], |
| 24 | + "metadata": {} |
| 25 | + }, |
| 26 | + { |
| 27 | + "outputs": [], |
| 28 | + "cell_type": "code", |
| 29 | + "source": [ |
| 30 | + "using LazyArtifacts # loading data\n", |
| 31 | + "using SEQ_BRUKER_a_MP2RAGE_CS_360\n", |
| 32 | + "using CairoMakie # plotting" |
| 33 | + ], |
| 34 | + "metadata": {}, |
| 35 | + "execution_count": null |
| 36 | + }, |
| 37 | + { |
| 38 | + "cell_type": "markdown", |
| 39 | + "source": [ |
| 40 | + "In addition we load the package internally used to perform the reconstruction" |
| 41 | + ], |
| 42 | + "metadata": {} |
| 43 | + }, |
| 44 | + { |
| 45 | + "cell_type": "markdown", |
| 46 | + "source": [ |
| 47 | + "## Loading Package" |
| 48 | + ], |
| 49 | + "metadata": {} |
| 50 | + }, |
| 51 | + { |
| 52 | + "outputs": [], |
| 53 | + "cell_type": "code", |
| 54 | + "source": [ |
| 55 | + "using LazyArtifacts # loading data\n", |
| 56 | + "using SEQ_BRUKER_a_MP2RAGE_CS_360\n", |
| 57 | + "using CairoMakie # plotting\n", |
| 58 | + "\n", |
| 59 | + "datadir = Main.MP2_artifacts\n", |
| 60 | + "@info \"The test data is located at $datadir.\"" |
| 61 | + ], |
| 62 | + "metadata": {}, |
| 63 | + "execution_count": null |
| 64 | + }, |
| 65 | + { |
| 66 | + "cell_type": "markdown", |
| 67 | + "source": [ |
| 68 | + "If you want to perform your own reconstruction, you can change the following line in order to point to another a bruker dataset" |
| 69 | + ], |
| 70 | + "metadata": {} |
| 71 | + }, |
| 72 | + { |
| 73 | + "outputs": [], |
| 74 | + "cell_type": "code", |
| 75 | + "source": [ |
| 76 | + "path_bruker = joinpath(datadir, \"MP2RAGE_CS2\")" |
| 77 | + ], |
| 78 | + "metadata": {}, |
| 79 | + "execution_count": null |
| 80 | + }, |
| 81 | + { |
| 82 | + "cell_type": "markdown", |
| 83 | + "source": [ |
| 84 | + "## Compressed-sensing reconstruction\n", |
| 85 | + "In order to use an advanced reconstruction we will pass some parameters that will be used by the reconstruction package MRIReco.jl" |
| 86 | + ], |
| 87 | + "metadata": {} |
| 88 | + }, |
| 89 | + { |
| 90 | + "outputs": [], |
| 91 | + "cell_type": "code", |
| 92 | + "source": [ |
| 93 | + "using SEQ_BRUKER_a_MP2RAGE_CS_360.MRIReco\n", |
| 94 | + "using SEQ_BRUKER_a_MP2RAGE_CS_360.MRIReco.RegularizedLeastSquares" |
| 95 | + ], |
| 96 | + "metadata": {}, |
| 97 | + "execution_count": null |
| 98 | + }, |
| 99 | + { |
| 100 | + "cell_type": "markdown", |
| 101 | + "source": [ |
| 102 | + "We have to create a parameter dictionnary that will be used. If you need more information about it take a look at [MRIReco.jl](https://github.com/MagneticResonanceImaging/MRIReco.jl)" |
| 103 | + ], |
| 104 | + "metadata": {} |
| 105 | + }, |
| 106 | + { |
| 107 | + "outputs": [], |
| 108 | + "cell_type": "code", |
| 109 | + "source": [ |
| 110 | + "CS = Dict{Symbol,Any}()\n", |
| 111 | + "CS[:sparseTrafo] = \"Wavelet\" #sparse trafo\n", |
| 112 | + "CS[:reg] = L1Regularization(100.) # regularization\n", |
| 113 | + "CS[:solver] = FISTA # solver\n", |
| 114 | + "CS[:iterations] = 30\n", |
| 115 | + "\n", |
| 116 | + "d = reconstruction_MP2RAGE(path_bruker; mean_NR=true,paramsCS = CS)" |
| 117 | + ], |
| 118 | + "metadata": {}, |
| 119 | + "execution_count": null |
| 120 | + }, |
| 121 | + { |
| 122 | + "cell_type": "markdown", |
| 123 | + "source": [ |
| 124 | + "for comparison purpose let's perform the undersampled reconstruction (without the paramCS keyword)" |
| 125 | + ], |
| 126 | + "metadata": {} |
| 127 | + }, |
| 128 | + { |
| 129 | + "outputs": [], |
| 130 | + "cell_type": "code", |
| 131 | + "source": [ |
| 132 | + "d_under = reconstruction_MP2RAGE(path_bruker; mean_NR=true)" |
| 133 | + ], |
| 134 | + "metadata": {}, |
| 135 | + "execution_count": null |
| 136 | + }, |
| 137 | + { |
| 138 | + "cell_type": "markdown", |
| 139 | + "source": [ |
| 140 | + "We can check the results" |
| 141 | + ], |
| 142 | + "metadata": {} |
| 143 | + }, |
| 144 | + { |
| 145 | + "outputs": [], |
| 146 | + "cell_type": "code", |
| 147 | + "source": [ |
| 148 | + "begin\n", |
| 149 | + " f = Figure(size=(500,400))\n", |
| 150 | + " ax=Axis(f[1,1],title=\"TI₁ undersampled\")\n", |
| 151 | + " h=heatmap!(ax,abs.(d_under[\"im_reco\"][:,:,60,1,1,1]),colormap=:grays)\n", |
| 152 | + "\n", |
| 153 | + " ax=Axis(f[1,2],title=\"TI₁ CS\")\n", |
| 154 | + " h=heatmap!(ax,abs.(d[\"im_reco\"][:,:,60,1,1,1]),colormap=:grays)\n", |
| 155 | + "\n", |
| 156 | + "\n", |
| 157 | + " ax=Axis(f[2,1],title=\"UNIT1 undersampled\")\n", |
| 158 | + " h=heatmap!(ax,d_under[\"T1map\"][:,:,60,1,1],colorrange = (500,2000))\n", |
| 159 | + "\n", |
| 160 | + " ax=Axis(f[2,2],title=\"UNIT1 CS\")\n", |
| 161 | + " h=heatmap!(ax,d[\"T1map\"][:,:,60,1,1],colorrange = (500,2000))\n", |
| 162 | + "\n", |
| 163 | + " for ax in f.content # hide decoration befor adding colorbar\n", |
| 164 | + " hidedecorations!(ax)\n", |
| 165 | + " end\n", |
| 166 | + "\n", |
| 167 | + " Colorbar(f[2,3],h,label = \"T₁ [ms]\", flip_vertical_label=true)\n", |
| 168 | + " f\n", |
| 169 | + "end" |
| 170 | + ], |
| 171 | + "metadata": {}, |
| 172 | + "execution_count": null |
| 173 | + }, |
| 174 | + { |
| 175 | + "cell_type": "markdown", |
| 176 | + "source": [ |
| 177 | + "## Write results in BIDS format\n", |
| 178 | + "Results can be written following most of the [qBIDS format recommandation](https://bids-specification.readthedocs.io/en/stable/appendices/qmri.html)" |
| 179 | + ], |
| 180 | + "metadata": {} |
| 181 | + }, |
| 182 | + { |
| 183 | + "outputs": [], |
| 184 | + "cell_type": "code", |
| 185 | + "source": [ |
| 186 | + "subject_name = \"sub_01_cs\"\n", |
| 187 | + "dir_path = \"\" # directory path where the files will be create\n", |
| 188 | + "write_bids_MP2RAGE(d,subject_name,dir_path)" |
| 189 | + ], |
| 190 | + "metadata": {}, |
| 191 | + "execution_count": null |
| 192 | + }, |
| 193 | + { |
| 194 | + "cell_type": "markdown", |
| 195 | + "source": [ |
| 196 | + "---\n", |
| 197 | + "\n", |
| 198 | + "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" |
| 199 | + ], |
| 200 | + "metadata": {} |
| 201 | + } |
| 202 | + ], |
| 203 | + "nbformat_minor": 3, |
| 204 | + "metadata": { |
| 205 | + "language_info": { |
| 206 | + "file_extension": ".jl", |
| 207 | + "mimetype": "application/julia", |
| 208 | + "name": "julia", |
| 209 | + "version": "1.11.1" |
| 210 | + }, |
| 211 | + "kernelspec": { |
| 212 | + "name": "julia-1.11", |
| 213 | + "display_name": "Julia 1.11.1", |
| 214 | + "language": "julia" |
| 215 | + } |
| 216 | + }, |
| 217 | + "nbformat": 4 |
| 218 | +} |
0 commit comments