Skip to content

Commit

Permalink
serialdilution bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yufongpeng committed Jan 22, 2024
1 parent 15bddd0 commit bdac82a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/quantification.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ function analysistable(featuretable::Table; data = :area, method = nothing, defa
end

function rec_r2(id, conc, value, nlevel, r2_threshold, r2_current)
isnan(r2_current) && return (false, Int[], -Inf)
length(unique(conc)) < nlevel && return (false, Int[], -Inf)
r2 = cor(conc, value) ^ 2
r2 < r2_current && return (false, id, r2_current)
Expand Down Expand Up @@ -340,10 +341,12 @@ function run_serialdilution(signaltable::ChemistryQuantitativeAnalysis.AbstractD
batch = Batch(method)
nlevel = length(conctable)
Threads.@threads for cal in batch.calibration
@info "SerialDilution | $(cal.analyte[1]) starts"
_, id, _ = rec_r2(collect(eachindex(cal.table.x)), cal.table.x, cal.table.y, nlevel, r2_threshold, 0)
cal.table.include .= false
cal.table.include[id] .= true
update_calibration!(cal, method)
@info "SerialDilution | $(cal.analyte[1]) ends"
end
batch
end
Expand Down

0 comments on commit bdac82a

Please sign in to comment.