From 603a297184a4745b9e0dd054661a9db314e949d6 Mon Sep 17 00:00:00 2001 From: Stockless Date: Mon, 23 Dec 2024 13:26:21 -0300 Subject: [PATCH 1/4] first tets qMRIColors --- KomaMRIPlots/Project.toml | 2 ++ KomaMRIPlots/src/KomaMRIPlots.jl | 1 + KomaMRIPlots/src/ui/DisplayFunctions.jl | 38 ++++--------------------- 3 files changed, 9 insertions(+), 32 deletions(-) diff --git a/KomaMRIPlots/Project.toml b/KomaMRIPlots/Project.toml index eddc20610..ca942bccf 100644 --- a/KomaMRIPlots/Project.toml +++ b/KomaMRIPlots/Project.toml @@ -9,6 +9,7 @@ Kaleido_jll = "f7e6163d-2fa5-5f23-b69c-1db539e41963" KomaMRIBase = "d0bc0b20-b151-4d03-b2a4-6ca51751cb9c" MAT = "23992714-dd62-5051-b70f-ba57cb901cac" PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a" +QMRIColors = "2bec176e-9e8c-4764-a62f-295118d1ec05" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" [weakdeps] @@ -24,6 +25,7 @@ KomaMRIBase = "0.9" MAT = "0.10" PlotlyJS = "0.18" PlutoPlotly = "0.4, 0.5" +QMRIColors = "1.0.0" Reexport = "1" julia = "1.9" diff --git a/KomaMRIPlots/src/KomaMRIPlots.jl b/KomaMRIPlots/src/KomaMRIPlots.jl index ad46a4c24..5d8190f93 100644 --- a/KomaMRIPlots/src/KomaMRIPlots.jl +++ b/KomaMRIPlots/src/KomaMRIPlots.jl @@ -2,6 +2,7 @@ module KomaMRIPlots using KomaMRIBase using MAT, Interpolations, PlotlyJS +using QMRIColors include("ui/PlotBackends.jl") include("ui/DisplayFunctions.jl") diff --git a/KomaMRIPlots/src/ui/DisplayFunctions.jl b/KomaMRIPlots/src/ui/DisplayFunctions.jl index 5fce63a37..d4e2e83ad 100644 --- a/KomaMRIPlots/src/ui/DisplayFunctions.jl +++ b/KomaMRIPlots/src/ui/DisplayFunctions.jl @@ -981,10 +981,10 @@ function plot_kspace(seq::Sequence; width=nothing, height=nothing, darkmode=fals "orbitRotation", "resetCameraDefault3d", ], - ) - return plot_koma(p, l; config) -end - + ) + return plot_koma(p, l; config) + end + """ p = plot_phantom_map(obj::Phantom, key::Symbol; kwargs...) @@ -1080,38 +1080,12 @@ function plot_phantom_map( unit = " ms" if key == :T1 cmax_key = 2500 / factor - colors = MAT.matread(path * "/assets/T1cm.mat")["T1colormap"][1:70:end, :] - N, _ = size(colors) - idx = range(0, 1; length=N) #range(0,T,N) works in Julia 1.7 - colormap = [ - ( - idx[n], - string("rgb(", - floor(Int, colors[n,1] * 255), ",", - floor(Int, colors[n,2] * 255), ",", - floor(Int, colors[n,3] * 255), ")" - ) - ) - for n in 1:N - ] + colormap = relaxationColorMap("T1") elseif key == :T2 || key == :T2s if key == :T2 cmax_key = 250 / factor end - colors = MAT.matread(path * "/assets/T2cm.mat")["T2colormap"][1:70:end, :] - N, _ = size(colors) - idx = range(0, 1; length=N) #range(0,T,N) works in Julia 1.7 - colormap = [ - ( - idx[n], - string("rgb(", - floor(Int, colors[n,1] * 255), ",", - floor(Int, colors[n,2] * 255), ",", - floor(Int, colors[n,3] * 255), ")" - ) - ) - for n in 1:N - ] + colormap = relaxationColorMap("T2") end elseif key == :x || key == :y || key == :z factor = 1e2 From df05e28cc886d3bf9a6b0b5f9861afdb41b01131 Mon Sep 17 00:00:00 2001 From: Stockless Date: Mon, 23 Dec 2024 15:37:08 -0300 Subject: [PATCH 2/4] Change colormap from ".mat" file to QMRIColors.jl --- KomaMRIPlots/src/ui/DisplayFunctions.jl | 34 +++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/KomaMRIPlots/src/ui/DisplayFunctions.jl b/KomaMRIPlots/src/ui/DisplayFunctions.jl index d4e2e83ad..0f28ad4f3 100644 --- a/KomaMRIPlots/src/ui/DisplayFunctions.jl +++ b/KomaMRIPlots/src/ui/DisplayFunctions.jl @@ -1080,12 +1080,42 @@ function plot_phantom_map( unit = " ms" if key == :T1 cmax_key = 2500 / factor - colormap = relaxationColorMap("T1") + colors = relaxationColorMap("T1") + N = length(colors) + idx = range(0, 1; length=N) + + # Create the colormap + colormap = [ + ( + idx[n], + string("rgb(", + floor(Int, colors[n].r * 255), ",", + floor(Int, colors[n].g * 255), ",", + floor(Int, colors[n].b * 255), ")" + ) + ) + for n in 1:N + ] elseif key == :T2 || key == :T2s if key == :T2 cmax_key = 250 / factor end - colormap = relaxationColorMap("T2") + colors = relaxationColorMap("T2") + N = length(colors) + idx = range(0, 1; length=N) + + # Create the colormap + colormap = [ + ( + idx[n], + string("rgb(", + floor(Int, colors[n].r * 255), ",", + floor(Int, colors[n].g * 255), ",", + floor(Int, colors[n].b * 255), ")" + ) + ) + for n in 1:N + ] end elseif key == :x || key == :y || key == :z factor = 1e2 From 479f31791aa5cec0e9af61a9e83d1bf99f680cd2 Mon Sep 17 00:00:00 2001 From: Stockless Date: Mon, 23 Dec 2024 17:57:24 -0300 Subject: [PATCH 3/4] changed version specifier / corrected indentation / changed way of using of QMRIColors.jl --- KomaMRIPlots/Project.toml | 2 +- KomaMRIPlots/src/ui/DisplayFunctions.jl | 38 ++++++------------------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/KomaMRIPlots/Project.toml b/KomaMRIPlots/Project.toml index ca942bccf..ed535c75e 100644 --- a/KomaMRIPlots/Project.toml +++ b/KomaMRIPlots/Project.toml @@ -25,7 +25,7 @@ KomaMRIBase = "0.9" MAT = "0.10" PlotlyJS = "0.18" PlutoPlotly = "0.4, 0.5" -QMRIColors = "1.0.0" +QMRIColors = "1" Reexport = "1" julia = "1.9" diff --git a/KomaMRIPlots/src/ui/DisplayFunctions.jl b/KomaMRIPlots/src/ui/DisplayFunctions.jl index 0f28ad4f3..acae3bd34 100644 --- a/KomaMRIPlots/src/ui/DisplayFunctions.jl +++ b/KomaMRIPlots/src/ui/DisplayFunctions.jl @@ -1080,42 +1080,20 @@ function plot_phantom_map( unit = " ms" if key == :T1 cmax_key = 2500 / factor - colors = relaxationColorMap("T1") + colors = + replace.(string.(relaxationColorMap("T1") .* 255), "RGB{Float64}" => "rgb") N = length(colors) - idx = range(0, 1; length=N) - - # Create the colormap - colormap = [ - ( - idx[n], - string("rgb(", - floor(Int, colors[n].r * 255), ",", - floor(Int, colors[n].g * 255), ",", - floor(Int, colors[n].b * 255), ")" - ) - ) - for n in 1:N - ] + indices = range(0.0; stop=1.0, length=N) + colormap = [(idx, color) for (idx, color) in zip(indices, colors)] elseif key == :T2 || key == :T2s if key == :T2 cmax_key = 250 / factor end - colors = relaxationColorMap("T2") + colors = + replace.(string.(relaxationColorMap("T2") .* 255), "RGB{Float64}" => "rgb") N = length(colors) - idx = range(0, 1; length=N) - - # Create the colormap - colormap = [ - ( - idx[n], - string("rgb(", - floor(Int, colors[n].r * 255), ",", - floor(Int, colors[n].g * 255), ",", - floor(Int, colors[n].b * 255), ")" - ) - ) - for n in 1:N - ] + indices = range(0.0; stop=1.0, length=N) + colormap = [(idx, color) for (idx, color) in zip(indices, colors)] end elseif key == :x || key == :y || key == :z factor = 1e2 From de796fb984625320f4dd0b01ef21e999c76e548e Mon Sep 17 00:00:00 2001 From: Stockless Date: Mon, 23 Dec 2024 19:55:15 -0300 Subject: [PATCH 4/4] fixed indentation --- KomaMRIPlots/src/ui/DisplayFunctions.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/KomaMRIPlots/src/ui/DisplayFunctions.jl b/KomaMRIPlots/src/ui/DisplayFunctions.jl index acae3bd34..7ed1e63c4 100644 --- a/KomaMRIPlots/src/ui/DisplayFunctions.jl +++ b/KomaMRIPlots/src/ui/DisplayFunctions.jl @@ -980,11 +980,11 @@ function plot_kspace(seq::Sequence; width=nothing, height=nothing, darkmode=fals "resetCameraLastSave3d", "orbitRotation", "resetCameraDefault3d", - ], - ) - return plot_koma(p, l; config) - end - + ], + ) + return plot_koma(p, l; config) +end + """ p = plot_phantom_map(obj::Phantom, key::Symbol; kwargs...)