|
@@ -65,6 +65,9 @@ def main(configFile):
|
|
|
print('No rows returned')
|
|
|
return
|
|
|
for r in rows:
|
|
|
+ #check row sanity
|
|
|
+
|
|
|
+
|
|
|
print("Loading {}/{}".format(config.getPatientId(r,xconfig),config.getVisitId(r,xconfig)))
|
|
|
rPath=fb.formatPathURL(xconfig['project'],config.getOutputDir(r,xconfig))
|
|
|
rPath+='/'+config.getNodeName(r,xconfig,'CT')+'.nrrd'
|
|
@@ -80,10 +83,13 @@ def main(configFile):
|
|
|
|
|
|
print('Forced recalculation')
|
|
|
|
|
|
-
|
|
|
+ code=config.getCode(r,xconfig)
|
|
|
print('{} available:{}'.format(config.getNodeName(r,xconfig,'CT'),fb.entryExists(rPath)))
|
|
|
#loadPatient into slicer
|
|
|
patient=loadPatient(ofb,r,xconfig)
|
|
|
+ if not patient:
|
|
|
+ print(f'{code} failed to load from Orthanc')
|
|
|
+ continue
|
|
|
#convert to nodes
|
|
|
addCT(r,patient,xconfig)
|
|
|
addFrames(r,patient,xconfig)
|
|
@@ -134,11 +140,15 @@ def loadPatient(ofb,r,xconfig):
|
|
|
pd=parseDicom.parseDicom()
|
|
|
|
|
|
masterPath=downloadAndUnzip(ofb,r,"nmMaster",xconfig)
|
|
|
+ if not masterPath:
|
|
|
+ return None
|
|
|
pd.readMasterDirectory(masterPath,False)
|
|
|
print('Time [{} .. {}]'.format(pd.frame_start,pd.frame_stop))
|
|
|
clearUnzipDir(r,xconfig)
|
|
|
|
|
|
nmPath=downloadAndUnzip(ofb,r,"nmCorrData",xconfig)
|
|
|
+ if not nmPath:
|
|
|
+ return None
|
|
|
frame_data, frame_time, frame_duration, frame_origin, \
|
|
|
frame_pixel_size, frame_orientation=\
|
|
|
pd.readNMDirectory(nmPath,False)
|
|
@@ -146,6 +156,8 @@ def loadPatient(ofb,r,xconfig):
|
|
|
clearUnzipDir(r,xconfig)
|
|
|
|
|
|
ctPath=downloadAndUnzip(ofb,r,"ct",xconfig)
|
|
|
+ if not ctPath:
|
|
|
+ return None
|
|
|
ct_data,ct_origin,ct_pixel_size, \
|
|
|
ct_orientation=pd.readCTDirectory(ctPath,False)
|
|
|
print('CT pixel {}'.format(ct_pixel_size))
|
|
@@ -185,6 +197,9 @@ def downloadAndUnzip(ofb,r,code,xconfig):
|
|
|
os.makedirs(tempDir)
|
|
|
|
|
|
orthancId=r[code+'OrthancId']
|
|
|
+ if not orthancId:
|
|
|
+ return None
|
|
|
+
|
|
|
fileCode='{}_{}'.format(config.getCode(r,xconfig),code)
|
|
|
zipFile=os.path.join(tempDir,fileCode+'.zip')
|
|
|
ofb.getZip('series',orthancId,zipFile)
|