|
|
@@ -5,6 +5,7 @@ import subprocess
|
|
|
import nibabel
|
|
|
import shutil
|
|
|
import sys
|
|
|
+import nixWrapper
|
|
|
|
|
|
#nothing gets done if you do import
|
|
|
|
|
|
@@ -35,13 +36,18 @@ def runPreprocess_DM(matlab,generalCodes,niftiTools,studyDir):
|
|
|
return True
|
|
|
|
|
|
|
|
|
-def getDicom(ofb,row,zipDir,rawDir,im,imageSelector,\
|
|
|
- participantField='PatientId'):
|
|
|
+def getDicom(pars,row,zipDir,rawDir,im,imageSelector):
|
|
|
|
|
|
#Load the dicom zip file and unzips it. If zip file is already at the expected path, it skips the loading step
|
|
|
|
|
|
#Return True for valid outcome and False for troubles in row formating or unzip failures
|
|
|
|
|
|
+ participantField=pars.get('participantField','PatientId')
|
|
|
+ ofb=pars['ofb']
|
|
|
+ if row['movedToProjectOrthanc']=='TRUE':
|
|
|
+ ofbStore=ofb.store()
|
|
|
+ ofb.set(pars['orthanc'])
|
|
|
+
|
|
|
seriesId=row[imageSelector[im]];
|
|
|
if seriesId=="0":
|
|
|
return False
|
|
|
@@ -55,8 +61,19 @@ def getDicom(ofb,row,zipDir,rawDir,im,imageSelector,\
|
|
|
print("Data already loaded. Skipping")
|
|
|
else:
|
|
|
print("getDicom: Loading data from orthanc")
|
|
|
+
|
|
|
+#use study specific orthanc
|
|
|
+ if row['movedToProjectOrthanc']=='TRUE':
|
|
|
+ ofbStore=ofb.store()
|
|
|
+ ofb.set(pars['orthanc'])
|
|
|
+
|
|
|
ofb.getZip('series',seriesId,fname)
|
|
|
|
|
|
+#reset to global value
|
|
|
+ if row['movedToProjectOrthanc']=='TRUE':
|
|
|
+ ofb.set(ofbStore)
|
|
|
+
|
|
|
+
|
|
|
#unzip the zipped dicom series
|
|
|
|
|
|
unzipDir=os.path.join(rawDir,im)
|
|
|
@@ -92,8 +109,6 @@ def main(parameterFile):
|
|
|
with open(os.path.join(fhome,".labkey","setup.json")) as f:
|
|
|
setup=json.load(f)
|
|
|
|
|
|
- sys.path.insert(0,setup["paths"]["nixWrapper"])
|
|
|
- import nixWrapper
|
|
|
|
|
|
nixWrapper.loadLibrary("labkeyInterface")
|
|
|
|
|
|
@@ -135,7 +150,15 @@ def main(parameterFile):
|
|
|
|
|
|
|
|
|
participantField=pars['Database']['participantField']
|
|
|
+ dicomPars={'participantField':participantField,'ofb':ofb}
|
|
|
+
|
|
|
+
|
|
|
+ ds=db.selectRows(project,'study','StudyProperties')
|
|
|
+ orthancObj={'server':ds['rows'][0]['orthancURL'],
|
|
|
+ 'user':ds['rows'][0]['orthancUser'],
|
|
|
+ 'password':ds['rows'][0]['orthancPassword']}
|
|
|
|
|
|
+ dicomPars['orhanc']=orthancObj
|
|
|
#all images from database
|
|
|
ds=db.selectRows(project,schema,dataset,[])
|
|
|
imageSelector={"CT":"CT_orthancId","PET":"PETWB_orthancId"}
|
|
|
@@ -227,7 +250,7 @@ def main(parameterFile):
|
|
|
#use imageSelector -> inputs
|
|
|
for im in imageSelector:
|
|
|
#checks if raw files are already loaded
|
|
|
- getDicom(ofb,row,zipDir,rawDir,im,imageSelector,\
|
|
|
+ getDicom(dicomPars,row,zipDir,rawDir,im,imageSelector,\
|
|
|
participantField)
|
|
|
|
|
|
|