Skip to content

Commit

Permalink
rm volume fraction allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
Dale-Black committed Jun 5, 2024
1 parent 39e37d3 commit 36a6316
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CalciumScoring"
uuid = "9c0cb1da-21b1-4615-967b-153e03110a28"
authors = ["Dale <[email protected]> and contributors"]
version = "0.5.0"
version = "0.5.1"

[deps]
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Expand Down
68 changes: 28 additions & 40 deletions src/volume_fraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ the Hounsfield unit associated with a known calcium density `hu_calcium`, and th
unit associated with background heart tissue `hu_heart_tissue`
"""
function _percentage_calcium(voxel_intensity, hu_calcium, hu_heart_tissue)
return precentage_calcium = (voxel_intensity - hu_heart_tissue) / (hu_calcium - hu_heart_tissue)
return (voxel_intensity - hu_heart_tissue) / (hu_calcium - hu_heart_tissue)
end

"""
Expand Down Expand Up @@ -68,79 +68,67 @@ depending on the provided arguments.
[Coronary artery calcium mass measurement based on integrated intensity and volume fraction techniques](https://doi.org/10.1101/2023.01.12.23284482)
"""
function score(vol::AbstractMatrix, hu_calcium, hu_heart_tissue, alg::VolumeFraction)
number_calcium_voxels = Float64[]
calcium_score = 0.0
for i in axes(vol, 1)
for j in axes(vol, 2)
m = vol[i, j]
percent = _percentage_calcium(m, hu_calcium, hu_heart_tissue)
push!(number_calcium_voxels, percent)
for j in axes(vol, 2)
calcium_score += _percentage_calcium(vol[i, j], hu_calcium, hu_heart_tissue)
end
end
return sum(number_calcium_voxels)
return calcium_score
end

function score(vol::AbstractMatrix, hu_calcium, hu_heart_tissue, voxel_size, alg::VolumeFraction)
number_calcium_voxels = Float64[]
calcium_score = 0.0
for i in axes(vol, 1)
for j in axes(vol, 2)
m = vol[i, j]
percent = _percentage_calcium(m, hu_calcium, hu_heart_tissue)
push!(number_calcium_voxels, percent)
for j in axes(vol, 2)
calcium_score += _percentage_calcium(vol[i, j], hu_calcium, hu_heart_tissue)
end
end
return sum(number_calcium_voxels) * voxel_size
return calcium_score * voxel_size
end

function score(vol::AbstractMatrix, hu_calcium, hu_heart_tissue, voxel_size, density_calcium, alg::VolumeFraction)
number_calcium_voxels = Float64[]
calcium_score = 0.0
for i in axes(vol, 1)
for j in axes(vol, 2)
m = vol[i, j]
percent = _percentage_calcium(m, hu_calcium, hu_heart_tissue)
push!(number_calcium_voxels, percent)
for j in axes(vol, 2)
calcium_score += _percentage_calcium(vol[i, j], hu_calcium, hu_heart_tissue)
end
end
return sum(number_calcium_voxels) * voxel_size * density_calcium
return calcium_score * voxel_size * density_calcium
end

function score(vol::AbstractArray, hu_calcium, hu_heart_tissue, alg::VolumeFraction)
number_calcium_voxels = Float64[]
calcium_score = 0.0
for i in axes(vol, 1)
for j in axes(vol, 2)
for k in axes(vol, 3)
m = vol[i, j, k]
percent = _percentage_calcium(m, hu_calcium, hu_heart_tissue)
push!(number_calcium_voxels, percent)
for j in axes(vol, 2)
for k in axes(vol, 3)
calcium_score += _percentage_calcium(vol[i, j, k], hu_calcium, hu_heart_tissue)
end
end
end
return sum(number_calcium_voxels)
return calcium_score
end

function score(vol::AbstractArray, hu_calcium, hu_heart_tissue, voxel_size, alg::VolumeFraction)
number_calcium_voxels = Float64[]
calcium_score = 0.0
for i in axes(vol, 1)
for j in axes(vol, 2)
for k in axes(vol, 3)
m = vol[i, j, k]
percent = _percentage_calcium(m, hu_calcium, hu_heart_tissue)
push!(number_calcium_voxels, percent)
for j in axes(vol, 2)
for k in axes(vol, 3)
calcium_score += _percentage_calcium(vol[i, j, k], hu_calcium, hu_heart_tissue)
end
end
end
return sum(number_calcium_voxels) * voxel_size
return calcium_score * voxel_size
end

function score(vol::AbstractArray, hu_calcium, hu_heart_tissue, voxel_size, density_calcium, alg::VolumeFraction)
number_calcium_voxels = Float64[]
calcium_score = 0.0
for i in axes(vol, 1)
for j in axes(vol, 2)
for k in axes(vol, 3)
m = vol[i, j, k]
percent = _percentage_calcium(m, hu_calcium, hu_heart_tissue)
push!(number_calcium_voxels, percent)
for j in axes(vol, 2)
for k in axes(vol, 3)
calcium_score += _percentage_calcium(vol[i, j, k], hu_calcium, hu_heart_tissue)
end
end
end
return sum(number_calcium_voxels) * voxel_size * density_calcium
return calcium_score * voxel_size * density_calcium
end

2 comments on commit 36a6316

@Dale-Black
Copy link
Collaborator Author

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/108347

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.5.1 -m "<description of version>" 36a631630abc024dd3d0d02704964adddf24c2ff
git push origin v0.5.1

Please sign in to comment.