|
@@ -95,51 +95,60 @@ def doAnalysisRow(r,xsetup,mode):
|
|
|
|
|
|
|
|
|
|
|
|
-def doPixelAnalysis(db,setup,sigma2,mode='IVF'):
|
|
|
-
|
|
|
+def doPixelAnalysis(db,fb,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)
|
|
|
+
|
|
|
+def doPixelAnalysisRow(db,fb,r,setup, mode='IVF'):
|
|
|
+ cmds=config.cmdMatlab()
|
|
|
+
|
|
|
+
|
|
|
|
|
|
#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
|
|
|
#time-response curves from pixels in the sigma2-defined neighborhood of
|
|
|
#target pixels
|
|
|
- if mode=='global':
|
|
|
- runScript='doPixelAnalysis.sh'
|
|
|
- analysisType=''
|
|
|
+
|
|
|
+ if mode=='global':
|
|
|
+ mScript='analyzePixel'
|
|
|
+ analysisType=''
|
|
|
+ if mode=='IVF':
|
|
|
+ mScript='analzyePixelIVF'
|
|
|
+ analysisType='IVF_'
|
|
|
+
|
|
|
+
|
|
|
#in IVF mode, the parameters of input function are taken from the cluster fit
|
|
|
#(doAnalysis above, with mode=general). The rest is the same as for global mode
|
|
|
- if mode=='IVF':
|
|
|
- runScript='doPixelIVFAnalysis.sh'
|
|
|
- analysisType='IVF_'
|
|
|
|
|
|
- #either doPixelAnalysis or doPixelAnalysisIVF.sh
|
|
|
- scriptPath=os.path.join(baseDir,'scripts',runScript)
|
|
|
+ try:
|
|
|
+ print('Setting runScript to {}'.format(mScript))
|
|
|
+ except NameError:
|
|
|
+ print('Mode can be one of (global,IVF))')
|
|
|
+ return
|
|
|
+
|
|
|
+ #code=config.getCode(r,setup)
|
|
|
+ x=segmentation.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)
|
|
|
+ if os.path.isfile(fName):
|
|
|
+ print('Skipping; {} available.'.format(fName))
|
|
|
+ continue
|
|
|
|
|
|
- try:
|
|
|
- print('Setting runScript to {}'.format(runScript))
|
|
|
- except NameError:
|
|
|
- print('Mode can be one of (global,IVF))')
|
|
|
- return
|
|
|
-
|
|
|
- rows=getData.getPatients(db,setup)
|
|
|
- for r in rows:
|
|
|
- dataPath=config.getLocalDir(r,setup)
|
|
|
- code=config.getCode(r,setup)
|
|
|
- sName=os.path.join(dataPath,'{}_Segmentation.txt'.format(code))
|
|
|
- sFile=os.path.join(dataPath,sName)
|
|
|
- x=numpy.loadtxt(sFile)
|
|
|
- nc=x.shape[0]
|
|
|
- for s2 in sigma2:
|
|
|
- sigmaCode='{:.2f}'.format(s2)
|
|
|
- sigmaCode=re.sub('\.','p',sigmaCode)
|
|
|
- fName=os.path.join(dataPath,'{}_{}_{}_Pixel{}_fitParFinal.txt'.format(code,nc,sigmaCode,analysisType))
|
|
|
- if os.path.isfile(fName):
|
|
|
- print('Skipping; {} available.'.format(fName))
|
|
|
- continue
|
|
|
- subprocess.run([scriptPath,code,str(s2)], \
|
|
|
- check=True, stdout=subprocess.PIPE)
|
|
|
-
|
|
|
+ runCmds=[x for x in cmds]
|
|
|
+ runCmds.append('-r "path=\'{}\'; patientID=\'{}\'; sigma2=\'{}\'; {}"'.format(tempDir,code,s2,mScript))
|
|
|
+
|
|
|
+
|
|
|
+ subprocess.run(runCmds,check=True, stdout=subprocess.PIPE)
|
|
|
+
|
|
|
|
|
|
def getIWeights(r,setup,nclass,realizationId,ic):
|
|
|
locDir=config.getLocalDir(r,setup)
|