|
@@ -8,15 +8,15 @@ import sys
|
|
|
|
|
|
shome=os.path.expanduser('~nixUser')
|
|
|
fhome=os.path.expanduser('~')
|
|
|
-with open(os.path.join(fhome,".labkey","setup.json"),"w") as f:
|
|
|
+with open(os.path.join(fhome,".labkey","setup.json")) as f:
|
|
|
setup=json.load(f)
|
|
|
|
|
|
-sys.path.insert(1,setup["paths"]["labkeyInterface"])
|
|
|
+sys.path.insert(0,setup["paths"]["labkeyInterface"])
|
|
|
import labkeyInterface
|
|
|
import labkeyDatabaseBrowser
|
|
|
import labkeyFileBrowser
|
|
|
|
|
|
-sys.path.insert(1,setup["paths"]["orthancInterface"])
|
|
|
+sys.path.insert(0,setup["paths"]["orthancInterface"])
|
|
|
import orthancInterface
|
|
|
import orthancFileBrowser
|
|
|
|
|
@@ -47,13 +47,13 @@ ofb=orthancFileBrowser.orthancFileBrowser(onet)
|
|
|
hi=0
|
|
|
project='iPNUMMretro/Study'
|
|
|
dataset='Imaging'
|
|
|
-h
|
|
|
tempBase=os.path.join(fhome,'temp')
|
|
|
|
|
|
#all images from database
|
|
|
ds=db.selectRows(project,'study',dataset,[])
|
|
|
-imageSelector={"CT":"CT","PETWB":"PET"};
|
|
|
-imageResampledField={"CT":"ctResampled","PETWB":"petResampled"}
|
|
|
+#imageSelector={"CT":"CT","PET":"PETWB"};
|
|
|
+imageSelector={"CT":"CT_orthancId","PET":"PETWB_orthancId"}
|
|
|
+imageResampledField={"CT":"ctResampled","PET":"petResampled"}
|
|
|
|
|
|
#projectNIfTIBase=os.path.join(labkeyBase,'files',project,'@files/nifti')
|
|
|
#use webdav to transfer file (even though it is localhost)
|
|
@@ -92,12 +92,12 @@ def getDicom(ofb,row,zipDir,rawDir,im,imageSelector):
|
|
|
|
|
|
#Return True for valid outcome and False for troubles in row formating or unzip failures
|
|
|
|
|
|
- seriesId=row[im];
|
|
|
+ seriesId=row[imageSelector[im]];
|
|
|
if seriesId=="0":
|
|
|
return False
|
|
|
|
|
|
print("{}: {}".format(im,seriesId))
|
|
|
- fname=os.path.join(zipDir,getStudyLabel(row)+'_'+imageSelector[im]+".zip");
|
|
|
+ fname=os.path.join(zipDir,getStudyLabel(row)+'_'+im+".zip");
|
|
|
|
|
|
#copy data from orthanc
|
|
|
if os.path.isfile(fname):
|
|
@@ -108,7 +108,7 @@ def getDicom(ofb,row,zipDir,rawDir,im,imageSelector):
|
|
|
|
|
|
#unzip the zipped dicom series
|
|
|
|
|
|
- unzipDir=os.path.join(rawDir,imageSelector[im])
|
|
|
+ unzipDir=os.path.join(rawDir,im)
|
|
|
|
|
|
if os.path.isdir(unzipDir):
|
|
|
print("Data already unzipped")
|
|
@@ -142,7 +142,7 @@ for row in ds["rows"]:
|
|
|
#interesting files are processedDir/studyName_CT_notCropped_2mmVoxel.nii
|
|
|
#asn processedDir/studyName_PET_notCropped_2mmVoxel.nii
|
|
|
volumeFileNames={im:\
|
|
|
- getStudyLabel(row)+'_'+imageSelector[im]+
|
|
|
+ getStudyLabel(row)+'_'+im+
|
|
|
'_notCropped_2mmVoxel.nii'\
|
|
|
for im in imageSelector}
|
|
|
gzFileNames={im:f+".gz" \
|
|
@@ -187,7 +187,7 @@ for row in ds["rows"]:
|
|
|
|
|
|
#specify local file names with path
|
|
|
volumeFiles={im:os.path.join(processedDir,f)\
|
|
|
- for (im.f) in volumeFileNames.items()}
|
|
|
+ for (im,f) in volumeFileNames.items()}
|
|
|
gzFiles={im:f+".gz"\
|
|
|
for (im,f) in volumeFiles.items()}
|
|
|
|