instedd / cdx

Connected Diagnostics Platform
https://cdx.io
9 stars 7 forks source link

Add Lod and Lob Caculation #1953

Closed bolom closed 1 year ago

bolom commented 1 year ago

This PR include caculation of Limit of Detection and Limit of blank. I've used the gem rumale

leandroradusky commented 1 year ago

Hi @bolom, besides the small comments I've left in the code, one thing to fix is that the new fields make the page structure of the PDF report to brake:

image

The fields should be organized into columns, please take as a reference the PDF for the boxes of purpose = Challenge, where more fields are informed and the confusion matrix fits completely into the first page:

image

bolom commented 1 year ago

et voila

bolom commented 1 year ago

@leandroradusky helped me last week to validate the calculations using some data. We could use the same data to create the test for calculating LOD and LOB.

concentrations [0, 10, 10, 10, 20, 0]
signal [10, 100.12, 193.5, 100.12, 193.5, 3.3]
Blank Sample size : 2
Limit of Detection: 17.651812199460668
Root Mean Square Error: 34.65889649273338
Limit of Blank: 14.443377388847534
Gray Zone: 14.443377388847534..17.651812199460668
leandroradusky commented 1 year ago

These numbers are ok to make a test :+1: (to test the function you will have to round them to three decimal places since we're returning the rounded number).

Still think thatrmse & gray zone should be removed from the function and calculate_lod & calculate_lod_and_lob should be merged into one function or at least renamed properly to reflect what they do before merging this PR.

leandroradusky commented 1 year ago

I continued the testing, is almost ready to merge. I've detected two things:

image

When this happens, and we try to create a report, the following error is thrown:

image

nil values should be ignored in the mapping to float.

bolom commented 1 year ago

@leandroradusky I've fixed the method and the indentation