diff --git a/analysis.jl b/analysis.jl index 2f4a3ea..169edb5 100644 --- a/analysis.jl +++ b/analysis.jl @@ -51,6 +51,9 @@ f_df = read(joinpath(root_dir, "F_0bpm.csv"), DataFrame); # ╔═╡ 72c80245-ba42-48d5-82ba-846feaa5f2b8 f_df_80, f_df_100, f_df_120 = groupby(f_df, :kV); +# ╔═╡ e49c64b7-6e74-4818-b939-6b80e36f0c30 +e_df + # ╔═╡ 9b72cccf-a2ae-4f41-a9a7-3266000cf265 f_df @@ -606,6 +609,11 @@ let f end +# ╔═╡ 4fa11f89-1b4f-497c-a676-96800b922895 +md""" +### (J) Density: 250 mg/cc, Diameter: 5.0mm +""" + # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] @@ -2147,10 +2155,11 @@ version = "3.5.0+0" # ╠═d4de246a-dbdd-4a37-9d91-c936e4a8c120 # ╠═ba29fa79-c096-4da9-b6db-61b8ff1d158a # ╠═72c80245-ba42-48d5-82ba-846feaa5f2b8 +# ╠═e49c64b7-6e74-4818-b939-6b80e36f0c30 # ╠═9b72cccf-a2ae-4f41-a9a7-3266000cf265 # ╟─9281994e-f515-4877-829c-2fadc7a1f9a4 # ╠═88f23085-659e-4ce1-92f0-37cbb46f4d48 -# ╠═3f325f9c-44c0-4b5c-b9f8-45451ad3f221 +# ╟─3f325f9c-44c0-4b5c-b9f8-45451ad3f221 # ╟─fb5641cc-e158-4181-9c6c-819733d044bb # ╟─2230a4ab-dc36-4392-8872-d38ce6d22024 # ╟─fe6af106-df3c-4439-ae86-75a77196dfdd @@ -2167,5 +2176,6 @@ version = "3.5.0+0" # ╟─73a5d15e-aa2e-41a3-9755-9162cf5c1f3c # ╟─ad2bc5af-404c-4dbb-8f18-8f8ec9c4737b # ╟─83eec244-0fb4-4a66-8e13-235374e9af69 +# ╟─4fa11f89-1b4f-497c-a676-96800b922895 # ╟─00000000-0000-0000-0000-000000000001 # ╟─00000000-0000-0000-0000-000000000002 diff --git a/data/D_0bpm.csv b/data/D_0bpm.csv index a95e8a0..007994e 100644 --- a/data/D_0bpm.csv +++ b/data/D_0bpm.csv @@ -1,31 +1,31 @@ insert_name,beats_per_minute,kV,mA,ctdi,gt_mass,vf_mass,agatston_mass -D,0bpm,80.0,10.0,0.1,2.3750440461138838,1.46215785057751,4.69633508697101 -D,0bpm,80.0,15.0,0.1,2.3750440461138838,1.0038084606402715,2.103610807863697 -D,0bpm,80.0,20.0,0.2,2.3750440461138838,3.196938303790263,3.6597001743528264 -D,0bpm,80.0,25.0,0.2,2.3750440461138838,1.0185166967188406,2.1242043282916163 -D,0bpm,80.0,30.0,0.2,2.3750440461138838,1.5132944580390386,1.3810537063574493 -D,0bpm,80.0,40.0,0.3,2.3750440461138838,2.1819947394321053,1.911668446035806 -D,0bpm,80.0,50.0,0.4,2.3750440461138838,1.3107983663016767,0.5684894772369821 -D,0bpm,80.0,100.0,0.8,2.3750440461138838,0.5362532965263064,0.0 -D,0bpm,80.0,150.0,1.2,2.3750440461138838,1.3215537836109466,0.0 -D,0bpm,80.0,250.0,2.0,2.3750440461138838,1.1218190401988557,0.0 -D,0bpm,100.0,10.0,0.2,2.3750440461138838,0.5292054529667822,2.535778279292405 -D,0bpm,100.0,15.0,0.2,2.3750440461138838,0.42399829003574113,0.637989970044053 -D,0bpm,100.0,20.0,0.3,2.3750440461138838,0.8515161564783575,0.47648704025824323 -D,0bpm,100.0,25.0,0.4,2.3750440461138838,0.5790939500444091,0.5493014870904905 -D,0bpm,100.0,30.0,0.5,2.3750440461138838,1.0792765718041994,0.4053066896923908 -D,0bpm,100.0,40.0,0.6,2.3750440461138838,0.15907478977099115,0.0 -D,0bpm,100.0,50.0,0.8,2.3750440461138838,1.7186004667119663,0.0 -D,0bpm,100.0,100.0,1.6,2.3750440461138838,1.109299443778566,0.09512845586813734 -D,0bpm,100.0,150.0,2.4,2.3750440461138838,0.4282177268537173,0.0 -D,0bpm,100.0,250.0,4.0,2.3750440461138838,1.3357052885898524,0.0 -D,0bpm,120.0,10.0,0.3,2.3750440461138838,-0.10929045127677273,1.1226453848152966 -D,0bpm,120.0,15.0,0.4,2.3750440461138838,0.15394684196587283,0.5241389308880795 -D,0bpm,120.0,20.0,0.5,2.3750440461138838,1.1802718280119493,0.0 -D,0bpm,120.0,25.0,0.6,2.3750440461138838,0.6612793604519056,0.09775897116823952 -D,0bpm,120.0,30.0,0.8,2.3750440461138838,0.7050154311303786,0.09431999192711987 -D,0bpm,120.0,40.0,1.0,2.3750440461138838,1.251038763602369,0.0 -D,0bpm,120.0,50.0,1.3,2.3750440461138838,1.1544241058930111,0.06022093348559148 -D,0bpm,120.0,100.0,2.5,2.3750440461138838,0.8134998995342753,0.0 -D,0bpm,120.0,150.0,3.8,2.3750440461138838,0.8864289739182626,0.0 -D,0bpm,120.0,250.0,6.3,2.3750440461138838,1.3211190581290895,0.0 +D,0bpm,80.0,10.0,0.1,2.3750440461138838,2.834775296484746,3.6109763038666958 +D,0bpm,80.0,15.0,0.1,2.3750440461138838,1.0306535377580055,3.4275140322743223 +D,0bpm,80.0,20.0,0.2,2.3750440461138838,0.3589961203879588,1.0577717301283094 +D,0bpm,80.0,25.0,0.2,2.3750440461138838,1.278914447958331,1.8736114606891945 +D,0bpm,80.0,30.0,0.2,2.3750440461138838,1.7099127920412416,1.3422984414303334 +D,0bpm,80.0,40.0,0.3,2.3750440461138838,0.49428626066176024,1.660145561929363 +D,0bpm,80.0,50.0,0.4,2.3750440461138838,1.9225102060014745,0.6355145941093971 +D,0bpm,80.0,100.0,0.8,2.3750440461138838,1.336156567352029,0.0 +D,0bpm,80.0,150.0,1.2,2.3750440461138838,1.3732481112970927,0.0 +D,0bpm,80.0,250.0,2.0,2.3750440461138838,1.4279114051755053,0.0 +D,0bpm,100.0,10.0,0.2,2.3750440461138838,0.9910485859382736,1.6566816069818184 +D,0bpm,100.0,15.0,0.2,2.3750440461138838,0.029029553027032848,0.5064553844782772 +D,0bpm,100.0,20.0,0.3,2.3750440461138838,2.9359827418357063,0.980843017040974 +D,0bpm,100.0,25.0,0.4,2.3750440461138838,1.6092049435686313,0.45150386021405314 +D,0bpm,100.0,30.0,0.5,2.3750440461138838,2.3650760722798476,0.11600275509483399 +D,0bpm,100.0,40.0,0.6,2.3750440461138838,2.1834771908695685,0.08927671907952968 +D,0bpm,100.0,50.0,0.8,2.3750440461138838,1.7041155259402943,0.0 +D,0bpm,100.0,100.0,1.6,2.3750440461138838,1.7191472982138405,0.0 +D,0bpm,100.0,150.0,2.4,2.3750440461138838,1.581582685984634,0.0 +D,0bpm,100.0,250.0,4.0,2.3750440461138838,1.4126398096775707,0.0 +D,0bpm,120.0,10.0,0.3,2.3750440461138838,3.378523476185992,2.1933485827633383 +D,0bpm,120.0,15.0,0.4,2.3750440461138838,2.3302225294074277,1.212792546718147 +D,0bpm,120.0,20.0,0.5,2.3750440461138838,1.873022445279064,0.14794698632667672 +D,0bpm,120.0,25.0,0.6,2.3750440461138838,2.0194605200479994,0.0 +D,0bpm,120.0,30.0,0.8,2.3750440461138838,2.2771691920707817,0.14519247561989396 +D,0bpm,120.0,40.0,1.0,2.3750440461138838,2.5412608107374246,0.12117639440048696 +D,0bpm,120.0,50.0,1.3,2.3750440461138838,1.1886084338755243,0.06128433420277664 +D,0bpm,120.0,100.0,2.5,2.3750440461138838,1.5273968757218075,0.0 +D,0bpm,120.0,150.0,3.8,2.3750440461138838,1.4754756662778608,0.0 +D,0bpm,120.0,250.0,6.3,2.3750440461138838,1.2454167286448994,0.0 diff --git a/data/E_0bpm.csv b/data/E_0bpm.csv index 46c73c1..c8392f3 100644 --- a/data/E_0bpm.csv +++ b/data/E_0bpm.csv @@ -1,31 +1,31 @@ -insert_name,beats_per_minute,kV,mA,ctdi,gt_mass,vf_mass,agatston_mass -E,0bpm,80.0,10.0,0.1,14.844025288211775,17.365055544992387,29.25820408543689 -E,0bpm,80.0,15.0,0.1,14.844025288211775,17.983980977540735,30.36795580600462 -E,0bpm,80.0,20.0,0.2,14.844025288211775,15.89969150502739,21.396290221889895 -E,0bpm,80.0,25.0,0.2,14.844025288211775,11.056194016347701,13.579596857695753 -E,0bpm,80.0,30.0,0.2,14.844025288211775,11.218512455411497,9.82702558407583 -E,0bpm,80.0,40.0,0.3,14.844025288211775,10.839493292871971,5.920321828890798 -E,0bpm,80.0,50.0,0.4,14.844025288211775,10.999238782227804,2.875605495848047 -E,0bpm,80.0,100.0,0.8,14.844025288211775,10.507851454549897,1.2119647405009304 -E,0bpm,80.0,150.0,1.2,14.844025288211775,10.57408489798957,0.12719390815054965 -E,0bpm,80.0,250.0,2.0,14.844025288211775,11.092264563709993,0.0 -E,0bpm,100.0,10.0,0.2,14.844025288211775,6.856769313662773,19.778398983748787 -E,0bpm,100.0,15.0,0.2,14.844025288211775,12.154702318366656,13.241930815848756 -E,0bpm,100.0,20.0,0.3,14.844025288211775,13.792007153260423,8.471003890120476 -E,0bpm,100.0,25.0,0.4,14.844025288211775,14.656577741107654,7.873256446111475 -E,0bpm,100.0,30.0,0.5,14.844025288211775,12.29515748228148,4.618919522145219 -E,0bpm,100.0,40.0,0.6,14.844025288211775,12.628836201613767,2.092635873943353 -E,0bpm,100.0,50.0,0.8,14.844025288211775,11.225189153772416,2.5303721321016175 -E,0bpm,100.0,100.0,1.6,14.844025288211775,12.622982932784037,1.2072896592444335 -E,0bpm,100.0,150.0,2.4,14.844025288211775,12.409859946151803,0.8140405677032598 -E,0bpm,100.0,250.0,4.0,14.844025288211775,11.987979878123747,0.2601593684681328 -E,0bpm,120.0,10.0,0.3,14.844025288211775,15.553824507928523,14.666305147298068 -E,0bpm,120.0,15.0,0.4,14.844025288211775,13.893554807542692,9.622335732678131 -E,0bpm,120.0,20.0,0.5,14.844025288211775,10.780362410082285,7.131761617313809 -E,0bpm,120.0,25.0,0.6,14.844025288211775,13.537563124943569,6.147861086657614 -E,0bpm,120.0,30.0,0.8,14.844025288211775,13.416421319913852,5.392292271504633 -E,0bpm,120.0,40.0,1.0,14.844025288211775,11.102057332469853,4.084728459041669 -E,0bpm,120.0,50.0,1.3,14.844025288211775,11.029760947736532,5.20958741387373 -E,0bpm,120.0,100.0,2.5,14.844025288211775,12.183247276327464,3.03528102544564 -E,0bpm,120.0,150.0,3.8,14.844025288211775,12.420967616511504,3.619433678240679 -E,0bpm,120.0,250.0,6.3,14.844025288211775,12.365175993115407,3.3664514992917676 +insert_name,beats_per_minute,kV,mA,ctdi,gt_mass,vf_mass,vf_mass_bkg_mean,vf_mass_bkg_std,agatston_mass,agatston_mass_bkg_mean,agatston_mass_bkg_std +E,0bpm,80.0,10.0,0.1,14.844025288211775,17.365055544992387,5.208956209501285,5.016376723048968,29.25820408543689,19.558913422190113,12.72503569223618 +E,0bpm,80.0,15.0,0.1,14.844025288211775,17.983980977540735,1.722977712418223,4.341024486226738,30.36795580600462,24.31345969330255,19.322198396153723 +E,0bpm,80.0,20.0,0.2,14.844025288211775,15.89969150502739,0.8826011900618821,4.576317501121545,21.396290221889895,11.31345728278617,10.088788450902069 +E,0bpm,80.0,25.0,0.2,14.844025288211775,11.056194016347701,-2.007014888978239,4.572023241345927,13.579596857695753,11.337040312335425,9.890009658194844 +E,0bpm,80.0,30.0,0.2,14.844025288211775,11.218512455411497,0.08039536849059248,4.601025458973848,9.82702558407583,7.483800953175354,7.034981326936466 +E,0bpm,80.0,40.0,0.3,14.844025288211775,10.839493292871971,-2.303925341967874,3.8200812977659266,5.920321828890798,3.402911197764402,2.9822220561488835 +E,0bpm,80.0,50.0,0.4,14.844025288211775,10.999238782227804,-0.6550376530090404,2.1891108742063947,2.875605495848047,1.467976668817877,1.5463144375882005 +E,0bpm,80.0,100.0,0.8,14.844025288211775,10.507851454549897,1.0216630535840714,2.6899387269366226,1.2119647405009304,0.09395777455977254,0.16273963930362853 +E,0bpm,80.0,150.0,1.2,14.844025288211775,10.57408489798957,0.23981694524379002,0.9777844751738513,0.12719390815054965,0.0,0.0 +E,0bpm,80.0,250.0,2.0,14.844025288211775,11.092264563709993,0.3537775628965938,1.25048951084745,0.0,0.0,0.0 +E,0bpm,100.0,10.0,0.2,14.844025288211775,6.856769313662773,1.405894157996484,1.9233462909768204,19.778398983748787,14.933934117707992,12.078234365527171 +E,0bpm,100.0,15.0,0.2,14.844025288211775,12.154702318366656,-1.2323178942268171,0.8541919502977428,13.241930815848756,7.299749634862889,6.305883783663464 +E,0bpm,100.0,20.0,0.3,14.844025288211775,13.792007153260423,-0.7669595833966237,0.2966856570690695,8.471003890120476,3.3571290002065406,2.978741955458063 +E,0bpm,100.0,25.0,0.4,14.844025288211775,14.656577741107654,-1.1621752380601607,1.3722321253643746,7.873256446111475,1.838827840839345,1.908240953980537 +E,0bpm,100.0,30.0,0.5,14.844025288211775,12.29515748228148,-1.9816359044052494,2.187426972216541,4.618919522145219,1.0088836445883802,1.2308260968082598 +E,0bpm,100.0,40.0,0.6,14.844025288211775,12.628836201613767,-0.4456617860207836,2.823199489063289,2.092635873943353,0.24796493424605917,0.24876101880401455 +E,0bpm,100.0,50.0,0.8,14.844025288211775,11.225189153772416,-0.506610885824307,1.9687323123251603,2.5303721321016175,0.06778615759815243,0.11740906900987111 +E,0bpm,100.0,100.0,1.6,14.844025288211775,12.622982932784037,0.36238053725171415,2.8430846786334616,1.2072896592444335,0.0,0.0 +E,0bpm,100.0,150.0,2.4,14.844025288211775,12.409859946151803,0.2080987570209638,1.7463285767070909,0.8140405677032598,0.0,0.0 +E,0bpm,100.0,250.0,4.0,14.844025288211775,11.987979878123747,-0.08167736659399276,1.7598717366754935,0.2601593684681328,0.0,0.0 +E,0bpm,120.0,10.0,0.3,14.844025288211775,15.553824507928523,0.24722233405166585,4.38858666337251,14.666305147298068,8.538725964990316,6.649950925337721 +E,0bpm,120.0,15.0,0.4,14.844025288211775,13.893554807542692,-0.05636307765248272,2.26798245053399,9.622335732678131,3.213480719410319,3.3982995919876697 +E,0bpm,120.0,20.0,0.5,14.844025288211775,10.780362410082285,1.5439134313661487,0.9724593832701425,7.131761617313809,1.1182855174029287,1.0378512953718615 +E,0bpm,120.0,25.0,0.6,14.844025288211775,13.537563124943569,0.43726777809710377,2.8323905368080347,6.147861086657614,0.6207365241477883,0.6748141234537581 +E,0bpm,120.0,30.0,0.8,14.844025288211775,13.416421319913852,-0.2664637710385274,3.4099173618231036,5.392292271504633,0.296725474265431,0.260556284015426 +E,0bpm,120.0,40.0,1.0,14.844025288211775,11.102057332469853,0.5077641109774365,1.0995818308960896,4.084728459041669,0.028768461062005726,0.04982843621496082 +E,0bpm,120.0,50.0,1.3,14.844025288211775,11.029760947736532,-0.4780710148669846,1.2703161650724264,5.20958741387373,0.09441248885424787,0.16352722756458765 +E,0bpm,120.0,100.0,2.5,14.844025288211775,12.183247276327464,-0.12780151797179073,1.319233399954167,3.03528102544564,0.0,0.0 +E,0bpm,120.0,150.0,3.8,14.844025288211775,12.420967616511504,-0.07926739403410461,1.7715732928063537,3.619433678240679,0.0,0.0 +E,0bpm,120.0,250.0,6.3,14.844025288211775,12.365175993115407,-0.23768276805421082,2.185405526044004,3.3664514992917676,0.0,0.0 diff --git a/measure_cac.jl b/measure_cac.jl index 8a106db..dc58111 100644 --- a/measure_cac.jl +++ b/measure_cac.jl @@ -252,6 +252,7 @@ md""" | 3082 | C_0bpm | 2-11 | 12-21 | 22-31 | | 3083 | F_0bpm | 2-11 | 12-21 | 22-31 | | 3087 | E_0bpm | 2-11 | 12-21 | 22-31 | + | 3093 | D_0bpm | 2-11 | 12-21 | 22-31 | """ # ╔═╡ d6670850-8f89-46fc-8db7-2617c58d656b @@ -299,7 +300,7 @@ function download_info(acc, ser, inst, save_folder_path) inputs = [ md""" $(acc): $( - Child(TextField(default="3089")) + Child(TextField(default="3093")) )""", md""" $(ser): $( Child(TextField(default="9")) @@ -759,9 +760,6 @@ elseif insert_name == "D" || insert_name == "E" || insert_name == "F" gt_density = 0.100 # mg/mm^3 end -# ╔═╡ 3d6adf79-8d1b-4ee3-b588-6bec6b80606a - - # ╔═╡ 0028adf1-cc3d-411a-875a-c7ebbb342500 ## Extract diameter if insert_name == "A" || insert_name == "D" @@ -776,10 +774,33 @@ end cylinder_rad = diameter * 2.0 # ╔═╡ d8519bec-6ae8-4575-80be-6b2bfcb3fc84 -cylinder = create_cylinder(dcm_heart, centers_a, centers_b, cylinder_rad, -25); +begin + cylinder = create_cylinder(dcm_heart, centers_a, centers_b, cylinder_rad, -25) + + + off_num = 30 + offa1 = (centers_a[1] + off_num, centers_a[2] + off_num, centers_a[3]) + offb1 = (centers_b[1] + off_num, centers_b[2] + off_num, centers_b[3]) + + offa2 = (centers_a[1] - off_num, centers_a[2] - off_num, centers_a[3]) + offb2 = (centers_b[1] - off_num, centers_b[2] - off_num, centers_b[3]) + + offa3 = (centers_a[1] + off_num, centers_a[2] - off_num, centers_a[3]) + offb3 = (centers_b[1] + off_num, centers_b[2] - off_num, centers_b[3]) + + offset_cylinder1 = create_cylinder(dcm_heart, offa1, offb1, cylinder_rad, -25) + offset_cylinder2 = create_cylinder(dcm_heart, offa2, offb2, cylinder_rad, -25) + offset_cylinder3 = create_cylinder(dcm_heart, offa3, offb3, cylinder_rad, -25) +end; # ╔═╡ 4b767984-077e-4801-bfdb-5297a4ea637d -cylinder_clean = remove_outliers(dcm_heart[cylinder]); +begin + cylinder_clean = remove_outliers(dcm_heart[cylinder]) + + offset_cylinder1_clean = remove_outliers(dcm_heart[offset_cylinder1]) + offset_cylinder2_clean = remove_outliers(dcm_heart[offset_cylinder2]) + offset_cylinder3_clean = remove_outliers(dcm_heart[offset_cylinder3]) +end; # ╔═╡ ad45ed1c-d103-449d-b8c4-49c56f465cde let @@ -795,28 +816,62 @@ end # ╔═╡ 5d301dd8-e23b-4156-8538-9c626b5a9b0b begin - _background_ring = create_cylinder(dcm_heart, centers_a, centers_b, cylinder_rad + 6, -25); - background_ring = Bool.(_background_ring .- cylinder) + background_ring = Bool.( + create_cylinder(dcm_heart, centers_a, centers_b, cylinder_rad + 6, -25) .- cylinder + ) + + offset_background_ring1 = Bool.( + create_cylinder(dcm_heart, offa1, offb1, cylinder_rad + 6, -25) .- offset_cylinder1 + ) + + offset_background_ring2 = Bool.( + create_cylinder(dcm_heart, offa2, offb2, cylinder_rad + 6, -25) .- offset_cylinder2 + ) + + offset_background_ring3 = Bool.( + create_cylinder(dcm_heart, offa3, offb3, cylinder_rad + 6, -25) .- offset_cylinder3 + ) end; # ╔═╡ 309b2a1b-9760-47e3-b0be-00cf1a8716f8 let idxs = getindex.(findall(isone, cylinder[:, :, z]), [1 2]) idxs_ring = getindex.(findall(isone, background_ring[:, :, z]), [1 2]) - α = 0.25 + alpha = 0.25 - f = Figure() + f = Figure(size = (800, 800)) - ax = Axis(f[1, 1]) + ax = Axis(f[1, 1], title = "Region Of Interest") heatmap!(dcm_arr[:, :, z]; colormap = :grays) - heatmap!(cylinder[:, :, z]; colormap = (:viridis, 0.2)) - heatmap!(background_ring[:, :, z]; colormap = (:jet, 0.2)) + heatmap!(cylinder[:, :, z]; colormap = (:viridis, alpha)) + heatmap!(background_ring[:, :, z]; colormap = (:jet, alpha)) + + ax = Axis(f[2, 1], title = "Offset Background 1") + heatmap!(dcm_arr[:, :, z]; colormap = :grays) + heatmap!(offset_cylinder1[:, :, z]; colormap = (:viridis, alpha)) + heatmap!(offset_background_ring1[:, :, z]; colormap = (:jet, alpha)) + + ax = Axis(f[1, 2], title = "Offset Background 2") + heatmap!(dcm_arr[:, :, z]; colormap = :grays) + heatmap!(offset_cylinder2[:, :, z]; colormap = (:viridis, alpha)) + heatmap!(offset_background_ring2[:, :, z]; colormap = (:jet, alpha)) + + ax = Axis(f[2, 2], title = "Offset Background 3") + heatmap!(dcm_arr[:, :, z]; colormap = :grays) + heatmap!(offset_cylinder3[:, :, z]; colormap = (:viridis, alpha)) + heatmap!(offset_background_ring3[:, :, z]; colormap = (:jet, alpha)) f end # ╔═╡ b483e08a-3970-4825-b548-4b7a8026aeed -background_clean = remove_outliers(dcm_heart[background_ring]); +begin + background_clean = remove_outliers(dcm_heart[background_ring]) + + offset_background_ring1_clean = remove_outliers(dcm_heart[offset_background_ring1]) + offset_background_ring2_clean = remove_outliers(dcm_heart[offset_background_ring2]) + offset_background_ring3_clean = remove_outliers(dcm_heart[offset_background_ring3]) +end; # ╔═╡ 6a9ab52a-2586-4d48-b035-7c7ec9ff7220 num_inserts = 3 @@ -849,12 +904,33 @@ std(dcm_heart[binary_calibration]) voxel_size = pixel_size[1] * pixel_size[2] * pixel_size[3] # ╔═╡ 79bc8e94-1568-49c2-a9c8-55b52427cbd1 -# hu_heart_tissue_bkg = mean(dcm_heart[background_ring]) -hu_heart_tissue_bkg = mean(background_clean) +begin + hu_heart_tissue_bkg = mean(background_clean) + + hu_heart_tissue_bkg_offset1 = mean(offset_background_ring1_clean) + hu_heart_tissue_bkg_offset2 = mean(offset_background_ring2_clean) + hu_heart_tissue_bkg_offset3 = mean(offset_background_ring3_clean) +end; # ╔═╡ 3163ccbd-e53f-42a9-9fa3-7fb5430104b7 vf_mass = score(cylinder_clean, hu_calcium_400, hu_heart_tissue_bkg, voxel_size, ρ_calcium_400, VolumeFraction()) +# ╔═╡ d9f8d148-0df8-4226-98e0-c24fec499553 +begin + vf_mass_offset1 = score(offset_cylinder1_clean, hu_calcium_400, hu_heart_tissue_bkg_offset1, voxel_size, ρ_calcium_400, VolumeFraction()) + vf_mass_offset2 = score(offset_cylinder2_clean, hu_calcium_400, hu_heart_tissue_bkg_offset2, voxel_size, ρ_calcium_400, VolumeFraction()) + vf_mass_offset3 = score(offset_cylinder3_clean, hu_calcium_400, hu_heart_tissue_bkg_offset3, voxel_size, ρ_calcium_400, VolumeFraction()) +end; + +# ╔═╡ fd18ea3a-fdf4-4bfa-827c-fe27cd8fd1af +begin + vf_mass_bkg_mean = mean([vf_mass_offset1, vf_mass_offset2, vf_mass_offset3]) + vf_mass_bkg_std = std([vf_mass_offset1, vf_mass_offset2, vf_mass_offset3]) +end; + +# ╔═╡ 78a2827c-95cc-490d-a35a-ad390849ab90 +vf_mass_bkg_mean, vf_mass_bkg_std + # ╔═╡ f361009d-ce57-43dd-bde3-b27f20cd38df md""" ## Agatston @@ -866,9 +942,25 @@ mass_cal_factor = ρ_calcium_400 / hu_calcium_400 # ╔═╡ 66fbeffb-9012-43c2-b5b5-e96e0fd75e7e a_agatston, a_volume, a_mass = score(cylinder_clean, pixel_size, mass_cal_factor, Agatston(); kV=kV) +# ╔═╡ 20cf0cfc-ee39-4abb-b721-c531bb4b4013 +begin + _, _, a_mass_offset1 = score(offset_cylinder1_clean, pixel_size, mass_cal_factor, Agatston(); kV=kV) + _, _, a_mass_offset2 = score(offset_cylinder2_clean, pixel_size, mass_cal_factor, Agatston(); kV=kV) + _, _, a_mass_offset3 = score(offset_cylinder3_clean, pixel_size, mass_cal_factor, Agatston(); kV=kV) +end; + +# ╔═╡ 458a7ead-d58b-45d0-9248-235d0c3dfd07 +begin + a_mass_bkg_mean = mean([a_mass_offset1, a_mass_offset2, a_mass_offset3]) + a_mass_bkg_std = std([a_mass_offset1, a_mass_offset2, a_mass_offset3]) +end; + # ╔═╡ 6fc57bee-0130-4624-b8f9-2b9f650b1e73 a_mass +# ╔═╡ 78b4440d-bc8a-4742-819c-3f2d5bffa7a0 +a_mass_bkg_mean, a_mass_bkg_std + # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] @@ -2778,7 +2870,6 @@ version = "3.5.0+0" # ╠═bc8312ed-4958-4362-b96c-fbb60ecfd8a9 # ╠═835c6d36-708b-4f32-91df-33ec0abcb993 # ╠═e71b73be-4ac0-4aff-a13b-516f812c606f -# ╠═3d6adf79-8d1b-4ee3-b588-6bec6b80606a # ╠═0028adf1-cc3d-411a-875a-c7ebbb342500 # ╠═6a9ab52a-2586-4d48-b035-7c7ec9ff7220 # ╠═f231a0cc-1f9d-4bb0-b016-fe8e29357099 @@ -2791,9 +2882,15 @@ version = "3.5.0+0" # ╠═aae1984d-c2ec-4ffc-97f0-55a64017387c # ╠═79bc8e94-1568-49c2-a9c8-55b52427cbd1 # ╠═3163ccbd-e53f-42a9-9fa3-7fb5430104b7 +# ╠═d9f8d148-0df8-4226-98e0-c24fec499553 +# ╠═fd18ea3a-fdf4-4bfa-827c-fe27cd8fd1af +# ╠═78a2827c-95cc-490d-a35a-ad390849ab90 # ╟─f361009d-ce57-43dd-bde3-b27f20cd38df # ╠═906e5abb-4bdf-4fd8-916e-c97644b97fa6 # ╠═66fbeffb-9012-43c2-b5b5-e96e0fd75e7e +# ╠═20cf0cfc-ee39-4abb-b721-c531bb4b4013 +# ╠═458a7ead-d58b-45d0-9248-235d0c3dfd07 # ╠═6fc57bee-0130-4624-b8f9-2b9f650b1e73 +# ╠═78b4440d-bc8a-4742-819c-3f2d5bffa7a0 # ╟─00000000-0000-0000-0000-000000000001 # ╟─00000000-0000-0000-0000-000000000002 diff --git a/measure_cac_script.jl b/measure_cac_script.jl index 97dbb14..9d0b036 100644 --- a/measure_cac_script.jl +++ b/measure_cac_script.jl @@ -596,21 +596,12 @@ md""" !!! info "" See `README.md` in the root directory for more info on the scans - NEED RESCAN: - - | Accession Number | Scan Name | Series (80 kV) | Series (100 kV) | Series (120 kV) | - | ---------------- | --------- | -------------- | --------------- | --------------- | - | 3074 | A_0bpm | 2-11 | 12-21 | 22-31 | - | 3075 | B_0bpm | 2-11 | 12-21 | 22-31 | - | 3089 | D_0bpm | 2-11 | 12-21 | 22-31 | - - Good: - | Accession Number | Scan Name | Series (80 kV) | Series (100 kV) | Series (120 kV) | | ---------------- | --------- | -------------- | --------------- | --------------- | | 3082 | C_0bpm | 2-11 | 12-21 | 22-31 | | 3083 | F_0bpm | 2-11 | 12-21 | 22-31 | | 3087 | E_0bpm | 2-11 | 12-21 | 22-31 | + | 3095 | D_0bpm | 2-11 | 12-21 | 22-31 | """ # ╔═╡ 4f0f5767-5c26-4ae4-a28c-20ca9ed986ee @@ -658,7 +649,7 @@ function download_info(acc, ser, inst, save_folder_path) inputs = [ md""" $(acc): $( - Child(TextField(default="3089")) + Child(TextField(default="3087")) )""", md""" $(ser): $( Child(TextField(default="2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31")) @@ -709,34 +700,35 @@ instance_number = parse(Int64, instance_num) # ╔═╡ d60685cd-846f-4591-9908-2f2275a193d0 instances_dicts -# ╔═╡ 8e3fc2b5-18d0-4bce-bf74-5a7b56d61457 +# ╔═╡ 08e918cd-0032-4f8e-be16-84f2b19d8291 md""" # Run Script """ -# ╔═╡ 19b23f93-48b3-4c39-bcee-32b03d4f6f50 +# ╔═╡ b22040f6-5726-4551-af1d-b65ae876e83c begin - results_df = DataFrame( - insert_name = String[], - beats_per_minute = String[], + results_df = DataFrame( + insert_name = String[], + beats_per_minute = String[], kV = Float64[], - mA = Float64[], + mA = Float64[], ctdi = Float64[], - gt_mass = Float64[], - vf_mass = Float64[], - agatston_mass = Float64[] - ) + gt_mass = Float64[], + vf_mass = Float64[], + vf_mass_bkg_mean = Float64[], + vf_mass_bkg_std = Float64[], + agatston_mass = Float64[], + agatston_mass_bkg_mean = Float64[], + agatston_mass_bkg_std = Float64[] + ) local insert_name local beats_per_minute - for (i, dicts) in enumerate(instances_dicts) + for (i, dicts) in enumerate(instances_dicts) @info i - @info dicts - output_paths = process_instances([dicts], series_num_vec[i], output_dir, instance_number, ip_address) output_path = output_paths[end] - @info output_path # Load DICOMs dcms = dcmdir_parse(output_path) @@ -792,6 +784,31 @@ begin cylinder_clean = remove_outliers(dcm_heart[cylinder]) background_clean = remove_outliers(dcm_heart[background_ring]) + # Offset Measurements + off_num = 30 + offa1 = (centers_a[1] + off_num, centers_a[2] + off_num, centers_a[3]) + offb1 = (centers_b[1] + off_num, centers_b[2] + off_num, centers_b[3]) + offa2 = (centers_a[1] - off_num, centers_a[2] - off_num, centers_a[3]) + offb2 = (centers_b[1] - off_num, centers_b[2] - off_num, centers_b[3]) + offa3 = (centers_a[1] + off_num, centers_a[2] - off_num, centers_a[3]) + offb3 = (centers_b[1] + off_num, centers_b[2] - off_num, centers_b[3]) + + offset_cylinder1 = create_cylinder(dcm_heart, offa1, offb1, cylinder_rad, -25) + offset_cylinder2 = create_cylinder(dcm_heart, offa2, offb2, cylinder_rad, -25) + offset_cylinder3 = create_cylinder(dcm_heart, offa3, offb3, cylinder_rad, -25) + + offset_background_ring1 = Bool.(create_cylinder(dcm_heart, offa1, offb1, background_rad, -25) .- offset_cylinder1) + offset_background_ring2 = Bool.(create_cylinder(dcm_heart, offa2, offb2, background_rad, -25) .- offset_cylinder2) + offset_background_ring3 = Bool.(create_cylinder(dcm_heart, offa3, offb3, background_rad, -25) .- offset_cylinder3) + + offset_cylinder1_clean = remove_outliers(dcm_heart[offset_cylinder1]) + offset_cylinder2_clean = remove_outliers(dcm_heart[offset_cylinder2]) + offset_cylinder3_clean = remove_outliers(dcm_heart[offset_cylinder3]) + + offset_background_ring1_clean = remove_outliers(dcm_heart[offset_background_ring1]) + offset_background_ring2_clean = remove_outliers(dcm_heart[offset_background_ring2]) + offset_background_ring3_clean = remove_outliers(dcm_heart[offset_background_ring3]) + # Ground truth mass num_inserts = 3 gt_length = 7 # mm @@ -806,31 +823,48 @@ begin ## Calculate voxel_size = pixel_size[1] * pixel_size[2] * pixel_size[3] hu_heart_tissue_bkg = mean(background_clean) + hu_heart_tissue_bkg_offset1 = mean(offset_background_ring1_clean) + hu_heart_tissue_bkg_offset2 = mean(offset_background_ring2_clean) + hu_heart_tissue_bkg_offset3 = mean(offset_background_ring3_clean) + vf_mass = score(cylinder_clean, hu_calcium_400, hu_heart_tissue_bkg, voxel_size, ρ_calcium_400, VolumeFraction()) + vf_mass_offset1 = score(offset_cylinder1_clean, hu_calcium_400, hu_heart_tissue_bkg_offset1, voxel_size, ρ_calcium_400, VolumeFraction()) + vf_mass_offset2 = score(offset_cylinder2_clean, hu_calcium_400, hu_heart_tissue_bkg_offset2, voxel_size, ρ_calcium_400, VolumeFraction()) + vf_mass_offset3 = score(offset_cylinder3_clean, hu_calcium_400, hu_heart_tissue_bkg_offset3, voxel_size, ρ_calcium_400, VolumeFraction()) + + vf_mass_bkg_mean = mean([vf_mass_offset1, vf_mass_offset2, vf_mass_offset3]) + vf_mass_bkg_std = std([vf_mass_offset1, vf_mass_offset2, vf_mass_offset3]) # Agatston mass_cal_factor = ρ_calcium_400 / hu_calcium_400 agatston_agatston, agatston_volume, agatston_mass = score(cylinder_clean, pixel_size, mass_cal_factor, Agatston(); kV=kV) - - @info vf_mass, agatston_mass + + _, _, agatston_mass_offset1 = score(offset_cylinder1_clean, pixel_size, mass_cal_factor, Agatston(); kV=kV) + _, _, agatston_mass_offset2 = score(offset_cylinder2_clean, pixel_size, mass_cal_factor, Agatston(); kV=kV) + _, _, agatston_mass_offset3 = score(offset_cylinder3_clean, pixel_size, mass_cal_factor, Agatston(); kV=kV) + + agatston_mass_bkg_mean = mean([agatston_mass_offset1, agatston_mass_offset2, agatston_mass_offset3]) + agatston_mass_bkg_std = std([agatston_mass_offset1, agatston_mass_offset2, agatston_mass_offset3]) + + @info """ + Ground Truth Mass: $(gt_mass) \n + Volume Fraction Mass: $(vf_mass) \n + Volume Fraction Background Mass Mean + Std: $((vf_mass_bkg_mean, vf_mass_bkg_std)) \n + Agatston Mass: $(agatston_mass) \n + Agatston Background Mass Mean + Std: $((agatston_mass_bkg_mean, agatston_mass_bkg_std)) + """ # Push results to DataFrame - push!(results_df, [insert_name, beats_per_minute, kV, mA, ctdi, gt_mass, vf_mass, agatston_mass]) - end + push!(results_df, [insert_name, beats_per_minute, kV, mA, ctdi, gt_mass, vf_mass, vf_mass_bkg_mean, vf_mass_bkg_std, agatston_mass, agatston_mass_bkg_mean, agatston_mass_bkg_std]) + end output_filename = joinpath(pwd(),"data","$(insert_name)_$(beats_per_minute).csv") - write(output_filename, results_df) + write(output_filename, results_df) end # ╔═╡ 4951072e-5546-4825-a12c-bb917df5995c results_df -# ╔═╡ cfff3b8b-4b23-426f-849d-04a39c1dfde4 - - -# ╔═╡ fc36cbd3-83ad-4446-b95d-62aec7fb5142 -3000 / 60 - # ╔═╡ 00000000-0000-0000-0000-000000000001 PLUTO_PROJECT_TOML_CONTENTS = """ [deps] @@ -2734,10 +2768,8 @@ version = "3.5.0+0" # ╠═1cbc8875-8b23-4660-8eb6-543f31436c73 # ╠═986a7b15-a441-412f-88a7-25f9648cfcbc # ╠═d60685cd-846f-4591-9908-2f2275a193d0 -# ╟─8e3fc2b5-18d0-4bce-bf74-5a7b56d61457 -# ╠═19b23f93-48b3-4c39-bcee-32b03d4f6f50 +# ╟─08e918cd-0032-4f8e-be16-84f2b19d8291 +# ╠═b22040f6-5726-4551-af1d-b65ae876e83c # ╠═4951072e-5546-4825-a12c-bb917df5995c -# ╠═cfff3b8b-4b23-426f-849d-04a39c1dfde4 -# ╠═fc36cbd3-83ad-4446-b95d-62aec7fb5142 # ╟─00000000-0000-0000-0000-000000000001 # ╟─00000000-0000-0000-0000-000000000002