|
| 1 | +#--------------------------------------------------------- |
| 2 | +# # [Simple reconstruction](@id 01-simple_reconstruction) |
| 3 | +#--------------------------------------------------------- |
| 4 | + |
| 5 | +# ## Description |
| 6 | +# |
| 7 | +# This example describes how to perform a reconstruction of a fully acquisition acquired with the a_MP2RAGE_CS_360 sequence. |
| 8 | +# |
| 9 | + |
| 10 | +# ## Loading Package |
| 11 | +using Artifacts |
| 12 | +using LazyArtifacts # loading data |
| 13 | +using SEQ_BRUKER_a_MP2RAGE_CS_360 |
| 14 | +using CairoMakie # plotting |
| 15 | + |
| 16 | +# ## Download the datasets |
| 17 | + artifact_toml = "../../../../Artifacts.toml" |
| 18 | + _hash = artifact_hash("MP2RAGE_data", artifact_toml) |
| 19 | + if ~isnothing(_hash) |
| 20 | + datadir = artifact_path(_hash) |
| 21 | + else |
| 22 | + datadir = artifact_path(artifact_hash("MP2RAGE_data",find_artifacts_toml("."))) |
| 23 | + end |
| 24 | +@info "The test data is located at $datadir." |
| 25 | + |
| 26 | +# If you want to perform your own reconstruction, you can change the following line in order to point to another a bruker dataset |
| 27 | +path_bruker = joinpath(datadir, "MP2RAGE_FULLY") |
| 28 | + |
| 29 | +# ## Perform the reconstruction |
| 30 | +# this function will perform a standard reconstruction without compressed-sensing. If your data are subsampled, results will be undersampled reconstruction. |
| 31 | +# |
| 32 | +# the keyword mean_NR=true will average the image before performing the MP2RAGE/T1 maps estimation. |
| 33 | +# Otherwise an image/T₁ map will be generated for each Number Of Repetition (NR) |
| 34 | +d = reconstruction_MP2RAGE(path_bruker; mean_NR=true) |
| 35 | + |
| 36 | + |
| 37 | +# the result is a dictionnary with the following fields : |
| 38 | +# - "im_reco" : (x,y,z,Number of Repetition,TI) Complex |
| 39 | +# - "MP2RAGE" : (x,y,z,TI) Float |
| 40 | +# - "T1map" : (x,y,z,Number of Repetition) Float |
| 41 | +# - "params_prot" |
| 42 | +# - "params_reco" |
| 43 | +# - "params_MP2RAGE" |
| 44 | +# |
| 45 | +# im_reco corresponds to the TI₁ and \TI₂ images in the complex format with 6 dimensions : |
| 46 | +# (x,y,z,Number of Repetition,TI) |
| 47 | + |
| 48 | + |
| 49 | +# We can check the results |
| 50 | + |
| 51 | +begin |
| 52 | + f = Figure(size=(500,400)) |
| 53 | + ax=Axis(f[1,1],title="TI₁") |
| 54 | + h=heatmap!(ax,abs.(d["im_reco"][:,:,60,1,1,1]),colormap=:grays) |
| 55 | + |
| 56 | + ax=Axis(f[1,2],title="TI₂") |
| 57 | + h=heatmap!(ax,abs.(d["im_reco"][:,:,60,1,1,2]),colormap=:grays) |
| 58 | + |
| 59 | + ax=Axis(f[2,1],title="UNIT1 / MP2RAGE") |
| 60 | + h=heatmap!(ax,d["MP2RAGE"][:,:,60,1,1],colormap=:grays) |
| 61 | + |
| 62 | + ax=Axis(f[2,2],title="UNIT1 / MP2RAGE") |
| 63 | + h=heatmap!(ax,d["T1map"][:,:,60,1,1],colorrange = (500,2000)) |
| 64 | + |
| 65 | + for ax in f.content # hide decoration befor adding colorbar |
| 66 | + hidedecorations!(ax) |
| 67 | + end |
| 68 | + |
| 69 | + Colorbar(f[2,3],h,label = "T₁ [ms]", flip_vertical_label=true) |
| 70 | + f |
| 71 | +end |
| 72 | + |
| 73 | +# The Lookup table used for the reconstruction is stored in the dictionnary (LUT) |
| 74 | +# First columns is the range of T1. |
| 75 | +f=Figure() |
| 76 | +ax = Axis(f[1,1],xlabel="T₁ [ms]") |
| 77 | +lines!(ax,d["LUT"]) |
| 78 | +f |
| 79 | + |
| 80 | +# ## Write results in BIDS format |
| 81 | +# Results can be written following most of the [qBIDS format recommandation](https://bids-specification.readthedocs.io/en/stable/appendices/qmri.html) |
| 82 | + |
| 83 | +subject_name = "sub_01" |
| 84 | +dir_path = "" # directory path where the files will be create |
| 85 | +write_bids_MP2RAGE(d,subject_name,dir_path) |
| 86 | + |
| 87 | +#= |
| 88 | +which results in : |
| 89 | +``` |
| 90 | +sub_01/ |
| 91 | +├─ MP2RAGE.json |
| 92 | +└─ anat/ |
| 93 | + ├─ sub_01_T1map.nii.gz |
| 94 | + ├─ sub_01_UNIT1.nii.gz |
| 95 | + ├─ sub_01_inv-1-complex_MP2RAGE.nii.gz |
| 96 | + ├─ sub_01_inv-1-mag_MP2RAGE.nii.gz |
| 97 | + ├─ sub_01_inv-1-phase_MP2RAGE.nii.gz |
| 98 | + ├─ sub_01_inv-2-complex_MP2RAGE.nii.gz |
| 99 | + ├─ sub_01_inv-2-mag_MP2RAGE.nii.gz |
| 100 | + └─ sub_01_inv-2-phase_MP2RAGE.nii.gz |
| 101 | +``` |
| 102 | +
|
| 103 | +If you want to generate the T1 map with another tools like qMRLab |
| 104 | +the required MP2RAGE parameters are stored in the **MP2RAGE.json** file. |
| 105 | +=# |
| 106 | + |
0 commit comments