|
@@ -9,7 +9,7 @@ import SimpleITK
|
|
|
import numpy
|
|
|
import re
|
|
|
import json
|
|
|
-
|
|
|
+import segmentation
|
|
|
|
|
|
def calculateCenters(db,setup):
|
|
|
|
|
@@ -95,18 +95,19 @@ def doAnalysisRow(r,xsetup,mode):
|
|
|
|
|
|
|
|
|
|
|
|
-def doPixelAnalysis(db,fb,setup,sigma2,mode='IVF'):
|
|
|
+def doPixelAnalysis(db,setup,sigma2,mode='IVF'):
|
|
|
|
|
|
baseDir=os.path.dirname(os.getcwd())#one up
|
|
|
rows=getData.getPatients(db,setup)
|
|
|
|
|
|
for r in rows:
|
|
|
- doPixelAnalysisRow(db,fb,r,setup,mode)
|
|
|
+ doPixelAnalysisRow(r,setup,mode)
|
|
|
|
|
|
-def doPixelAnalysisRow(db,fb,r,setup, mode='IVF'):
|
|
|
+def doPixelAnalysisRow(r,setup, mode='IVF'):
|
|
|
cmds=config.cmdMatlab()
|
|
|
|
|
|
-
|
|
|
+ tempDir=config.getTempDir(setup)
|
|
|
+ #
|
|
|
|
|
|
#in global mode, IVF parameters are inferred together with fits to classes
|
|
|
#this is essentially repeat of the above, except that classes are taken as
|
|
@@ -117,7 +118,7 @@ def doPixelAnalysisRow(db,fb,r,setup, mode='IVF'):
|
|
|
mScript='analyzePixel'
|
|
|
analysisType=''
|
|
|
if mode=='IVF':
|
|
|
- mScript='analzyePixelIVF'
|
|
|
+ mScript='analyzePixelIVF'
|
|
|
analysisType='IVF_'
|
|
|
|
|
|
|
|
@@ -131,14 +132,15 @@ def doPixelAnalysisRow(db,fb,r,setup, mode='IVF'):
|
|
|
return
|
|
|
|
|
|
#code=config.getCode(r,setup)
|
|
|
- x=segmentation.loadSegmentation(db,fb,r,setup)
|
|
|
- nc=x.shape[0]
|
|
|
+ nc=segmentation.getNC(r,setup)
|
|
|
+ #loadSegmentation(db,fb,r,setup)
|
|
|
+ #nc=x.shape[0]
|
|
|
|
|
|
sigma2=setup['sigma2']
|
|
|
code=config.getCode(r,setup)
|
|
|
for s2 in sigma2:
|
|
|
f=config.getPixelFitParFinalName(code,nc,s2,mode)
|
|
|
- fName=getData.getLocalPath(f)
|
|
|
+ fName=getData.getLocalPath(r,setup,f)
|
|
|
if os.path.isfile(fName):
|
|
|
print('Skipping; {} available.'.format(fName))
|
|
|
continue
|
|
@@ -217,7 +219,22 @@ def getWeights(db,r,setup,nclass,realizationId,sigma2,na):
|
|
|
|
|
|
|
|
|
#gets fitPar for a particular realization in [0..nr-1] range
|
|
|
-def getFitPar(r,setup,nclass,realizationId,mode=''):
|
|
|
+def getPixelFitPar(r,setup,nc,s2,mode):
|
|
|
+ code=config.getCode(r,setup)
|
|
|
+ f=config.getPixelFitParFinalName(code,nc,s2,mode)
|
|
|
+ getData.copyFromServer(r,setup,f)
|
|
|
+ fName=getData.getLocalPath(r,setup,f)
|
|
|
+ return numpy.genFromText(fName,delimiter='\t')
|
|
|
+
|
|
|
+def getFitPar(r,setup,nclass,realizationId,mode):
|
|
|
+ code=config.getCode(r,setup)
|
|
|
+ f=config.getFitParFinalName(code,nclass,realizationId,mode)
|
|
|
+ getData.copyFromServer(r,setup,f)
|
|
|
+ fName=getData.getLocalPath(r,setup,f)
|
|
|
+ return numpy.genFromText(fName,delimiter='\t')
|
|
|
+
|
|
|
+
|
|
|
+def getFitParBackup(r,setup,nclass,realizationId,mode=''):
|
|
|
#fitGoodnes A tau alpha delay [k1 BVF k2 delay]xNcenters
|
|
|
allowedModes=['','IVF','Pixel','PixelIVF']
|
|
|
if mode not in allowedModes:
|
|
@@ -335,12 +352,12 @@ def storeSummary(db,setup,summary,sigma2,na):
|
|
|
qrow['na']=na
|
|
|
getData.updateSummary(db,setup,mode,[qrow])
|
|
|
|
|
|
-def summaryPixelIVF(db,setup,sigma2):
|
|
|
+def summaryPixelIVF(db,fb,setup,sigma2,qfilter=[]):
|
|
|
#for second type of analysis (pixel based regions)
|
|
|
- rows=getData.getPatients(db,setup)
|
|
|
+ rows=getData.getPatients(db,setup,qfilter)
|
|
|
return \
|
|
|
{config.getCode(r,setup):\
|
|
|
- {s2:getPixelIVF(db,r,setup,s2) for s2 in sigma2} for r in rows}
|
|
|
+ {s2:getPixelIVF(db,fb,r,setup,s2) for s2 in sigma2} for r in rows}
|
|
|
|
|
|
|
|
|
def storeIVF(db,setup,summary):
|
|
@@ -371,11 +388,17 @@ def storeIVF(db,setup,summary):
|
|
|
qrow['option']='D'
|
|
|
getData.updateSummary(db,setup,mode,[qrow])
|
|
|
|
|
|
-def getPixelIVF(db,r,setup,sigma2):
|
|
|
- idFilter=config.getIdFilter(r,setup)
|
|
|
- visitFilter=config.getVisitFilter(r,setup)
|
|
|
- rows=getData.getSegmentation(db,setup,[idFilter,visitFilter])
|
|
|
- nclassIVF=len(rows)
|
|
|
- fitPar=getFitPar(r,setup,nclassIVF,sigma2,'PixelIVF')
|
|
|
+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)
|
|
|
+
|
|
|
+ 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')
|
|
|
k1={r['regionId']:getK1(fitPar,r['regionId']) for r in rows}
|
|
|
return k1
|