Skip to content

Commit

Permalink
Merge pull request #85 from lmejn/feature/dose-recon
Browse files Browse the repository at this point in the history
Kernel Truncation in `reconstruct_dose`
  • Loading branch information
lmejn authored Oct 19, 2023
2 parents 7e365b2 + 83bc85d commit 12ecda7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Roentgen"
uuid = "b0d14063-c48a-4081-83d5-5a5ab48cb495"
authors = ["lmejn <[email protected]>"]
version = "0.13.3"
version = "0.13.4"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
27 changes: 15 additions & 12 deletions src/DoseReconstructions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,37 @@ export reconstruct_dose

"""
reconstruct_dose(vol::AbstractDoseVolume, plan::AbstractTreatmentPlan,
calc::AbstractDoseAlgorithm; Δx=5., show_progress=true)
calc::AbstractDoseAlgorithm; Δx=5., show_progress=true, maxradius=100.)
Dose reconstruction from a treatment plan.
Requires a dose volume (`vol`), a treatment plan (`plan`), and a dose calculation\
algorithm (`calc`).
Requires a dose volume (`vol`), a treatment plan (`plan`), and a dose calculation
algorithm (`calc`).
Optional arguments include:
- `Δx`: Size of each bixel in the fluence grid (defaults to 5.)
- `show_progress`: If true (default), displays the progress
- `maxradius`: Kernel truncation radius
"""
function reconstruct_dose(vol::AbstractDoseVolume, plan::AbstractTreatmentPlan,
calc::AbstractDoseAlgorithm; Δx=5., show_progress=true)
calc::AbstractDoseAlgorithm; Δx=5., show_progress=true, maxradius=100.)

pos = getpositions(vol)
surf = getsurface(vol)

dose = zeros(length(pos))
Ψ = zeros(1)

if(show_progress)
totalMU = 0.
progress = Progress(sum(length.(plan)))
end

# Iterate through each field in the plan
for field in plan

pos_fixed = patient_to_fixed(getisocenter(field)).(pos)

if(show_progress)
totalMU = 0.
p = Progress(length(field))
end

# Iterate through each control point in the field
for beam in field
ΔMU = getΔMU(beam)
Expand All @@ -51,14 +53,15 @@ function reconstruct_dose(vol::AbstractDoseVolume, plan::AbstractTreatmentPlan,
resize!(Ψ, nbixels)

dose .+= ΔMU*sum(dose_fluence_matrix(SparseMatrixCSC, vec(pos_fixed),
vec(beamlets), surf, calc);
vec(beamlets), surf, calc;
maxradius=maxradius);
dims=2)

if(show_progress)
next!(p; showvalues=[(:MU, totalMU+=ΔMU)])
next!(progress; showvalues=[(:MU, totalMU+=ΔMU)])
end

end

end
dose
end
2 changes: 1 addition & 1 deletion test/ExternalSurfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Implemented Surfaces:

from_cyl_coords(rho, ϕ, y) = SVector(rho*cos(ϕ), y, rho*sin(ϕ)) + pc

ρ_inside = rand()*ρᵢ
ρ_inside = 0.8*ρᵢ
ρ_outside = rand()+ρᵢ
y_inside = yᵢ
y_outside_m = y[1] - rand()
Expand Down

2 comments on commit 12ecda7

@lmejn
Copy link
Member Author

@lmejn lmejn commented on 12ecda7 Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/94193

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.13.4 -m "<description of version>" 12ecda713746ab5f72e16b73c03df8df99c76a9e
git push origin v0.13.4

Please sign in to comment.