From 99ee9e2163836a29c8e173ba0d12b9e26c894dcf Mon Sep 17 00:00:00 2001
From: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk>
Date: Thu, 1 Feb 2024 13:57:38 +0000
Subject: [PATCH] Add scale to RF pulses

---
 src/pulses/constant_pulses.jl | 7 +++++--
 src/pulses/instant_pulses.jl  | 6 ++++--
 src/pulses/sinc_pulses.jl     | 6 ++++--
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/pulses/constant_pulses.jl b/src/pulses/constant_pulses.jl
index c6e8b83..dc8bbb7 100644
--- a/src/pulses/constant_pulses.jl
+++ b/src/pulses/constant_pulses.jl
@@ -23,14 +23,17 @@ struct ConstantPulse <: RFPulseBlock
     duration :: VariableType
     phase :: VariableType
     frequency :: VariableType
+    scale :: Union{Nothing, Symbol}
 end
 
 @global_model_constructor ConstantPulse
 
-function ConstantPulse(model::Model; amplitude=nothing, duration=nothing, phase=nothing, frequency=nothing, kwargs...) 
+function ConstantPulse(model::Model; amplitude=nothing, duration=nothing, phase=nothing, frequency=nothing, scale=nothing, kwargs...) 
     res = ConstantPulse(
         model,
-        [get_free_variable(model, value) for value in (amplitude, duration, phase, frequency)]...
+        [get_free_variable(model, value) for value in (amplitude, duration, phase, frequency)]...,
+        scale
+
     )
     @constraint model res.amplitude >= 0
     set_simple_constraints!(model, res, kwargs)
diff --git a/src/pulses/instant_pulses.jl b/src/pulses/instant_pulses.jl
index 98f6825..fb49d0e 100644
--- a/src/pulses/instant_pulses.jl
+++ b/src/pulses/instant_pulses.jl
@@ -9,15 +9,17 @@ struct InstantRFPulseBlock <: RFPulseBlock
     model :: Model
     flip_angle :: VariableType
     phase :: VariableType
+    scale :: Union{Nothing, Symbol}
 end
 
 @global_model_constructor InstantRFPulseBlock
 
-function InstantRFPulseBlock(model::Model; flip_angle=nothing, phase=nothing) 
+function InstantRFPulseBlock(model::Model; flip_angle=nothing, phase=nothing, scale=nothing) 
     res = InstantRFPulseBlock(
         model,
         get_free_variable(model, flip_angle),
-        get_free_variable(model, phase)
+        get_free_variable(model, phase),
+        scale
     )
     @constraint model res.flip_angle >= 0
     return res
diff --git a/src/pulses/sinc_pulses.jl b/src/pulses/sinc_pulses.jl
index b6d8e9f..ecdcfe8 100644
--- a/src/pulses/sinc_pulses.jl
+++ b/src/pulses/sinc_pulses.jl
@@ -39,13 +39,14 @@ struct SincPulse <: RFPulseBlock
     phase :: VariableType
     frequency :: VariableType
     lobe_duration :: VariableType
+    scale :: Union{Nothing, Symbol}
 end
 
 @global_model_constructor SincPulse
 
 function SincPulse(model::Model; 
     symmetric=true, max_Nlobes=nothing, apodise=true, N_lobes=nothing, N_left=nothing, N_right=nothing, 
-    amplitude=nothing, phase=nothing, frequency=nothing, lobe_duration=nothing, kwargs...
+    amplitude=nothing, phase=nothing, frequency=nothing, lobe_duration=nothing, scale=nothing, kwargs...
 ) 
     if symmetric
         N_lobes = get_free_variable(model, N_lobes)
@@ -63,7 +64,8 @@ function SincPulse(model::Model;
         nlobe_integral_params(max_Nlobes, apodise),
         N_left_var,
         N_right_var,
-        [get_free_variable(model, value) for value in (amplitude, phase, frequency, lobe_duration)]...
+        [get_free_variable(model, value) for value in (amplitude, phase, frequency, lobe_duration)]...,
+        scale
     )
     @constraint model res.amplitude >= 0
     @constraint model res.N_left >= 1
-- 
GitLab