using SPECTrecon: RealU
using PyCall: pyimport

sci = pyimport("scipy.signal")

function gen_dvk(spect::AbstractArray{<:RealU, 3},
                 density::AbstractArray{<:RealU, 3},
                 kernel::AbstractArray{<:RealU, 3},
                 scale_factor_den::RealU,
                 scale_factor_dose::RealU)

        T = Float64
        spect_scale = T.(spect ./ sum(spect))
        density_scale = T.(density / scale_factor_den)
        tot_dose = max.(sci.fftconvolve(spect_scale, kernel, mode= "same"), 0)
        tot_dose = tot_dose .* 1.04 ./ (density_scale ./ 1000)
        tot_dose[(density_scale .< 100)] .= 0
        return Float32.(tot_dose * scale_factor_dose)
end
