def __init__(self, user: str = Config.get('db_user'), password: str = Config.get('db_password'), host: str = Config.get('db_host'), db_name: str = Config.get('db_name')): self.__db_string__ = 'postgresql+psycopg2://' + user + ':' + password + '@' + host + '/' + db_name self.db = self.__make_connect() self.__create_tables()
def run_nn_proces(self): self.process.start( Config.get('app_dir') + '/res/run_HDense.bat', [ Config.get('app_dir') + self.__path_to_dicoms + self.__serie_name__, Config.get('app_dir') + '/res/H-DenseUNet-master_v1/data/TestData', 'test-volume-0', Config.get('app_dir') + self.__nn_segmegented_images, str(self.__rows) ])
def fill_fields(self): self.pacs_adres.setText(Config.get('pacs_adres')) self.pacs_login.setText(Config.get('pacs_login')) self.pacs_password.setText(Config.get('pacs_password')) self.db_host.setText(Config.get('db_host')) self.db_name.setText(Config.get('db_name')) self.db_user.setText(Config.get('db_user')) self.db_password.setText(Config.get('db_password')) if Config.get('dont_show_settings_startup'): self.dont_show_settings_startup.setChecked(True)
def generate_nn_bat(): path = Config.get('app_dir') + '/res/run_HDense.bat' content = ''' @ECHO OFF Rem args : %1 - input dicom dir path Rem %2 - output nifti path Rem %3 - output nifti file name Rem %4 - result save path Rem %5 - input size ECHO '##################' ECHO 'Script is starting with params: ' ECHO 'Input input path: ' %1 ECHO 'Output nifti dir path: ' %2 ECHO 'Output nifti file name: ' %3 ECHO 'Result save path: ' %4 ECHO 'Input size: ' %5 ECHO '#########################' del "{0}" /s /f /q ECHO 'Conda activate ...' call conda.bat activate H-DenseUNet ECHO 'Conda READY' ECHO 'Converting dicom to nifti ...' dcm2niix -f volume-0 -o %2 %1 del "{1}" /s /f /q ECHO 'Converting dicom to nifti - DONE' ECHO 'Preprocessing start ...' cd "{2}" ECHO 'Starting preprocesing...' python preprocessing.py ECHO 'Preprocessing - DONE' ECHO 'Starting H-DenseUNet segmentation....' python test.py -input_size %5 '''.format( Config.get('app_dir') + '\\res\\H-DenseUNet-master_v1\\data\\TestData\\*.*', Config.get('app_dir') + '\\res\\H-DenseUNet-master_v1\\data\\TestData\\volume-0.json', Config.get('app_dir') + '\\res\\H-DenseUNet-master_v1') f = open(path, "w") f.write(content) f.close()
def finish_nn_segmentation(self): self.process_modal.print_output('Process finished') file_dialog = QFileDialog() file_path = file_dialog.getSaveFileName(self.process.parent(), 'Save mask as nifti', 'c:/', 'Nifit (*.nii);;') self.rotate_nifit( Config.get('app_dir') + '/res/H-DenseUNet-master_v1/results/test-segmentation-0.nii', file_path[0]) self.process_modal.startButton.setText("Exit") self.process_modal.startButton.setEnabled(True) self.process_modal.startButton.clicked.disconnect() self.process_modal.startButton.clicked.connect( self.process_modal.close)
def send_segmented(series_name): s = open_connection() s.send('GET {0}'.format(series_name).encode()) file_path = Config.get( 'app_dir') + '/data/.segemented_images/test-segmentation-0.nii' if os.path.exists(file_path): file = open(file_path, 'rb') while True: pack = file.read(BUFFER_SIZE) s.send(pack) if not pack: file.close() s.close() break else: s.close()
# This Python file uses the following encoding: utf-8 import os import sys from PySide2 import QtWidgets from PySide2.QtWidgets import QApplication from app.ctrl.Utils import get_app_dir, start_app from app.gui.Dialogs.LoginDialog import LoginDialog from app.gui.Dialogs.SettingsDialog import SettingDialog from app.gui.MainWindow import App from app.ctrl.SettingsCtrl import Config if __name__ == '__main__': Config.update('app_dir', get_app_dir()) start_app() app = QApplication(sys.argv) if not Config.get('dont_show_settings_startup'): sett = SettingDialog() sett.show() sett.exec_() # With Login login = LoginDialog() if login.exec_() == QtWidgets.QDialog.Accepted: ex = App(login.username_auth()) sys.exit(app.exec_()) # Without login
def update_config(self): if self.pacs_adres.text().strip() or self.pacs_login.text().strip( ) or self.pacs_password.text().strip(): Config.update('app_dir', get_app_dir()) Config.update('pacs_adres', self.pacs_adres.text()) Config.update('pacs_login', self.pacs_login.text()) Config.update('pacs_password', self.pacs_password.text()) Config.update('db_host', self.db_host.text()) Config.update('db_name', self.db_name.text()) Config.update('db_user', self.db_user.text()) Config.update('db_password', self.db_password.text()) Config.update('dont_show_settings_startup', self.dont_show_settings_startup.isChecked()) super().accept() else: QMessageBox.warning(self, 'Error', 'All field are required')