Browse Source

Robustifying against non-function derivatives

Andrej 2 years ago
parent
commit
9e18018d7c

+ 95 - 15
models/humanHG_parameters1.json

@@ -25,22 +25,40 @@
         "liverInFlow":{"value":0.391,"unit":"l/min"},
         "liverOutFlow":{"value":1.928,"unit":"l/min"},
         "gutFlow":{"value":1.538,"unit":"l/min"},
-        "plasmaVolume":{"value":1.64,"unit":"kg"},
-        "redBloodCellsVolume":{"value":1.64,"unit":"kg"},
-        "kidneyVolume":{"value":0.28,"unit":"kg"},
-        "richlyPerfusedVolume":{"value":7,"unit":"kg"},
-        "fatVolume":{"value":19.11,"unit":"kg"},
+        "commentVolumes":"X",
+        "plasmaVolume":{"derived":"plasmaVolume"},
+        "redBloodCellsVolume":{"derived":"redBloodCellsVolume"},
+        "kidneyVolume":{"derived":"kidneyVolume"},
+        "richlyPerfusedVolume":{"derived":"richlyPerfusedVolume"},
+        "fatVolume":{"derived":"fatVolume"},
         "hairVolume":{"function":"hairGrowth"},
         "hairGrowthDuration":{"derived":"hairGrowthDuration"},
         "hairVolumeMax":{"derived":"hairVolumeMax"},
-        "hairVolumeFraction":{"value":0.002,"dist":"lognormal","cv":0.5},
-        "slowlyPerfusedVolume":{"value":24.5,"unit":"kg"},
-        "brainBloodVolume":{"value":0.49,"unit":"kg"},
-        "brainVolume":{"value":1.4,"unit":"kg"},
-        "placentaVolume":{"value":0.0431,"unit":"kg"},
-        "liverVolume":{"value":1.82,"unit":"kg"},
-        "gutVolume":{"value":1.19,"unit":"kg"},
-        "intestineVolume":{"value":0.98,"unit":"kg"},
+        "slowlyPerfusedVolume":{"derived":"slowlyPerfusedVolume"},
+        "brainBloodVolume":{"derived":"brainBloodVolume"},
+        "brainVolume":{"derived":"brainVolume"},
+        "liverVolume":{"derived":"liverVolume"},
+        "gutVolume":{"derived":"gutVolume"},
+        "intestineVolume":{"derived":"intestineVolume"},
+        "placentaVolume":{"derived":"placentaVolume"},
+        "fetusWeight":{"function":"fetusWeight"},
+        "fetusWeightMax":{"value":4.0,"unit":"kg","dist":"normal","cv":0.1},
+        "commentFractions":"X",
+        "plasmaVolumeFraction":{"value":0.024,"dist":"normal","cv":0.14},
+        "redBloodCellsVolumeFraction":{"value":0.024,"dist":"normal","cv":0.25},
+        "kidneyVolumeFraction":{"value":0.004,"dist":"normal","cv":0.3},
+        "richlyPerfusedVolumeFraction":{"value":0.1,"dist":"normal","cv":0.3},
+        "fatVolumeFraction":{"value":0.273,"dist":"normal","cv":0.24},
+        "hairVolumeFraction":{"value":0.002,"dist":"normal","cv":0.5},
+        "slowlyPerfusedVolumeFraction":{"value":0.35,"dist":"normal","cv":0.16},
+        "brainBloodVolumeFraction":{"value":0.007,"dist":"normal","cv":0.3},
+        "brainVolumeFraction":{"value":0.02,"dist":"normal","cv":0.3},
+        "liverVolumeFraction":{"value":0.026,"dist":"normal","cv":0.25},
+        "placentaVolumeFraction":{"value":0.18,"dist":"normal","cv":0.13},
+        "placentaVolumeFractionSurce":"https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3530253",
+        "gutVolumeFraction":{"value":0.017,"dist":"normal","cv":0.15},
+        "intestineVolumeFraction":{"value":0.14,"dist":"normal","cv":0.3},
+        "commentDiff":"X",
         "kRBC":{"value":0.60,"unit":"l/min"},
         "kU":{"value":0,"unit":"l/min"},
         "commentkH":"assume pc-times larger input flow, 2.823e-6*248.7",
