generateCenters.ipynb 3.1 KB

import sys
import os
import SimpleITK
import numpy
import matplotlib.pyplot
import subprocess
sys.path.append(os.path.join(os.path.expanduser('~'),'software','src','nixSuite','wrapper'))
import nixWrapper
nixWrapper.loadLibrary('labkeyInterface')
import labkeyInterface
net=labkeyInterface.labkeyInterface()
fconfig=os.path.join(os.path.expanduser('~'),'.labkey','network.json')
net.init(fconfig)
net.getCSRF()
import labkeyFileBrowser
sys.path.append(os.getcwd())
import downloadPatient
fb=labkeyFileBrowser.labkeyFileBrowser(net)
project='dinamic_spect/Patients'
locDir=os.path.join(os.path.expanduser('~'),'temp','dynamicSPECT')
import labkeyDatabaseBrowser
db=labkeyDatabaseBrowser.labkeyDB(net)
ds=db.selectRows(project,'study','Imaging',[])
patients=[row['aliasID'] for row in ds['rows']]
#generate centers
import subprocess

nclass=10
nsample=20
patients=list(set(patients))
scriptPath=os.path.join(os.path.expanduser('~'),\
                        'scripts','dynamicSPECT','generateCenters.sh')

for pId in patients:
    if pId.find('8')==0:
        continue
    print(subprocess.run([scriptPath,pId,str(nclass),str(nsample)], \
                         check=True, stdout=subprocess.PIPE).stdout)
    
   
#doAnalysis
import subprocess

patients=list(set(patients))
runScript='doAnalysis.sh'
#this is if IVF is taken from clusters
scriptPath=os.path.join(os.path.expanduser('~'),\
                        'scripts','dynamicSPECT',runScript)
#patients1=['10KFMIR']
patients1=patients
for pId in patients1:
    if pId.find('8')==0:
        continue
    for nclass in [10,20,30]:
        for realizationId in numpy.arange(20):
            print('{}/{} {}'.format(pId,nclass,realizationId+1))
            subprocess.run([scriptPath,pId,str(nclass),str(realizationId)],\
                         check=True, stdout=subprocess.PIPE)