Browse Source

Merge branch 'master' of https://git-1.fmf.uni-lj.si/studen/limfomiPET

Andrej Studen @ VBOX 2 years ago
parent
commit
70f68c0eae

File diff suppressed because it is too large
+ 27 - 0
pythonScripts/confirmForms.ipynb


+ 19 - 4
pythonScripts/preprocess.py

@@ -46,6 +46,9 @@ def getDicom(ofb,row,zipDir,rawDir,im,imageSelector,\
     if seriesId=="0":
         return False
 
+    if seriesId==None:
+        return False
+    
     print("getDicom: {}: {}".format(im,seriesId))
     fname=os.path.join(zipDir,\
             getStudyLabel(row,participantField)+'_'+im+".zip");
@@ -149,7 +152,11 @@ def main(parameterFile):
 
     i=0
     for row in ds["rows"]:
-        print("Starting row id:{} seq:{}".format(row[participantField],row['SequenceNum']))
+        pId=row[participantField]
+        seqNo=row['SequenceNum']
+        print("Starting row id:{} seq:{}".format(pId,seqNo))
+
+
         #interesting files are processedDir/studyName_CT_notCropped_2mmVoxel.nii
         #asn processedDir/studyName_PET_notCropped_2mmVoxel.nii
         volumeFileNames={im:\
@@ -211,12 +218,20 @@ def main(parameterFile):
         if not all(filesPresent):
 
             #use imageSelector -> inputs
+            dicomStatus="OK"
             for im in imageSelector:
                 #checks if raw files are already loaded
-                getDicom(ofb,row,zipDir,rawDir,im,imageSelector,\
+                ok=getDicom(ofb,row,zipDir,rawDir,im,imageSelector,\
                     participantField)
-
-
+                
+                if not ok:
+                    dicomStatus="BAD"
+                    break
+
+            
+            if not dicomStatus=="OK":
+                print('Troubles getting dicom for {}/{}'.format(pId,seqNo))
+                continue
     
             #preprocess and zip
             ok=runPreprocess_DM(matlab,generalCodes,niftiTools,studyDir)

+ 17 - 4
slicerModules/imageBrowser.py

@@ -97,6 +97,8 @@ class imageBrowserWidget(ScriptedLoadableModuleWidget):
 
         self.patientList=qt.QComboBox()
         self.patientList.currentIndexChanged.connect(self.onPatientListChanged)
+        self.patientList.setEditable(True)
+        self.patientList.setInsertPolicy(qt.QComboBox.NoInsert)
         patientsFormLayout.addRow("Patient:",self.patientList)
             
 
@@ -260,7 +262,11 @@ class imageBrowserWidget(ScriptedLoadableModuleWidget):
         except KeyError:
             pass
 
-        self.updatePatientList(status['ids'])
+        #sort ids
+        ids=status['ids']
+        ids.sort()
+
+        self.updatePatientList(ids)
         self.onPatientListChanged(0)
  
     def onServerListChanged(self,i):
@@ -279,6 +285,10 @@ class imageBrowserWidget(ScriptedLoadableModuleWidget):
         self.serverList.setStyleSheet('background-color: green')
 
     def onPatientListChanged(self,i):
+        self.visitList.clear()   
+        self.petCode.setText("")
+        self.ctCode.setText("")
+        
         #add potential filters from setup to dbFilter
         ds=self.logic.getDataset(dbFilter={'participant':self.patientList.currentText})
        
@@ -286,10 +296,14 @@ class imageBrowserWidget(ScriptedLoadableModuleWidget):
         dt=datetime.datetime
         
         #label is a combination of sequence number and date of imaging
-        seq={row['SequenceNum']:
+        try:
+            seq={row['SequenceNum']:
                 {'label':row[visitVar],
                 'date': dt.strptime(row['studyDate'],'%Y/%m/%d %H:%M:%S')}
-            for row in ds['rows']}
+                for row in ds['rows']}
+        except TypeError:
+            #if studyDate is empty, this will return no possible visits
+            return
 
         #apply lookup to visitVar if available
         try:
@@ -304,7 +318,6 @@ class imageBrowserWidget(ScriptedLoadableModuleWidget):
         seq={x:'{} ({})'.format(seq[x]['label'],dt.strftime(seq[x]['date'],'%d-%b-%Y')) 
             for x in seq}
 
-        self.visitList.clear()   
             
         for s in seq:
             #onVisitListChanged is called for every addItem

+ 6 - 0
slicerModules/pyrightconfig.json

@@ -0,0 +1,6 @@
+{
+    "extraPaths":["../../nixsuite/slicerModule",
+        "../../nixsuite/wrapper",
+        "../../../install/Slicer/bin/Python",
+        "../../../../.labkey/software/src/labkeyInterface"],
+}

Some files were not shown because too many files changed in this diff