Skip to content

Commit

Permalink
Merge pull request #3 from aTrotier/noClipExample
Browse files Browse the repository at this point in the history
No clip example
  • Loading branch information
aTrotier authored Nov 29, 2024
2 parents 9a9c44c + a8150a3 commit 1c60026
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,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.

0 comments on commit 1c60026

Please sign in to comment.