Skip to content

Commit c1d92a9

Browse files
authored
Merge branch 'master' into fix-599-colab-plots
2 parents 15d166d + 33dab33 commit c1d92a9

16 files changed

Lines changed: 436 additions & 259 deletions

File tree

KomaMRIBase/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "KomaMRIBase"
22
uuid = "d0bc0b20-b151-4d03-b2a4-6ca51751cb9c"
33

4-
version = "0.11.1"
4+
version = "0.11.2"
55
authors = ["Carlos Castillo Passi <cncastillo@uc.cl>"]
66

77
[workspace]

KomaMRIBase/src/motion/actions/simpleactions/Rotate.jl

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,39 +79,43 @@ get_center(center::CenterOfMass, x, y, z) = (sum(x) / length(x), sum(y) / length
7979
get_center(center::NTuple, x, y, z) = center
8080

8181
function displacement_x!(ux, action::Rotate, x, y, z, t)
82-
# Not using sind and cosd functions until bug with oneAPI is solved:
83-
# https://github.com/JuliaGPU/oneAPI.jl/issues/65
84-
α = t .* (action.yaw*π/180)
85-
β = t .* (action.roll*π/180)
86-
γ = t .* (action.pitch*π/180)
8782
cx, cy, cz = get_center(action.center, x, y, z)
88-
x0, y0, z0 = x .- cx, y .- cy, z .- cz
89-
ux .= cos.(α) .* cos.(β) .* x0 +
90-
(cos.(α) .* sin.(β) .* sin.(γ) .- sin.(α) .* cos.(γ)) .* y0 +
91-
(cos.(α) .* sin.(β) .* cos.(γ) .+ sin.(α) .* sin.(γ)) .* z0 .+ cx .- x
83+
α = deg2rad(action.yaw)
84+
β = deg2rad(action.roll)
85+
γ = deg2rad(action.pitch)
86+
87+
@. ux = cos* t) * cos* t) * (x - cx) +
88+
(cos* t) * sin* t) * sin* t) - sin* t) * cos* t)) * (y - cy) +
89+
(cos* t) * sin* t) * cos* t) + sin* t) * sin* t)) * (z - cz) +
90+
cx - x
91+
9292
return nothing
9393
end
9494

9595
function displacement_y!(uy, action::Rotate, x, y, z, t)
96-
α = t .* (action.yaw*π/180)
97-
β = t .* (action.roll*π/180)
98-
γ = t .* (action.pitch*π/180)
9996
cx, cy, cz = get_center(action.center, x, y, z)
100-
x0, y0, z0 = x .- cx, y .- cy, z .- cz
101-
uy .= sin.(α) .* cos.(β) .* x0 +
102-
(sin.(α) .* sin.(β) .* sin.(γ) .+ cos.(α) .* cos.(γ)) .* y0 +
103-
(sin.(α) .* sin.(β) .* cos.(γ) .- cos.(α) .* sin.(γ)) .* z0 .+ cy .- y
97+
α = deg2rad(action.yaw)
98+
β = deg2rad(action.roll)
99+
γ = deg2rad(action.pitch)
100+
101+
@. uy = sin* t) * cos* t) * (x - cx) +
102+
(sin* t) * sin* t) * sin* t) + cos* t) * cos* t)) * (y - cy) +
103+
(sin* t) * sin* t) * cos* t) - cos* t) * sin* t)) * (z - cz) +
104+
cy - y
105+
104106
return nothing
105107
end
106108

107109
function displacement_z!(uz, action::Rotate, x, y, z, t)
108-
α = t .* (action.yaw*π/180)
109-
β = t .* (action.roll*π/180)
110-
γ = t .* (action.pitch*π/180)
111110
cx, cy, cz = get_center(action.center, x, y, z)
112-
x0, y0, z0 = x .- cx, y .- cy, z .- cz
113-
uz .= -sin.(β) .* x0 +
114-
cos.(β) .* sin.(γ) .* y0 +
115-
cos.(β) .* cos.(γ) .* z0 .+ cz .- z
111+
α = deg2rad(action.yaw)
112+
β = deg2rad(action.roll)
113+
γ = deg2rad(action.pitch)
114+
115+
@. uz = -sin* t) * (x - cx) +
116+
cos* t) * sin* t) * (y - cy) +
117+
cos* t) * cos* t) * (z - cz) +
118+
cz - z
119+
116120
return nothing
117121
end

