Skip to content

Commit

Permalink
Merge pull request #536 from JuliaHealth/fix-motion-bugs
Browse files Browse the repository at this point in the history
Fix motion bugs and add `colorscale` keyword in `plot_image`
  • Loading branch information
cncastillo authored Feb 1, 2025
2 parents 64efca0 + adce005 commit ccb71b6
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion KomaMRIBase/src/motion/Action.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
abstract type AbstractAction{T<:Real} end

Base.:()(a1::AbstractAction, a2::AbstractAction) = (typeof(a1) == typeof(a2)) & reduce(&, [getfield(a1, field) getfield(a2, field) for field in fieldnames(typeof(a1))])
is_composable(m::AbstractAction) = false
is_composable(m::AbstractAction) = true

# Simple actions
include("actions/SimpleAction.jl")
Expand Down
2 changes: 1 addition & 1 deletion KomaMRIBase/src/motion/TimeCurve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ julia> periodic = Periodic(period=1.0, asymmetry=0.2)
```
![Periodic](../assets/periodic.svg)
"""
Periodic(period::T, asymmetry::T) where T = TimeCurve(t=[zero(T), period*asymmetry, period], t_unit=[zero(T), oneunit(T), zero(T)])
Periodic(period::T, asymmetry::T) where T = TimeCurve(t=[zero(T), period*asymmetry, period], t_unit=[zero(T), oneunit(T), zero(T)], periodic=true)
Periodic(; period=1.0, asymmetry=0.5) = Periodic(period, asymmetry)

""" Compare two TimeCurves """
Expand Down
2 changes: 0 additions & 2 deletions KomaMRIBase/src/motion/actions/simpleactions/HeartBeat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ julia> heartbeat = HeartBeat(circumferential_strain=-0.3, radial_strain=-0.2, lo
longitudinal_strain :: T
end

is_composable(action::HeartBeat) = true

function displacement_x!(ux, action::HeartBeat, x, y, z, t)
r = sqrt.(x .^ 2 + y .^ 2)
θ = atan.(y, x)
Expand Down
2 changes: 0 additions & 2 deletions KomaMRIBase/src/motion/actions/simpleactions/Rotate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ RotateX(pitch::T) where {T<:Real} = Rotate(pitch, zero(T), zero(T))
RotateY(roll::T) where {T<:Real} = Rotate(zero(T), roll, zero(T))
RotateZ(yaw::T) where {T<:Real} = Rotate(zero(T), zero(T), yaw)

is_composable(action::Rotate) = true

function displacement_x!(ux, action::Rotate, x, y, z, t)
# Not using sind and cosd functions until bug with oneAPI is solved:
# https://github.com/JuliaGPU/oneAPI.jl/issues/65
Expand Down
2 changes: 2 additions & 0 deletions KomaMRIBase/src/motion/actions/simpleactions/Translate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ TranslateX(dx::T) where {T<:Real} = Translate(dx, zero(T), zero(T))
TranslateY(dy::T) where {T<:Real} = Translate(zero(T), dy, zero(T))
TranslateZ(dz::T) where {T<:Real} = Translate(zero(T), zero(T), dz)

is_composable(m::Translate) = false

function displacement_x!(ux, action::Translate, x, y, z, t)
ux .= t.* action.dx
return nothing
Expand Down
3 changes: 2 additions & 1 deletion KomaMRIPlots/src/ui/DisplayFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ function plot_image(
zmax=maximum(image[:]),
darkmode=false,
title="",
colorscale="Greys"
)
#Layout
bgcolor, text_color, plot_bgcolor, grid_color, sep_color = theme_chooser(darkmode)
Expand Down Expand Up @@ -825,7 +826,7 @@ function plot_image(
l.width = width
end
#Plot
p = heatmap(; z=image, transpose=false, zmin=zmin, zmax=zmax, colorscale="Greys")
p = heatmap(; z=image, transpose=false, zmin=zmin, zmax=zmax, colorscale=colorscale)
config = PlotConfig(;
displaylogo=false,
toImageButtonOptions=attr(;
Expand Down

0 comments on commit ccb71b6

Please sign in to comment.