Browse Source

validating summaryIVF

Andrej 1 year ago
parent
commit
87d8bfd583
3 changed files with 25 additions and 15 deletions
  1. 20 14
      pythonScripts/analysis.py
  2. 2 1
      pythonScripts/clusterAnalysis.ipynb
  3. 3 0
      template/cardiacSPECT.json

+ 20 - 14
pythonScripts/analysis.py

@@ -219,19 +219,19 @@ def getWeights(db,r,setup,nclass,realizationId,sigma2,na):
 
 
 #gets fitPar for a particular realization in [0..nr-1] range
-def getPixelFitPar(r,setup,nc,s2,mode):
+def getPixelFitPar(fb,r,setup,nc,s2,mode):
    code=config.getCode(r,setup)
    f=config.getPixelFitParFinalName(code,nc,s2,mode)
-   getData.copyFromServer(r,setup,f)
+   getData.copyFromServer(fb,r,setup,[f])
    fName=getData.getLocalPath(r,setup,f)
-   return numpy.genFromText(fName,delimiter='\t')
+   return numpy.genfromtxt(fName,delimiter='\t')
 
-def getFitPar(r,setup,nclass,realizationId,mode):
+def getFitPar(fb,r,setup,nclass,realizationId,mode):
    code=config.getCode(r,setup)
    f=config.getFitParFinalName(code,nclass,realizationId,mode)
-   getData.copyFromServer(r,setup,f)
+   getData.copyFromServer(fb,r,setup,[f])
    fName=getData.getLocalPath(r,setup,f)
-   return numpy.genFromText(fName,delimiter='\t')
+   return numpy.genfromtxt(fName,delimiter='\t')
 
 
 def getFitParBackup(r,setup,nclass,realizationId,mode=''):
@@ -352,9 +352,15 @@ def storeSummary(db,setup,summary,sigma2,na):
                     qrow['na']=na
                     getData.updateSummary(db,setup,mode,[qrow])
                     
-def summaryPixelIVF(db,fb,setup,sigma2,qfilter=[]):
+def summaryPixelIVF(db,fb,setup):
     #for second type of analysis (pixel based regions)
+    qfilter=[]
+    try:
+      qfilter=setup['patientFilter']
+    except KeyError:
+      pass
     rows=getData.getPatients(db,setup,qfilter)
+    sigma2=setup['sigma2']
     return \
         {config.getCode(r,setup):\
          {s2:getPixelIVF(db,fb,r,setup,s2) for s2 in sigma2} for r in rows}
@@ -389,16 +395,16 @@ def storeIVF(db,setup,summary):
                 getData.updateSummary(db,setup,mode,[qrow])
                 
 def getPixelIVF(db,fb,r,setup,sigma2):
-    #idFilter=config.getIdFilter(r,setup)
-    #visitFilter=config.getVisitFilter(r,setup)
-    #rows=getData.getSegmentation(db,setup,[idFilter,visitFilter])
-    #nclassIVF=len(rows)
+    idFilter=config.getIdFilter(r,setup)
+    visitFilter=config.getVisitFilter(r,setup)
+    rows=getData.getSegmentation(db,setup,[idFilter,visitFilter])
+    nclassIVF=len(rows)
 
-    x=segmentation.loadSegmentation(db,fb,r,setup)
-    nclassIVF=x.shape[0]
+    #x=segmentation.loadSegmentation(db,fb,r,setup)
+    #nclassIVF=x.shape[0]
     #this assumes segmentation is loaded
     #nclassIVF=segmentation.getNC(r,setup)
     #fitPar=getFitPar(r,setup,nclassIVF,sigma2,'PixelIVF')
-    fitPar=getPixelFitPar(r,setup,nclassIVF,sigma2,'IVF')
+    fitPar=getPixelFitPar(fb,r,setup,nclassIVF,sigma2,'IVF')
     k1={r['regionId']:getK1(fitPar,r['regionId']) for r in rows}
     return k1

File diff suppressed because it is too large
+ 2 - 1
pythonScripts/clusterAnalysis.ipynb


+ 3 - 0
template/cardiacSPECT.json

@@ -20,6 +20,9 @@
    "network":"merlin.json",
    "nclass":[10,20,30],
    "nr":20,
+   "sigma2":[0.1,1,4],
+   "na":3,
+   "s2":0.1,
    "patientFilter":[{"variable":"PatientId","value":"MM","oper":"eq"},{"variable":"visitName","value":"MIR","oper":"eq"}],
    "calculateCenters":0
 }

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