From e896951f77b291a5092c12b2ffa20d8b6706b648 Mon Sep 17 00:00:00 2001
From: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
Date: Wed, 21 Feb 2024 14:57:44 +0000
Subject: [PATCH] Set different variables for both pulses

---
 src/parts/helper_functions.jl | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/parts/helper_functions.jl b/src/parts/helper_functions.jl
index 281d648..f62f347 100644
--- a/src/parts/helper_functions.jl
+++ b/src/parts/helper_functions.jl
@@ -187,12 +187,16 @@ function dwi_gradients(; type=:trapezoid, optimise=false, scanner=nothing, refoc
             :trapezoid => [:rise_time, :flat_time, :slew_rate],
         ), type, [])
     end
+
+    get_index(var::Union{Tuple, AbstractVector}, i) = length(var) == 2 ? var[i] : var
+    get_index(var::NamedTuple, i) = var
+    get_index(var, i) = var
+
     build_sequence(scanner; optimise=optimise) do 
         other_orientation = isnothing(orientation) ? nothing : (refocus ? orientation : -orientation)
-        (g1, g2) = (
-            func_dict[type](group=group, orientation=orientation, real_variables...),
-            func_dict[type](group=group, orientation=other_orientation, real_variables...)
-        )
+        (g1, g2) = [func_dict[type](;
+            group=group, orientation=o, Dict(key => get_index(value, i) for (key, value) in pairs(real_variables))...
+            ) for (i, o) in enumerate((orientation, other_orientation))]
         if !isnothing(orientation) || refocus
             apply_simple_constraint!(qval(g1), qval(g2))
         else
-- 
GitLab