diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f6d9534..77d388b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -24,7 +24,6 @@ jobs: - ubuntu-latest arch: - x64 - - x86 steps: - uses: actions/checkout@v2 - uses: julia-actions/setup-julia@v1 diff --git a/src/DoseCalculationAlgorithms/DoseCalculationAlgorithms.jl b/src/DoseCalculationAlgorithms/DoseCalculationAlgorithms.jl index 166b46a..0b205ab 100644 --- a/src/DoseCalculationAlgorithms/DoseCalculationAlgorithms.jl +++ b/src/DoseCalculationAlgorithms/DoseCalculationAlgorithms.jl @@ -1,7 +1,7 @@ abstract type AbstractDoseAlgorithm end -include("ScaledIsoplaneKernel.jl") +#include("ScaledIsoplaneKernel.jl") include("FinitePencilBeamKernel.jl") """ diff --git a/src/DoseCalculationAlgorithms/FinitePencilBeamKernel.jl b/src/DoseCalculationAlgorithms/FinitePencilBeamKernel.jl index 5b357e3..919fc06 100644 --- a/src/DoseCalculationAlgorithms/FinitePencilBeamKernel.jl +++ b/src/DoseCalculationAlgorithms/FinitePencilBeamKernel.jl @@ -74,9 +74,9 @@ function FinitePencilBeamKernel(depths, parameters::AbstractMatrix, tanθ, scali @assert length(tanθ) == size(scalingfactor, 2) data = SVector{5}.(eachcol(parameters)) - params_interpolator = LinearInterpolation(depths, data, extrapolation_bc=Interpolations.Line()) + params_interpolator = linear_interpolation(depths, data, extrapolation_bc=Interpolations.Line()) - scalingfactor_interpolator = LinearInterpolation((depths, tanθ), scalingfactor, extrapolation_bc=Interpolations.Line()) + scalingfactor_interpolator = linear_interpolation((depths, tanθ), scalingfactor, extrapolation_bc=Interpolations.Line()) FinitePencilBeamKernel(params_interpolator, scalingfactor_interpolator) end diff --git a/src/DoseCalculationAlgorithms/ScaledIsoplaneKernel.jl b/src/DoseCalculationAlgorithms/ScaledIsoplaneKernel.jl index 3de51d8..71afe8e 100644 --- a/src/DoseCalculationAlgorithms/ScaledIsoplaneKernel.jl +++ b/src/DoseCalculationAlgorithms/ScaledIsoplaneKernel.jl @@ -1,6 +1,8 @@ -# -# Scaled Isoplane Kernel Algorithm -# +#= + (DISABLED) Scaled Isoplane Kernel Algorithm + +This has been temporarily disabled as it is incompatible with the current API +=# export ScaledIsoplaneKernel, kernel, norm_depth_dose, calibrate! @@ -37,10 +39,10 @@ function ScaledIsoplaneKernel(filename::String, max_kernel_radius; δsub=SVector # Interpolate onto uniform grid Δr = kernel_radius[2]-kernel_radius[1] r = kernel_radius[1]:Δr:kernel_radius[end] - K = LinearInterpolation(kernel_radius, kernel_value)(r) + K = linear_interpolation(kernel_radius, kernel_value)(r) # Create interpolation kernel - kernel = LinearInterpolation(r, K, extrapolation_bc=-Inf) + kernel = linear_interpolation(r, K, extrapolation_bc=-Inf) # Load Depth Dose Data pdd_depth = data["Depth Dose"]["Depth"] @@ -52,7 +54,7 @@ function ScaledIsoplaneKernel(filename::String, max_kernel_radius; δsub=SVector # Interpolate onto uniform grid Δd = pdd_depth[2]-pdd_depth[1] d = pdd_depth[1]:Δd:pdd_depth[end] - D = LinearInterpolation(pdd_depth, pdd_dose)(d) + D = linear_interpolation(pdd_depth, pdd_dose)(d) # Create interpolation PDD PDD = CubicSplineInterpolation(d, D, extrapolation_bc=Interpolations.Line()) diff --git a/src/DosePoints.jl b/src/DosePoints.jl index 516e91e..44e23d5 100644 --- a/src/DosePoints.jl +++ b/src/DosePoints.jl @@ -114,7 +114,7 @@ function within(bounds::MeshBounds, p) pmin, _ = extent(bounds) line = Segment(Point(pmin), Point(p)) - pI, _ = intersect_mesh(line, bounds.mesh) + pI = intersect_mesh(line, bounds.mesh) length(pI) % 2 != 0 end diff --git a/src/ExternalSurfaces.jl b/src/ExternalSurfaces.jl index 785d84c..740c0ba 100644 --- a/src/ExternalSurfaces.jl +++ b/src/ExternalSurfaces.jl @@ -116,7 +116,7 @@ getSSD(surf::MeshSurface, pos, src) = getSSD(surf, Point(pos), Point(src)) function getSSD(surf::MeshSurface, pos::Point, src::Point) line = Ray(src, pos-src) - pI, _ = intersect_mesh(line, surf.mesh) + pI = intersect_mesh(line, surf.mesh) length(pI)==0 && return Inf minimum(norm.(pI .- Ref(src))) end @@ -134,7 +134,7 @@ struct CylindricalSurface{Ty<:AbstractVector, Tϕ<:AbstractVector, Tdist<:Abstra distance::Tdist I::TInterpolation function CylindricalSurface(ϕ, y, rho) - I = LinearInterpolation((ϕ, y), rho) + I = linear_interpolation((ϕ, y), rho) new{typeof(ϕ), typeof(y), typeof(rho), typeof(I)}(ϕ, y, rho, I) end end @@ -165,7 +165,7 @@ function CylindricalSurface(mesh::SimpleMesh; Δϕ°=2., Δy=2.) src = Point(SAD*sin(ϕ[i]), y[j], SAD*cos(ϕ[i])) line = Ray(src, pos-src) - pI, _ = intersect_mesh(line, mesh) + pI = intersect_mesh(line, mesh) if length(pI)==0 ρᵢ = Inf else diff --git a/src/Structures.jl b/src/Structures.jl index 6f6c3da..52c0c1d 100644 --- a/src/Structures.jl +++ b/src/Structures.jl @@ -64,15 +64,13 @@ Single-threaded version of `intersect_mesh`. """ function intersect_mesh_single_threaded(line::Geometry, mesh::Domain{Dim, T}) where {Dim, T} intersection_points = Point{Dim, T}[] - intersection_cells = Geometry{Dim, T}[] for cell in mesh pt = intersect(line, cell) if(pt !== nothing) push!(intersection_points, pt) - push!(intersection_cells, cell) end end - intersection_points, intersection_cells + intersection_points end """ @@ -82,19 +80,16 @@ Multi-threaded version of `intersect_mesh`. """ function intersect_mesh_multi_threaded(line::Geometry, mesh::Domain{Dim, T}) where {Dim, T} intersection_points = Vector{Vector{Point{Dim, T}}}(undef, Threads.nthreads()) - intersection_cells = Vector{Vector{Geometry{Dim, T}}}(undef, Threads.nthreads()) for i=1:Threads.nthreads() intersection_points[i] = Point{Dim, T}[] - intersection_cells[i] = Geometry{Dim, T}[] end Threads.@threads for cell in mesh pt = intersect(line, cell) if(pt !== nothing) push!(intersection_points[Threads.threadid()], pt) - push!(intersection_cells[Threads.threadid()], cell) end end - vcat(intersection_points...), vcat(intersection_cells...) + vcat(intersection_points...) end #--- File IO ------------------------------------------------------------------ diff --git a/src/utils/interpolation.jl b/src/utils/interpolation.jl index 58f0f27..aa88e2e 100644 --- a/src/utils/interpolation.jl +++ b/src/utils/interpolation.jl @@ -53,7 +53,7 @@ locate(xg, yg, xi, yi) = CartesianIndex(locate(xg, xi), locate(yg, yi)) Interpolate `xi` within uniform grid positions `xg` and grid values `fg` """ Base.@propagate_inbounds function interp(xg::AbstractVector{T}, fg::AbstractVector{T}, xi) where T<:Real - LinearInterpolation(xg, fg, extrapolation_bc = Flat())(xi) + linear_interpolation(xg, fg, extrapolation_bc = Interpolations.Flat())(xi) end """ @@ -71,6 +71,6 @@ interp(f1, f2, α) = (1 - α)*f1 + α*f2 Bilinear interpolation at position `xi,yi`, on grid `xg-yg` with values `fg` """ Base.@propagate_inbounds function interp(xg::AbstractVector, yg::AbstractVector, fg::AbstractMatrix, xi, yi) - LinearInterpolation((xg, yg), fg, extrapolation_bc = Flat())(xi, yi) + linear_interpolation((xg, yg), fg, extrapolation_bc = Interpolations.Flat())(xi, yi) end diff --git a/test/CoordinateSystems.jl b/test/CoordinateSystems.jl index ff82bc5..a0a49fb 100644 --- a/test/CoordinateSystems.jl +++ b/test/CoordinateSystems.jl @@ -1,5 +1,3 @@ -using Meshes - @testset "CoordinateSystems" begin compare(v1, v2) = all(v1 .≈ v2) diff --git a/test/ExternalSurfaces.jl b/test/ExternalSurfaces.jl index 9a7f7e1..c397a19 100644 --- a/test/ExternalSurfaces.jl +++ b/test/ExternalSurfaces.jl @@ -1,5 +1,3 @@ -using Meshes, LinearAlgebra, StaticArrays, Rotations - #= Depth and SSD Calculation @@ -11,8 +9,7 @@ same ray line return the same SSD. Implemented Surfaces: - ConstantSurface - PlaneSurface - - MeshSurface (uses the same mesh and visual inspection as detailed in - test/meshes.jl) + - MeshSurface (uses the same mesh and visual inspection as detailed in meshes.jl) =# @testset "External Surfaces" begin @@ -80,7 +77,7 @@ Implemented Surfaces: end @testset "MeshSurface" begin - structure = load_structure_from_ply("test/test_mesh.stl") + structure = load_structure_from_ply("test_mesh.stl") surf = MeshSurface(structure) # Test 1 - Visually inspected for accuracy @@ -102,7 +99,7 @@ Implemented Surfaces: end @testset "Cylindrical Surface" begin - mesh = load_structure_from_ply("test/test_cylinder.stl") + mesh = load_structure_from_ply("test_cylinder.stl") surf = CylindricalSurface(mesh; Δϕ°=1., Δy=1.) meshsurf = MeshSurface(mesh) diff --git a/test/FinitePencilBeamKernel.jl b/test/FinitePencilBeamKernel.jl index e78614e..b85f642 100644 --- a/test/FinitePencilBeamKernel.jl +++ b/test/FinitePencilBeamKernel.jl @@ -1,7 +1,3 @@ -using LinearAlgebra -using QuadGK -using HCubature - @testset "Pencil Beam Profile" begin # Tests if profile is continuous @testset "Continuity" begin diff --git a/test/Jaws.jl b/test/Jaws.jl index 63637fb..b92f5d7 100644 --- a/test/Jaws.jl +++ b/test/Jaws.jl @@ -1,5 +1,3 @@ -using HDF5 - @testset "HDF5" begin jaws = Jaws(rand(2), rand(2)) diff --git a/test/Project.toml b/test/Project.toml index 731e250..43716be 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,3 +1,9 @@ [deps] HCubature = "19dc6840-f33b-545b-b366-655c7e3ffd49" +HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa" QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" +Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/ScaledIsoplaneKernel.jl b/test/ScaledIsoplaneKernel.jl index 8558214..de4c2fb 100644 --- a/test/ScaledIsoplaneKernel.jl +++ b/test/ScaledIsoplaneKernel.jl @@ -1,5 +1,8 @@ -using StaticArrays +#= + (DISABLED) Tests for the ScaledIsoplaneKernel Dose Calculation Algorithm +See src/DoseCalculationAlgorithms/ScaledIsoplaneKernel.jl +=# @testset "ScaledIsoplaneKernel" begin @testset "Sub-division" begin diff --git a/test/bixels.jl b/test/bixels.jl index 17f8d4f..8f3c02c 100644 --- a/test/bixels.jl +++ b/test/bixels.jl @@ -1,5 +1,3 @@ -using StaticArrays - @testset "Bixels" begin pos = SVector(1., 2.) diff --git a/test/interpolation.jl b/test/interpolation.jl index 8448699..c57e2b1 100644 --- a/test/interpolation.jl +++ b/test/interpolation.jl @@ -1,5 +1,3 @@ -using Test - rand_in_range(x1, x2) = (x2-x1)*rand() + x1 function test_grid(xg) @@ -39,12 +37,12 @@ function test_linear_interpolation(xg) xs = [0., 1.] - @testset "f[$(i[1])] == f($(xs[i[1]]))" for i in eachindex(fg) - @test fg[i] == interp(xg, fg, xs[i]) + @testset "f[$(i[1])] ≈ f($(xs[i[1]]))" for i in eachindex(fg) + @test fg[i] ≈ interp(xg, fg, xs[i]) end - @testset "avg(f) == f(0.5,0.5)" begin - @test sum(fg)/length(fg) == interp(xg, fg, 0.5) + @testset "avg(f) ≈ f(0.5,0.5)" begin + @test sum(fg)/length(fg) ≈ interp(xg, fg, 0.5) end end @@ -66,15 +64,15 @@ function test_bilinear_interpolation(xg) xs = [0., 1.] ys = [0., 1.] - @testset "f[$(i[1]),$(i[2])] == f($(xs[i[1]]),$(ys[i[2]]))" for i in CartesianIndices(fg) + @testset "f[$(i[1]),$(i[2])] ≈ f($(xs[i[1]]),$(ys[i[2]]))" for i in CartesianIndices(fg) xi = xs[i[1]] yi = ys[i[2]] fi = interp(xg, yg, fg, xi, yi) - @test fi == fg[i] + @test fi ≈ fg[i] end - @testset "avg(f) == f(0.5,0.5)" begin - @test sum(fg)/length(fg) == interp(xg, yg, fg, 0.5, 0.5) + @testset "avg(f) ≈ f(0.5,0.5)" begin + @test sum(fg)/length(fg) ≈ interp(xg, yg, fg, 0.5, 0.5) end end diff --git a/test/meshes.jl b/test/meshes.jl index 393409a..3964c3b 100644 --- a/test/meshes.jl +++ b/test/meshes.jl @@ -1,7 +1,3 @@ - -using Meshes -using LinearAlgebra - #= Mesh Intersections diff --git a/test/runtests.jl b/test/runtests.jl index f0054b7..cb86ce6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,10 @@ using Test using DoseCalculations using HDF5 +using StaticArrays +using Meshes +using LinearAlgebra, Rotations +using QuadGK, HCubature @testset "DoseCalculations" begin include("utils.jl") @@ -10,7 +14,7 @@ using HDF5 include("ExternalSurfaces.jl") include("meshes.jl") include("Fluence.jl") - include("ScaledIsoplaneKernel.jl") + #include("ScaledIsoplaneKernel.jl") # DISABLED, See src/DoseCalculationAlgorithms/ScaledIsoplaneKernel.jl include("MultiLeafCollimator.jl") include("MultiLeafCollimatorSequence.jl") end diff --git a/test/utils.jl b/test/utils.jl index 69ca241..e2290f7 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -6,7 +6,6 @@ function test_snapped_range(x1, x2, Δ) r = DoseCalculations.snapped_range(x1, x2, Δ) - print(r) @test r[1]<=x1 @test x2<=r[end] end