KomaMRICore/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "KomaMRICore"
22
uuid = "4baa4f4d-2ae9-40db-8331-a7d1080e3f4e"
33
authors = ["Carlos Castillo Passi <cncastillo@uc.cl>"]
4-
version = "0.11.1"
4+
version = "0.11.2"
55

66
[deps]
77
AcceleratedKernels = "6a4ca0a5-0e36-4168-a932-d9be78d558f1"

KomaMRICore/src/rawdata/ISMRMRD.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function signal_to_raw_data(
144144
"enc_lim_repetition" => Limit(0, 0, max_enc.REP), #min, max, center, e.g. dynamic number for dynamic scanning
145145
"enc_lim_set" => Limit(0, 0, max_enc.SET), #min, max, center, e.g. flow encoding set
146146
"enc_lim_segment" => Limit(0, 0, max_enc.SEG), #min, max, center, e.g. segment number for segmented acquisition
147-
"trajectory" => "other",
147+
"trajectory" => "custom",
148148
#sequenceParameters
149149
# "TR" => 0,
150150
# "TE" => 0,
@@ -264,4 +264,4 @@ Base.isapprox(sig1::RawAcquisitionData, sig2::RawAcquisitionData; kwargs...) = b
264264
end
265265

266266
return true
267-
end
267+
end

KomaMRICore/src/simulation/SimulatorCore.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,16 @@ macro maybe_time(verbose, expr)
271271
end
272272
end
273273

274+
function _assert_nonnegative_adc_labels(seq::Sequence)
275+
for (block, labels) in enumerate(get_labels(seq))
276+
for name in fieldnames(AdcLabels)
277+
value = getfield(labels, name)
278+
value < 0 && error("Negative ADC label found at block $block: `$name` with value `$value`.")
279+
end
280+
end
281+
return nothing
282+
end
283+
274284
"""
275285
out = simulate(obj::Phantom, seq::Sequence, sys::Scanner; sim_params, w)
276286
@@ -308,6 +318,7 @@ julia> plot_signal(raw)
308318
function simulate(
309319
obj::Phantom, seq::Sequence, sys::Scanner; sim_params=Dict{String,Any}(), verbose=true, callbacks=()
310320
)
321+
_assert_nonnegative_adc_labels(seq)
311322
#Simulation parameter unpacking, and setting defaults if key is not defined
312323
sim_params = default_sim_params(sim_params)
313324
#Warn if user is trying to run on CPU without enabling multi-threading

KomaMRICore/test/runtests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ end
218218
@test true
219219
end
220220

221+
@testitem "simulate rejects negative labels" tags=[:core, :nomotion] begin
222+
obj = Phantom(x=[0.0])
223+
seq = Sequence([Grad(0, 1e-3)])
224+
for label in (LabelSet(-1, "LIN"), LabelInc(-1, "LIN"))
225+
seq.EXT[1] = [label]
226+
@test_throws Exception simulate(obj, seq, Scanner(); verbose=false)
227+
end
228+
end
229+
221230
@testitem "Bloch" tags=[:important, :core, :nomotion, :bloch] begin
222231
include("initialize_backend.jl")
223232
include(joinpath(@__DIR__, "test_files", "utils.jl"))

docs/EmbeddPlotlyJSSyncPlotLiterate.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ function Base.show(io::IO, ::MIME"text/html", fig::PlotlyJS.SyncPlot)
2121
# Copy is required because we pop layout width/height for Plotly's inner JSON.
2222
# Mutating fig.plot directly would change size(fig) and user-visible behavior.
2323
plot = copy(fig.plot)
24+
plot.frames = fig.plot.frames
25+
plot.config = deepcopy(fig.plot.config)
26+
plot.config.displayModeBar = false
2427
default_width = layout_to_html_default_size!(plot.layout.fields, :width, get(plot.layout.fields, :width, nothing))
2528
default_height = layout_to_html_default_size!(plot.layout.fields, :height, get(plot.layout.fields, :height, nothing))
2629

2730
html_buffer = IOBuffer()
2831
PlotlyJS.PlotlyBase.to_html(
2932
html_buffer,
3033
plot;
34+
autoplay=false,
3135
full_html=true,
3236
include_plotlyjs="cdn",
3337
default_width=default_width,
-29.1 KB
Binary file not shown.

examples/3.tutorials/adiabatic_pulses/BIR4InversionB0B1.jl

Lines changed: 0 additions & 53 deletions
This file was deleted.

examples/3.tutorials/adiabatic_pulses/BIR4InversionProfile.jl

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)