Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No clip example #3

Merged
merged 4 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ cmap = relaxationColorMap("T1")
VIEW(x,c=cmap) # Do not use range limits here!
```
<p>Again, "VIEW" refers to your favorite viewing software.</p>
<p><br>If the simplified processing is invoked WITH use of range limits, then the
distinction is lost between invalid values and low-but-valid values. See second image in the
example below: it represents a circular object with a T1 value that is gradually increasing
from top to bottom, but only valid within a circular "object", the outside thereof representing
unknown T1 values. </p>

![image info](./rangeNoRange.jpg)
43 changes: 31 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 All @@ -49,8 +62,14 @@ end
Using GR backend
```@example 3
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"]

loLev = 700
Expand Down
Binary file added rangeNoRange.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading