From 1027f5471d460a8e627490faeeb9ac44dc8cc2c9 Mon Sep 17 00:00:00 2001
From: Michiel Cottaar <MichielCottaar@protonmail.com>
Date: Wed, 15 May 2024 16:30:58 +0100
Subject: [PATCH] Add usage examples

---
 docs/src/implemented_sequences.md | 46 +++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/docs/src/implemented_sequences.md b/docs/src/implemented_sequences.md
index 1861a3a..2643e91 100644
--- a/docs/src/implemented_sequences.md
+++ b/docs/src/implemented_sequences.md
@@ -10,6 +10,52 @@ When reading the help, you will notice that there are two type of expected input
 - `Parameters`: these define the type of components that will be includes, e.g., the shape of the excitation pulse or the readout strategy. These parameters have to be set to certain fixed values. If unset, they will be determined by their default value as defined in the documentation.
 - `Variables`: These are a special type of parameters. In addition to being set to a fixed value, they can also be set to `:min` or `:max` to minimise or maximise the variable. If they are unset, they will be determined based on the other variables. For more details, see the section on [sequence optimisation](@ref sequence_optimisation).
 
+As an example, the following creates and plots a [`DiffusionSpinEcho`](@ref) that has a b-value of 1, a minimal echo time, and a slice thickness of 2 mm:
+```@example
+using MRIBuilder
+using CairoMakie
+sequence = DiffusionSpinEcho(bval=1., TE=:min, slice_thickness=2)
+plot(sequence)
+save("dwi_1_min_2.png") # hide
+nothing # hide
+```
+![DWI sequence diagram](dwi_1_min_2.png)
+
+If we want a specific [`diffusion_time`](@ref), we can just add it to the constraints, and the rest of the sequence will adapt as needed:
+```@example
+using MRIBuilder # hide
+using CairoMakie # hide
+sequence = DiffusionSpinEcho(bval=1., diffusion_time=80, TE=:min, slice_thickness=2)
+plot(sequence)
+save("dwi_1_80_min_2.png") # hide
+nothing # hide
+```
+![DWI sequence diagram with fixed diffusion time](dwi_1_80_min_2.png)
+
+We can even directly set some aspect of one of the sequence components, such as slowing down the gradient [`rise_time`](@ref)
+and the additional constraint will just be included in the [sequence optimisation](@ref sequence_optimisation):
+```@example
+using MRIBuilder # hide
+using CairoMakie # hide
+sequence = DiffusionSpinEcho(bval=1., diffusion_time=80, TE=:min, slice_thickness=2, gradient=(rise_time=15, ))
+plot(sequence)
+save("dwi_1_80_min_2_15.png") # hide
+nothing # hide
+```
+![DWI sequence diagram with fixed diffusion time and rise time](dwi_1_80_min_2_15.png)
+
+Note that the previous sequences do not contain a realistic readout.
+Most sequences will only include an instant readout, unless you directly set the [`voxel_size`](@ref) and [`resolution`](@ref).
+```@example
+using MRIBuilder # hide
+using CairoMakie # hide
+sequence = DiffusionSpinEcho(bval=1., diffusion_time=80, TE=:min, voxel_size=2, resolution=(20, 20, 20), gradient=(rise_time=15, ))
+plot(sequence)
+save("dwi_1_80_min_2_15_epi.png") # hide
+nothing # hide
+```
+![DWI sequence diagram with EPI readout](dwi_1_80_min_2_15_epi.png)
+
 ## Available sequences
 ```@meta
 CollapsedDocStrings = true
-- 
GitLab