Skip to content

Commit

Permalink
build based on 82045f2
Browse files Browse the repository at this point in the history
  • Loading branch information
Documenter.jl committed May 20, 2024
0 parents commit b7491d1
Show file tree
Hide file tree
Showing 410 changed files with 478,961 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI
on:
push:
paths-ignore:
- '*/*.md'
- 'docs/**'
pull_request:
paths-ignore:
- '*/*.md'
- 'docs/**'

jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.6'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
20 changes: 20 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CompatHelper
on:
schedule:
- cron: 0 0 * * 0 # weekly
workflow_dispatch:

jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} # need ssh
run: julia -e 'using CompatHelper; CompatHelper.main()'

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

on:
pull_request:
push:
branches:
- 'main'
- 'release-'
tags: '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: '1.6'
- name: Cache artifacts
uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: Install dependencies
run: |
julia --project=docs/ -e '
ENV["JULIA_PKG_SERVER"] = ""
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- name: BuildAndDeploy
env:
# https://juliadocs.github.io/Documenter.jl/stable/man/hosting/#Authentication:-GITHUB_TOKEN
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
run: julia --project=docs/ docs/make.jl
15 changes: 15 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Files generated by invoking Julia with --code-coverage
*.jl.cov
*.jl.*.cov

# Files generated by invoking Julia with --track-allocation
*.jl.mem

# System-specific files and directories generated by the BinaryProvider and BinDeps packages
# They contain absolute paths specific to the host computer, and so should not be committed
deps/deps.jl
deps/build.log
deps/downloads/
deps/usr/
deps/src/

# Build artifacts for creating documentation generated by the Documenter package
docs/build/
docs/site/

# File generated by Pkg, the package manager, based on a corresponding Project.toml
# It records a fixed state of all packages used by the project. As such, it should not be
# committed for packages, but should be committed for applications that require a static
# environment.
Manifest.toml

# other
.DS_Store
.*.*.swp
.benchmarkci
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Jeff Fessler

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
20 changes: 20 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name = "SPECTrecon"
uuid = "ab1be465-a7f0-4423-9048-0ee774b70ed9"
authors = ["Zongyu Li and Jeff Fessler and group"]
version = "0.0.1"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
ImageFiltering = "6a3955dd-da59-5b1f-98d4-e7296123deb5"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearInterpolators = "2fc109c4-9d77-11e9-32ff-e5c650334c16"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"

[compat]
AbstractFFTs = "1.0"
FFTW = "1.4"
ImageFiltering = "0.7"
LinearInterpolators = "0.1"
OffsetArrays = "1.10"
julia = "1.6"
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# SPECTrecon
SPECT image reconstruction tools in Julia

https://github.com/JeffFessler/SPECTrecon.jl

