Skip to content

Commit

Permalink
Retry: CairoMakie examples for clearer test object
Browse files Browse the repository at this point in the history
  • Loading branch information
mfuderer committed Nov 29, 2024
1 parent eee2982 commit 8c9deb7
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions docs/src/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,45 @@ The generated colormap can be easily integrated with multiple plotting library l
For `Makie.jl` the colormap can be directly used like `heatmap(x,colormap=cmap,colorrange=(loLev,upLev))`

```@example 2
using FileIO
using Downloads
using qMRIColors
using CairoMakie
url = "https://github.com/mfuderer/colorResources/raw/refs/heads/main/sampleT1map.jld"
dest_path = "sampleT1map.jld"
# Download the file
Downloads.download(url, dest_path)
x = FileIO.load("sampleT1map.jld")["sampleT1map"]
# ----- Make test object: gradually increasing T1, but invalid outside a circle
size = 256; center = size÷2+1; radius = 100; origin = CartesianIndex(center,center)
d(x::CartesianIndex, y::CartesianIndex) = √( (x[1]-y[1])^2 + (x[2]-y[2])^2 )
row = [10*i for i in 1:size]
testT1= zeros(size,size)
testT1 .= row
# Set invalid values to 0
allidx = CartesianIndices(testT1)
invalid = allidx[ d.(origin, allidx) .> radius];
testT1[invalid] .= 0
# ---------------------------------------------- Test object made
# -------------------- Display test object the correct and the wrong way
loLev = 700
upLev = 1500
cmap,imClip = relaxationColorMap("T1",x,loLev,upLev)
upLev = 2000
begin
f=CairoMakie.Figure()
ax=Axis(f[1,1],aspect = DataAspect(),title = "clip")
ax=Axis(f[1,1],aspect = DataAspect(),title = "Using imClip")
cmap,imClip = relaxationColorMap("T1",testT1,loLev,upLev)
h=heatmap!(ax,rotr90(imClip),colormap=cmap,colorrange=(loLev,upLev))
Colorbar(f[1,2],h)
hidedecorations!(ax)
ax=Axis(f[2,1],aspect = DataAspect(),title = "no clip")
h=heatmap!(ax,rotr90(x),colormap=cmap,colorrange=(loLev,upLev))
ax=Axis(f[2,1],aspect = DataAspect(),title = "wrong: simplified, \n with range")
cmap = relaxationColorMap("T1")
h=heatmap!(ax,rotr90(testT1),colormap=cmap,colorrange=(loLev,upLev))
Colorbar(f[2,2],h)
hidedecorations!(ax)
ax=Axis(f[3,1],aspect = DataAspect(),title = "OK: simplified, \n no range")
cmap = relaxationColorMap("T1")
h=heatmap!(ax,rotr90(testT1),colormap=cmap)
Colorbar(f[3,2],h)
hidedecorations!(ax)
# clean up plot
colsize!(f.layout, 1, Aspect(1,1))
resize_to_layout!(f)
Expand Down

0 comments on commit 8c9deb7

Please sign in to comment.