Skip to content

Commit

Permalink
Try using cos and sin instead of broadcasting exp over complex numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
rkierulf committed Jun 18, 2024
1 parent ef5bfc7 commit 7d2dc76
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function run_spin_precession!(
exp_argument1 = one_im .* ϕ
exp_argument2 = - tp' ./ p.T2
exp_argument = exp_argument1 .+ exp_argument2
exp_result = exp.(exp_argument)
exp_result = exp.(real.(exp_argument)) .* (cos.(imag.(exp_argument)) .+ Complex{T}(0,1) * sin.(imag.(exp_argument)))
elementwise_multiplication = M.xy .* exp_result
Mxy = [M.xy elementwise_multiplication] #This assumes Δw and T2 are constant in time
M.xy .= Mxy[:, end]
Expand Down
3 changes: 1 addition & 2 deletions KomaMRICore/src/simulation/Bloch/BlochSimulationMethod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ function run_spin_precession!(
exp_argument1 = one_im .* ϕ
exp_argument2 = - tp' ./ p.T2
exp_argument = exp_argument1 .+ exp_argument2
println(typeof(exp_argument))
exp_result = exp.(exp_argument)
exp_result = exp.(real.(exp_argument)) .* (cos.(imag.(exp_argument)) .+ Complex{T}(0,1) * sin.(imag.(exp_argument)))
elementwise_multiplication = M.xy .* exp_result
Mxy = [M.xy elementwise_multiplication]
M.xy .= Mxy[:, end]
Expand Down
2 changes: 1 addition & 1 deletion KomaMRICore/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ end
sim_params = KomaMRICore.default_sim_params()
sim_params["return_type"] = "mat"
sim_params["gpu"] = USE_GPU
sig = simulate(obj, seq, sys; sim_params)
sig = @suppress simulate(obj, seq, sys; sim_params)

# Test signal_to_raw_data
raw = signal_to_raw_data(sig, seq)
Expand Down

0 comments on commit 7d2dc76

Please sign in to comment.