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

Illustrate mid3 with xticks in documentation #50

Merged
merged 5 commits into from
May 13, 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
40 changes: 34 additions & 6 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,48 @@
name: CompatHelper

on:
schedule:
- cron: 0 0 * * 0 # weekly
workflow_dispatch:

permissions:
contents: write
pull-requests: write
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
- name: Check if Julia is already available in the PATH
id: julia_in_path
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@latest
with:
version: '1'
# arch: ${{ runner.arch }}
if: steps.julia_in_path.outcome != 'success'
- name: "Add the General registry via Git"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
name = "CompatHelper"
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
version = "3"
Pkg.add(; name, uuid, version)
shell: julia --color=yes {0}
- name: "Run CompatHelper"
run: |
import CompatHelper
CompatHelper.main()
shell: julia --color=yes {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} # need ssh
run: julia -e 'using CompatHelper; CompatHelper.main()'
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}

# based on:
# https://github.com/JuliaRegistries/CompatHelper.jl
13 changes: 13 additions & 0 deletions .github/workflows/SpellCheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Spell Check

on: [pull_request]

jobs:
typos-check:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Check spelling
uses: crate-ci/typos@master
2 changes: 2 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: TagBot

on:
issue_comment:
types:
- created
workflow_dispatch:

jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
Expand Down
29 changes: 25 additions & 4 deletions docs/lit/examples/1-examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This page illustrates the Julia package

# Packages needed here.

using MIRTjim: jim, prompt
using MIRTjim: jim, prompt, mid3
using AxisArrays: AxisArray
using ColorTypes: RGB
using OffsetArrays: OffsetArray
Expand Down Expand Up @@ -71,7 +71,7 @@ jim(zo, "OffsetArray example")
=#

f3 = reshape(1:(9*7*6), (9, 7, 6))
jim(f3, "3D")
jim(f3, "3D"; size=(600, 300))


# One can specify how many images per row or column for such a mosaic.
Expand All @@ -80,7 +80,28 @@ x11 = reshape(1:(5*6*11), (5, 6, 11))
jim(x11, "nrow=3"; nrow=3)

#
jim(x11, "ncol=6"; ncol=6)
jim(x11, "ncol=6"; ncol=6, size=(600, 200))


#=
## Central slices with `mid3`
The `mid3` function shows the central x-y, y-z, and x-z slices
[(axial, coronal, sagittal) planes](https://en.wikipedia.org/wiki/Anatomical_plane).
Making useful `xticks` and `yticks` in this case takes some fiddling.
=#
x,y,z = -20:20, -10:10, 1:30
xc = reshape(x, :, 1, 1)
yc = reshape(y, 1, :, 1)
zc = reshape(z, 1, 1, :)
rx = reshape(range(2, 19, length(z)), size(zc))
ry = reshape(range(2, 9, length(z)), size(zc))
cone = @. abs2(xc / rx) + abs2(yc / ry) < 1
jim(mid3(cone); color=:cividis, title="mid3")
xticks = ([1, length(x), length(x)+length(z)],
["$(x[begin])", "$(x[end]), $(z[begin])", "$(z[end])"])
yticks = ([1, length(y), length(y)+length(z)],
["$(y[begin])", "$(y[end]), $(z[begin])", "$(z[end])"])
Plots.plot!(;xticks , yticks)


#=
Expand Down Expand Up @@ -115,7 +136,7 @@ jim(x, y, zu, "units" ;
x = range(-2,2,201) * 1u"m"
y = range(-1.2,1.2,150) * 1u"m" # Δy ≢ Δx
z = @. sqrt(x^2 + (y')^2) ≤ 1u"m"
jim(x, y, z, "Axis units with unequal spacing"; color=:cividis)
jim(x, y, z, "Axis units with unequal spacing"; color=:cividis, size=(600,350))


#=
Expand Down
3 changes: 2 additions & 1 deletion docs/lit/examples/2-yflip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ This is a typical convention in "image processing" of digital images
that lack any physical coordinates for their axes.
=#

ji = (args...; kwargs...) -> jim(args...; kwargs..., prompt=false)
ji = (args...; kwargs...) ->
jim(args...; size=(700,400), kwargs..., prompt=false)
jim(
ji(i1, "2D default"),
ji(i1, yflip=false, "2D yflip=false"),
Expand Down
10 changes: 5 additions & 5 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ execute = isempty(ARGS) || ARGS[1] == "run"

org, reps = :JeffFessler, :MIRTjim
eval(:(using $reps))
using Documenter
using Literate
import Documenter
import Literate

# https://juliadocs.github.io/Documenter.jl/stable/man/syntax/#@example-block
ENV["GKSwstype"] = "100"
Expand All @@ -23,7 +23,7 @@ binder_root_url =


repo = eval(:($reps))
DocMeta.setdocmeta!(repo, :DocTestSetup, :(using $reps); recursive=true)
Documenter.DocMeta.setdocmeta!(repo, :DocTestSetup, :(using $reps); recursive=true)

# preprocessing
inc1 = "include(\"../../../inc/reproduce.jl\")"
Expand Down Expand Up @@ -77,7 +77,7 @@ format = Documenter.HTML(;
assets = ["assets/custom.css"],
)

makedocs(;
Documenter.makedocs(;
modules = [repo],
authors = "Jeff Fessler and contributors",
sitename = "$repo.jl",
Expand All @@ -90,7 +90,7 @@ makedocs(;
)

if isci
deploydocs(;
Documenter.deploydocs(;
repo = "github.com/$base",
devbranch = "main",
devurl = "dev",
Expand Down
5 changes: 4 additions & 1 deletion src/MIRTjim.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""
Module `MIRTjim` exports the "jiffy image display" method `jim`,
and the two helper methods `caller_name` and `prompt`.
and the helper methods:
- `caller_name`
- `mid3`
- `prompt`
"""
module MIRTjim

Expand Down
6 changes: 4 additions & 2 deletions test/isplot.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Plots
using Test: @test

macro isplot(ex) # @isplot macro to streamline tests
:(@test $(esc(ex)) isa Plots.Plot)
if !isdefined(Main, Symbol("@isplot"))
macro isplot(ex) # @isplot macro to streamline tests
:(@test $(esc(ex)) isa Plots.Plot)
end
end
4 changes: 0 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ using MIRTjim

ENV["GKSwstype"] = "100"

macro isplot(ex) # @isplot macro to streamline tests
:(@test $(esc(ex)) isa Plots.Plot)
end

@testset "MIRTjim" begin
include("jim.jl")

Expand Down
Loading