@@ -57,7 +75,10 @@
         "heavisideTransition":{"value":100},
         "hairGrowthStart":{"value":0e6,"unit":"min"},
         "hairGrowthStop":{"derived":"hairGrowthStop"},
-        "hairGrowth":{"derived":"hairGrowth"}},
+        "hairGrowth":{"derived":"hairGrowth"},
+        "fetusGrowthStart":{"value":8.6e5,"unit":"min"},
+        "fetusGrowthDuration":{"value":4e5,"unit":"min"},
+        "fetusGrowthStop":{"derived":"fetusGrowthStop"}},
     "functions":{
        "commentHairGrowth":"2yr hair growth to a total mass of 140g",
        "hairGrowth":{
@@ -66,8 +87,63 @@
            "W1":"heavisideTransition",
            "t2":"hairGrowthStop",
            "W2":"heavisideTransition",
-           "C":"hairVolumeMax"}},
+           "C":"hairVolumeMax"},
+       "fetusWeight":{
+           "type":"linearGrowth",
+           "t1":"fetusGrowthStart",
+           "t2":"fetusGrowthStop",
+           "W1":"heavisideTransition",
+           "W2":"heavisideTransition",
+           "C":"fetusWeightMax"}},
     "derivedParameters":{
+        "plasmaVolume":{
+           "type":"product",
+           "a":"plasmaVolumeFraction",
+           "b":"bodyWeight"},
+        "redBloodCellsVolume":{
+           "type":"product",
+           "a":"redBloodCellsVolumeFraction",
+           "b":"bodyWeight"},
+        "kidneyVolume":{
+           "type":"product",
+           "a":"kidneyVolumeFraction",
+           "b":"bodyWeight"},
+        "richlyPerfusedVolume":{
+           "type":"product",
+           "a":"richlyPerfusedVolumeFraction",
+           "b":"bodyWeight"},
+        "fatVolume":{
+           "type":"product",
+           "a":"fatVolumeFraction",
+           "b":"bodyWeight"},
+        "slowlyPerfusedVolume":{
+           "type":"product",
+           "a":"slowlyPerfusedVolumeFraction",
+           "b":"bodyWeight"},
+        "brainBloodVolume":{
+           "type":"product",
+           "a":"brainBloodVolumeFraction",
+           "b":"bodyWeight"},
+        "brainVolume":{
+           "type":"product",
+           "a":"brainVolumeFraction",
+           "b":"bodyWeight"},
+        "liverVolume":{
+           "type":"product",
+           "a":"liverVolumeFraction",
+           "b":"bodyWeight"},
+        "gutVolume":{
+           "type":"product",
+           "a":"gutVolumeFraction",
+           "b":"bodyWeight"},
+        "intestineVolume":{
+           "type":"product",
+           "a":"intestineVolumeFraction",
+           "b":"bodyWeight"},
+        "placentaVolume":{
+           "type":"product",
+           "a":"placentaVolumeFraction",
+           "b":"fetusWeight"},
        "hairVolumeMax":{
            "type":"product",
            "a":"hairVolumeFraction",
@@ -84,6 +160,10 @@
             "type":"ratio",
             "a":"kH",
             "b":"hairPC"},
+       "fetusGrowthStop":{
+            "type":"sum",
+            "a":"fetusGrowthStart",
+            "b":"fetusGrowthDuration"},
        "bwPower0p75":{
           "type":"power",
           "a":"bodyWeight",

+ 8 - 8
pythonScripts/cModel.py

@@ -490,8 +490,8 @@ class model:
             f=lambda t,a=fa,b=fb:a(t)*b(t)
             dfdA=lambda t,b=fb: b(t)
             dfdB=lambda t,a=fa: a(t)
-            dA={x:lambda t,df=dfdA,D=DA,x=x: df(t)*D[x](t) for x in DA}
-            dB={x:lambda t,df=dfdB,D=DB,x=x: df(t)*D[x](t) for x in DB}
+            dA=function.generate(dfdA,DA)
+            dB=function.generate(dfdB,DB)
             return function.Object(f,[dA,dB])
          else:
             return derivedObject(a*b,[{'df':b,'D':DA},{'df':a,'D':DB}])
@@ -510,8 +510,8 @@ class model:
             f=lambda t,a=fa,n=fn:numpy.power(a(t),n(t))
             dfdA=lambda t,n=fn,f=f,a=fa:n(t)*f(t)/a(t)
             dfdN=lambda t,a=fa,f=f:numpy.log(a(t))*f(t)
-            dA={x:lambda t,df=dfdA,D=DA,x=x: df(t)*D[x](t) for x in DA}
-            dN={x:lambda t,df=dfdN,D=DN,x=x: df(t)*D[x](t) for x in DN}
+            dA=function.generate(dfdA,DA)
+            dN=function.generate(dfdN,DN)
             return function.Object(f,[dA,dN])
          else:
             f=numpy.power(a,n)
@@ -532,8 +532,8 @@ class model:
             f=lambda t,a=fa,b=fb,:a(t)/b(t)
             dfdA=lambda t,f=f,a=fa: f(t)/a(t)
             dfdB=lambda t,f=f,b=fb: -f(t)/b(t)
-            dA={x:lambda t,df=dfdA,D=DA,x=x: df(t)*D[x](t) for x in DA}
-            dB={x:lambda t,df=dfdB,D=DB,x=x: df(t)*D[x](t) for x in DB}
+            dA=function.generate(dfdA,DA)
+            dB=function.generate(dfdB,DB)
             return function.Object(f,[dA,dB])
          else:
             return derivedObject(a/b,[{'df':1/b,'D':DA},{'df':-a/b/b,'D':DB}])
@@ -552,8 +552,8 @@ class model:
             f=lambda t,a=fa,b=fb,:a(t)+b(t)
             dfdA=lambda t: 1
             dfdB=lambda t: 1
-            dA={x:lambda t,df=dfdA,D=DA,x=x: df(t)*D[x](t) for x in DA}
-            dB={x:lambda t,df=dfdB,D=DB,x=x: df(t)*D[x](t) for x in DB}
+            dA=function.generate(dfdA,DA)
+            dB=function.generate(dfdB,DB)
             return function.Object(f,[dA,dB])
          else:
             return derivedObject(a+b,[{'df':1,'D':DA},{'df':1,'D':DB}])

File diff suppressed because it is too large
+ 8 - 3
pythonScripts/compartmentModel.ipynb


+ 12 - 12
pythonScripts/function.py

@@ -35,11 +35,11 @@ def logisticPar(par):
    #D1[x] could be a function !!!
    Dt0=par['t0']['derivatives']
    dfdt0=functools.partial(dLdt0,t0=t0,W=W)
-   dt0={x:lambda t,df=dfdt0,D=Dt0,x=x: df(t)*to(D[x])(t) for x in Dt0}
+   dt0=generate(dfdt0,Dt0)
    #D2[x] could be a function !!!
    DW=par['W']['derivatives']
    dfdW=functools.partial(dLdW,t0=t0,W=W)
-   dW={x:lambda t,df=dfdW,D=DW,x=x: df(t)*to(D[x])(t) for x in DW}
+   dW=generate(dfdW,DW)
    #merge
    return Object(f,[dt0,dW])
 
@@ -128,23 +128,23 @@ def linearGrowth(par):
 
    Dt1=par['t1']['derivatives']
    dfdt1=functools.partial(dlgdt1,C=C,t1=t1,t2=t2,L1=L1,L2=L2)
-   dt1={x:lambda t,df=dfdt1,D=Dt1,x=x:df(t)*to(D[x])(t) for x in Dt1}
+   dt1=generate(dfdt1,Dt1)
    
    Dt2=par['t2']['derivatives']
    dfdt2=functools.partial(dlgdt2,C=C,t1=t1,t2=t2,L1=L1,L2=L2)
-   dt2={x:lambda t,df=dfdt2,D=Dt2,x=x:df(t)*to(D[x])(t) for x in Dt2}
+   dt2=generate(dfdt2,Dt2)
 
    DL1=pL1['derivatives']
    dfdL1=functools.partial(dlgdL1,C=C,t1=t1,t2=t2,L1=L1,L2=L2)
-   dL1={x:lambda t,df=dfdL1,D=DL1,x=x:df(t)*D[x](t) for x in DL1}
+   dL1=generate(dfdL1,DL1)
 
    DL2=pL2['derivatives']
    dfdL2=functools.partial(dlgdL2,C=C,t1=t1,t2=t2,L1=L1,L2=L2)
-   dL2={x:lambda t,df=dfdL2,D=DL2,x=x: df(t)*D[x](t) for x in DL2}
+   dL2=generate(dfdL2,DL2)
 
    DC=par['C']['derivatives']
    dfdC=functools.partial(dlgdC,C=C,t1=t1,t2=t2,L1=L1,L2=L2)
-   dC={x:lambda t,df=dfdC,D=DC,x=x:df(t)*to(D[x])(t) for x in DC}
+   dC=generate(dfdC,DC)
 
    return Object(f,[dt1,dt2,dL1,dL2,dC])
 
@@ -163,23 +163,23 @@ def linearGrowthFixedSlope(par):
 
    Dt1=par['t1']['derivatives']
    dfdt1=functools.partial(dlgFixedSlopedt1,alpha=alpha,L1=L1,L2=L2)
-   dt1={x:lambda t,df=dfdt1,D=Dt1,x=x:df(t)*to(D[x])(t) for x in Dt1}
+   dt1=generate(dfdt2,Dt1)
    
    Dt2=par['t2']['derivatives']
    dfdt2=functools.partial(dlgFixedSlopedt2,alpha=alpha,L1=L1,L2=L2)
-   dt2={x:lambda t,df=dfdt2,D=Dt2,x=x:df(t)*to(D[x])(t) for x in Dt2}
+   dt2=generate(dfdt2,Dt2)
 
    DL1=pL1['derivatives']
    dfdL1=functools.partial(dlgFixedSlopedL1,alpha=alpha,t1=t1,t2=t2,L1=L1,L2=L2)
-   dL1={x:lambda t,df=dfdL1,D=DL1,x=x:df(t)*D[x](t) for x in DL1}
+   dL1=generate(dfdL1,DL1)
 
    DL2=pL2['derivatives']
    dfdL2=functools.partial(dlgFixedSlopedL2,alpha=alpha,t1=t1,t2=t2,L1=L1,L2=L2)
-   dL2={x:lambda t,df=dfdL2,D=DL2,x=x: df(t)*D[x](t) for x in DL2}
+   dL2=generate(dfdL2,DL2)
 
    DA=par['alpha']['derivatives']
    dfdA=functools.partial(dlgFixedSlopedalpha,alpha=alpha,t1=t1,t2=t2,L1=L1,L2=L2)
-   dA={x:lambda t,df=dfdA,D=DA,x=x:df(t)*to(D[x])(t) for x in DA}
+   dA=generate(dfdA,DA)
 
    return Object(f,[dt1,dt2,dL1,dL2,dA])
 

Some files were not shown because too many files changed in this diff