[![action status][action-img]][action-url]
[![pkgeval status][pkgeval-img]][pkgeval-url]
[![codecov][codecov-img]][codecov-url]
[![license][license-img]][license-url]
[![docs-stable][docs-stable-img]][docs-stable-url]
[![docs-dev][docs-dev-img]][docs-dev-url]
[![code-style][code-blue-img]][code-blue-url]
[![ColPrac: Contributor's Guide][colprac-img]][colprac-url]

This repo provides forward and back-projection methods
for SPECT image reconstruction.

Designed for use with the
[Michigan Image Reconstruction Toolbox (MIRT)](https://github.com/JeffFessler/MIRT.jl)
or similar frameworks.

Tested with Julia ≥ 1.6.

<!-- URLs -->
[action-img]: https://github.com/JeffFessler/SPECTrecon.jl/workflows/CI/badge.svg
[action-url]: https://github.com/JeffFessler/SPECTrecon.jl/actions
[build-img]: https://github.com/JeffFessler/SPECTrecon.jl/workflows/CI/badge.svg?branch=main
[build-url]: https://github.com/JeffFessler/SPECTrecon.jl/actions?query=workflow%3ACI+branch%3Amain
[pkgeval-img]: https://juliaci.github.io/NanosoldierReports/pkgeval_badges/S/SPECTrecon.svg
[pkgeval-url]: https://juliaci.github.io/NanosoldierReports/pkgeval_badges/S/SPECTrecon.html
[code-blue-img]: https://img.shields.io/badge/code%20style-blue-4495d1.svg
[code-blue-url]: https://github.com/invenia/BlueStyle
[codecov-img]: https://codecov.io/github/JeffFessler/SPECTrecon.jl/coverage.svg?branch=main
[codecov-url]: https://codecov.io/github/JeffFessler/SPECTrecon.jl?branch=main
[docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg
[docs-stable-url]: https://JeffFessler.github.io/SPECTrecon.jl/stable
[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg
[docs-dev-url]: https://JeffFessler.github.io/SPECTrecon.jl/dev
[license-img]: http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat
[license-url]: LICENSE
[colprac-img]: https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet
[colprac-url]: https://github.com/SciML/ColPrac
80 changes: 80 additions & 0 deletions accuracy/project.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# project.jl

using Main.SPECTrecon: SPECTplan, Workarray
using Main.SPECTrecon: project!
using MAT
using LazyAlgebra: vdot
using LinearAlgebra: norm
using Plots: plot

function project_error()
T = Float32
path = "./data/"
file = matopen(path*"mumap208.mat")
mumap = read(file, "mumap208")
close(file)

file = matopen(path*"psf_208.mat")
psfs = read(file, "psf_208")
close(file)

file = matopen(path*"xtrue.mat")
xtrue = convert(Array{Float32, 3}, read(file, "xtrue"))
close(file)

file = matopen(path*"proj_jeff_newmumap.mat")
proj_jeff = read(file, "proj_jeff")
close(file)

dy = T(4.7952)
nview = size(psfs, 4)

plan1d = SPECTplan(mumap, psfs, dy; interpidx = 1)
plan2d = SPECTplan(mumap, psfs, dy; interpidx = 2)

workarray1d = Vector{Workarray}(undef, plan1d.ncore)
workarray2d = Vector{Workarray}(undef, plan2d.ncore)

for i = 1:plan1d.ncore
workarray1d[i] = Workarray(plan1d.T, plan1d.imgsize, plan1d.pad_fft, plan1d.pad_rot) # allocate
end

for i = 1:plan2d.ncore
workarray2d[i] = Workarray(plan2d.T, plan2d.imgsize, plan2d.pad_fft, plan2d.pad_rot) # allocate
end


(nx, ny, nz) = size(xtrue)
nview = size(psfs, 4)

views1d = zeros(T, nx, nz, nview)
views2d = zeros(T, nx, nz, nview)

project!(views1d, xtrue, plan1d, workarray1d)
project!(views2d, xtrue, plan2d, workarray2d)

nrmse(x, xtrue) = norm(vec(x - xtrue)) / norm(vec(xtrue))

err1d = zeros(nview)
for idx = 1:nview
err1d[idx] = nrmse(views1d[:,:,idx], proj_jeff[:,:,idx])
end

err2d = zeros(nview)
for idx = 1:nview
err2d[idx] = nrmse(views2d[:,:,idx], proj_jeff[:,:,idx])
end

return err1d, err2d
# 1d interp: 1e-7 nrmse
# 2d interp: 4e-3 nrmse
end

# shows accuracy
err1d, err2d = project_error()
nrmse1d = sum(err1d) / length(err1d)
nrmse2d = sum(err2d) / length(err2d)
@show nrmse1d
@show nrmse2d
nothing
# plot(nrmse1d)
5 changes: 5 additions & 0 deletions accuracy/run_accuracy.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# run_accuracy.jl

using Main.SPECTrecon

include("project.jl")
1 change: 1 addition & 0 deletions dev/.documenter-siteinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"documenter":{"julia_version":"1.10.3","generation_timestamp":"2024-05-18T01:31:55","documenter_version":"1.4.1"}}
3 changes: 3 additions & 0 deletions dev/assets/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.docs-sourcelink {
opacity:1 !important;
}
Loading

0 comments on commit b7491d1

Please sign in to comment.