def updateTextRect(self): qDebug("SetCursorLocation") # TODO x, y, w, h self.driver.SetCursorLocation(0, 0, 5, 5) self.update()
if __name__ == "__main__": #Set up the application window app = QGuiApplication(sys.argv) #Expose the list to the Qml code m_Database = QSqlDatabase() m_Database = QSqlDatabase.addDatabase("QSQLITE") m_Database.setDatabaseName("C:\dev\Work\python\SQLTest\o3.db") # Don't know why it is not working with (.mde file?, ...) # m_Database = QSqlDatabase.addDatabase("QODBC"); # m_Database.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)}; FIL={MS Access}; DBQ=C:\\OnDemand3DApp\\Users\\Common\\MasterDB\\lucion.mde;") if (not m_Database.open()): qDebug("ERROR") else: qDebug("DB Opened") my_StudyModel = myStudyModel() my_SeriesModel = studySeriesModel() my_StudyModel.selectRow.connect(my_SeriesModel.refreshUID) # Temporarily, setting default path manually path = "C:\\dev\\Work\\TestData" dirModel = myDirModel() dirModel.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs) dirModel.setRootPath(path) #Load the QML file qml_file = os.path.join(os.path.dirname(__file__), "main.qml")
def scanDir(self, strPath, s): d = gdcm.Directory() nfiles = d.Load(strPath) if (nfiles == 0): sys.exit(-1) # No DICOM files in the directory filenames = d.GetFilenames() qDebug("The number of files to scan is " + str(len(filenames))) # Define the set of tags we are interested in, may need more t1 = gdcm.Tag(0x10, 0x20) # Patient ID t2 = gdcm.Tag(0x10, 0x10) # Patient Name t3 = gdcm.Tag(0x20, 0x10) # Study ID t4 = gdcm.Tag(0x20, 0x0d) # Study Instance UID t5 = gdcm.Tag(0x20, 0x0e) # Series Instance UID t6 = gdcm.Tag(0x20, 0x11) # Series Number t7 = gdcm.Tag(0x28, 0x08) # Number of Frames t8 = gdcm.Tag(0x20, 0x32) # Image Position t10 = gdcm.Tag(0x28, 0x30) # Pixel Spacing t11 = gdcm.Tag(0x20, 0x37) # Image Orientation Patient t12 = gdcm.Tag(0x28, 0x02) # Samples per pixel t13 = gdcm.Tag(0x28, 0x04) # Photometric Interpretation t14 = gdcm.Tag(0x28, 0x10) # Rows t15 = gdcm.Tag(0x28, 0x11) # Column t16 = gdcm.Tag(0x28, 0x101) # BitStored t17 = gdcm.Tag(0x02, 0x02) # Media Storage SOP Class UID t18 = gdcm.Tag(0x02, 0x03) # Media Storage SOP Instance UID t19 = gdcm.Tag(0x02, 0x10) # Transfer Syntax t20 = gdcm.Tag(0x08, 0x16) # SOP Class UID t21 = gdcm.Tag(0x08, 0x18) # SOP Instance UID t22 = gdcm.Tag(0x5200, 0x9229) # Shared functional group t23 = gdcm.Tag(0x5200, 0x9230) # Per frame functional group t24 = gdcm.Tag(0x0028, 0x1050) # WindowCenter t25 = gdcm.Tag(0x0028, 0x1051) # WindowWidth t26 = gdcm.Tag(0x0028, 0x1052) # Rescale Intercept t27 = gdcm.Tag(0x0028, 0x1053) # Rescale Slope t28 = gdcm.Tag(0x0028, 0x1054) # Rescale Type t29 = gdcm.Tag(0x0010, 0x0030) # PatientBirthDate t30 = gdcm.Tag(0x0010, 0x0040) # PatientSex t31 = gdcm.Tag(0x0008, 0x0020) # Study Date t32 = gdcm.Tag(0x0008, 0x1030) # Study Description s.AddTag(t1) s.AddTag(t2) s.AddTag(t3) s.AddTag(t4) s.AddTag(t5) s.AddTag(t6) s.AddTag(t7) s.AddTag(t8) s.AddTag(t10) s.AddTag(t11) s.AddTag(t12) s.AddTag(t13) s.AddTag(t14) s.AddTag(t15) s.AddTag(t16) s.AddTag(t17) s.AddTag(t18) s.AddTag(t19) s.AddTag(t20) s.AddTag(t21) s.AddTag(t22) s.AddTag(t23) s.AddTag(t29) s.AddTag(t30) s.AddTag(t31) s.AddTag(t32) b = s.Scan(filenames) # if no files in this directory dicomfiles = [] if (not b): qDebug("Empty directory") return dicomfiles study_list = [] series_list = [] series_count = {} image_count = {} for aFile in filenames: if (s.IsKey(aFile)): # existing DICOM file # qDebug("Scan "+aFile) is_multiframe = 0 pttv = gdcm.PythonTagToValue(s.GetMapping(aFile)) pttv.Start() patient_DOB = "" patient_sex = "" study_description = "" # iterate until the end: while (not pttv.IsAtEnd()): # get current value for tag and associated value: # if tag was not found, then it was simply not added to the internal std::map # Warning value can be None tag = pttv.GetCurrentTag() value = pttv.GetCurrentValue() if (tag == t1): #print ("PatientID->",value) patient_id = value elif (tag == t2): #print ("PatientName->",value) patient_name = value elif (tag == t29): # print ("PatientBirthDate->",value) patient_DOB = value elif (tag == t30): patient_sex = value elif (tag == t3): # print ("StudyID->",value) study_id = value elif (tag == t4): studyinstance_uid = value elif (tag == t31): # print ("StudyDate->",value) study_date = value elif (tag == t32): study_description = value elif (tag == t6): series_num = value # print ("SeriesNum->",value) elif (tag == t5): # print ("SeriesInstanceUID->",value) seriesinstance_uid = value elif (tag == t7): # print ("NumberOfFrame->",value) if (int(value) > 1): is_multiframe = int(value) else: is_multiframe = 0 elif (tag == t19): # print("Transfer Syntax->",value) pass elif (tag == t20): # print("SOP Class UID->",value) sopclass_uid = value #sop_ClassName = sopclass_uid.GetName() elif (tag == t21): # print("SOP Instance UID->",value) sopinstance_uid = value # increment iterator pttv.Next() # new StudyInstanceUID if (studyinstance_uid not in series_count.keys()): # Add to the study_list study_list.append([ patient_id, patient_name, patient_DOB, patient_sex, study_id, studyinstance_uid, study_date, study_description, 0 ]) # Add count series_count[studyinstance_uid] = 0 # new SeriesInstanceUID if (seriesinstance_uid not in image_count.keys()): # Add to the series_list series_list.append([ study_id, studyinstance_uid, seriesinstance_uid, series_num, sopclass_uid, sopinstance_uid, 0 ]) # Add count image_count[seriesinstance_uid] = 0 series_count[studyinstance_uid] += 1 if (is_multiframe == 0): image_count[seriesinstance_uid] += 1 else: image_count[seriesinstance_uid] += is_multiframe # print(series_count) # print(image_count) # for each study_list items update series_count from series_count(studyinstance_uid) for study in study_list: study[8] = series_count[study[5]] # for each series_list items update images_count from image_count(seriesinstance_uid) for series in series_list: series[6] = image_count[series[2]] #print(study_list) #print(series_list) return study_list, series_list
def setIp(self, ip): qDebug("Ip : " + ip)
def mouseReleaseEvent(self, button:int, screenX:int, screenY:int): qDebug('CanvasHandler::mouseReleaseEvent()')
def __show_lookup_table_cb(self): qDebug("< ShowLookupTable") if self.__lookup_table_visible: return self.__lookup_table_visible = True
def __commit_text_cb(self, text): qDebug("< CommitText : %s" % text[2]) self.commitText.emit(text[2])
def __current_im_cb(self, name, uniqueName, langCode): qDebug("< CurrentIM : %s %s %s" % (name, uniqueName, langCode))
def __update_preedit_cb(self, text, cursor_pos): qDebug("< UpdatePreeditText : text = %s, cursor_pos = %d" % (text, cursor_pos)) self.__preedit = text self.preeditChanged.emit()
def __enable_im_cb(self): qDebug("< EnableIM")
def __close_im_cb(self): qDebug("< CloseIM")
def focusOutEvent(self, event): qDebug('focusOut') self.driver.iface.FocusOut()
def focusInEvent(self, event): self.driver.iface.FocusIn() qDebug("focusIn : Engine = %s" % self.driver.engine())
def mousePressEvent(self, event): qDebug('mousePress') self.setFocus()
def __hide_aux_text_cb(self): qDebug("< HideAuxiliaryText") if not self.__aux_string_visible: return self.__aux_string_visible = False
def __delete_surrounding_text_cb(self, offset, nchar): qDebug("< DeleteSurroundingText : %d %d" % (offset, nchar))
def __update_lookup_table_cb(self, lookup_table, visible): qDebug("< UpdateLookupTable") self.__lookup_table = lookup_table self.__lookup_table_visible = True
def __update_formatted_preedit_cb(self, text, cursorpos): print(text) qDebug("< UpdateFormattedPreedit : %s" % cursorpos)
def __hide_lookup_table_cb(self): qDebug("< HideLookupTable") if not self.__lookup_table_visible: return self.__lookup_table_visible = False
def __forward_key_cb(self, keyval, state, type_): qDebug("< ForwardKey: %d %d %d" % (keyval, state, type_))
def setName(self, name): self.Joueur1.change_pseudo = name qDebug("Nom : " + name)
def __show_preedit_text_cb(self): qDebug("< ShowPreeditText") if self.__preedit_visible: return self.__preedit_visible = True self.preeditChanged.emit()
def startApplication(self): qDebug('CanvasHandler::startApplication()') self.__m_vtkFboItem.rendererInitialized.disconnect(self.startApplication)
def __hide_preedit_text_cb(self): qDebug("< HidePreeditText") if not self.__preedit_visible: return self.__preedit_visible = False self.preeditChanged.emit()
def execute(self): qDebug('CommandModelAdd::execute()') self.__m_vtkFboRenderer.renderer.addModelActor(self.__m_model) self.signal_conn.done.emit()
def __update_aux_text_cb(self, text, visible): qDebug("< UpdateAuxiliaryText") self.__aux_string = text self.__aux_string_visible = visible
def thread_complete(self): qDebug("Thread Complete") self.Scanning = False
def __show_aux_text_cb(self): qDebug("< ShowAuxiliaryText") if self.__aux_string_visible: return self.__aux_string_visible = True
def createRenderer(self): qDebug('FboItem::createRenderer') self.setVtkFboRenderer(FboRenderer()) return self.__m_vtkFboRenderer
def placeModel(self, model: Model): qDebug('ProcessingEngine::placeModel()') model.translateToPosition(0, 0)