class TestStructureTab: """Class to set up the OnkoDICOM main window for testing the structures tab.""" __test__ = False def __init__(self): # Load test DICOM files if platform.system() == "Windows": desired_path = "\\testdata\\DICOM-RT-TEST" elif platform.system() == "Linux" or platform.system() == "Darwin": desired_path = "/testdata/DICOM-RT-TEST" desired_path = os.path.dirname( os.path.realpath(__file__)) + desired_path selected_files = find_DICOM_files( desired_path) # list of DICOM test files file_path = os.path.dirname( os.path.commonprefix(selected_files)) # file path of DICOM files read_data_dict, file_names_dict = ImageLoading.get_datasets( selected_files) # Create patient dict container object patient_dict_container = PatientDictContainer() patient_dict_container.clear() patient_dict_container.set_initial_values(file_path, read_data_dict, file_names_dict) # Set additional attributes in patient dict container (otherwise program will crash and test will fail) if "rtss" in file_names_dict: dataset_rtss = dcmread(file_names_dict['rtss']) self.rois = ImageLoading.get_roi_info(dataset_rtss) dict_raw_contour_data, dict_numpoints = ImageLoading.get_raw_contour_data( dataset_rtss) dict_pixluts = ImageLoading.get_pixluts(read_data_dict) patient_dict_container.set("rois", self.rois) patient_dict_container.set("raw_contour", dict_raw_contour_data) patient_dict_container.set("num_points", dict_numpoints) patient_dict_container.set("pixluts", dict_pixluts) # Open the main window self.main_window = MainWindow() self.main_window.show() self.dicom_view = self.main_window.dicom_view self.new_polygons = {} slider_id = self.dicom_view.slider.value() self.curr_slice = self.dicom_view.patient_dict_container.get( "dict_uid")[slider_id]
class TestManipulateROI: """Class to set up the OnkoDICOM main window for testing the Manipulate ROI window.""" __test__ = False def __init__(self): # Load test DICOM files desired_path = Path.cwd().joinpath('test', 'testdata') # list of DICOM test files selected_files = find_DICOM_files(desired_path) # file path of DICOM files file_path = os.path.dirname(os.path.commonprefix(selected_files)) read_data_dict, file_names_dict = ImageLoading.get_datasets( selected_files) # Create patient dict container object patient_dict_container = PatientDictContainer() patient_dict_container.clear() patient_dict_container.set_initial_values(file_path, read_data_dict, file_names_dict) # Set additional attributes in patient dict container (otherwise # program will crash and test will fail) if "rtss" in file_names_dict: self.dataset_rtss = dcmread(file_names_dict['rtss']) self.rois = ImageLoading.get_roi_info(self.dataset_rtss) dict_raw_contour_data, dict_numpoints = \ ImageLoading.get_raw_contour_data(self.dataset_rtss) dict_pixluts = ImageLoading.get_pixluts(read_data_dict) patient_dict_container.set("rois", self.rois) patient_dict_container.set("raw_contour", dict_raw_contour_data) patient_dict_container.set("num_points", dict_numpoints) patient_dict_container.set("pixluts", dict_pixluts) # Open the main window self.main_window = MainWindow() self.main_window.show() # Open the manipulate ROI window self.structures_tab = self.main_window.structures_tab color_dict = self.structures_tab.color_dict self.roi_manipulate_handler = self.structures_tab.\ roi_manipulate_handler.show_roi_manipulate_options(color_dict) self.manipulate_window = self.structures_tab.\ roi_manipulate_handler.manipulate_window
class TestStructureTab: """Class to set up the OnkoDICOM main window for testing the structures tab.""" __test__ = False def __init__(self): # Load test DICOM files desired_path = Path.cwd().joinpath('test', 'testdata') selected_files = find_DICOM_files( desired_path) # list of DICOM test files file_path = os.path.dirname( os.path.commonprefix(selected_files)) # file path of DICOM files read_data_dict, file_names_dict = ImageLoading.get_datasets( selected_files) # Create patient dict container object patient_dict_container = PatientDictContainer() patient_dict_container.clear() patient_dict_container.set_initial_values(file_path, read_data_dict, file_names_dict) # Set additional attributes in patient dict container (otherwise # program will crash and test will fail) if "rtss" in file_names_dict: self.dataset_rtss = dcmread(file_names_dict['rtss']) patient_dict_container.set("existing_rtss_files", [file_names_dict['rtss']]) self.rois = ImageLoading.get_roi_info(self.dataset_rtss) dict_raw_contour_data, dict_numpoints = \ ImageLoading.get_raw_contour_data(self.dataset_rtss) dict_pixluts = ImageLoading.get_pixluts(read_data_dict) patient_dict_container.set("rois", self.rois) patient_dict_container.set("raw_contour", dict_raw_contour_data) patient_dict_container.set("num_points", dict_numpoints) patient_dict_container.set("pixluts", dict_pixluts) # Open the main window self.main_window = MainWindow() self.main_window.show() self.dicom_view = self.main_window.dicom_single_view self.new_polygons = {} slider_id = self.dicom_view.slider.value() self.curr_slice = self.dicom_view.patient_dict_container.get( "dict_uid")[slider_id]
class Controller: # Initialisation function that creates an instance of each window def __init__(self): self.welcome_window = QtWidgets.QMainWindow() self.open_patient_window = QtWidgets.QMainWindow() self.main_window = QtWidgets.QMainWindow() self.pyradi_progressbar = QtWidgets.QWidget() def show_welcome(self): """ Display welcome page """ self.welcome_window = WelcomeWindow() self.welcome_window.go_next_window.connect(self.show_open_patient) self.welcome_window.show() def show_open_patient(self): """ Display open patient window """ # Close all other open windows first if self.welcome_window.isVisible(): self.welcome_window.close() if self.main_window.isVisible(): self.main_window.close() self.open_patient_window = OpenPatientWindow() self.open_patient_window.patient_info_initialized.connect( self.show_main_window) self.open_patient_window.show() def show_main_window(self, patient_attributes): """ Displays the main patient window after completing the loading. :param patient_attributes: A tuple of (PatientDictContainer, ProgressWindow) :return: """ patient_dict_container = patient_attributes[0] progress_window = patient_attributes[1] self.main_window = MainWindow(patient_dict_container) self.main_window.open_patient_window.connect(self.show_open_patient) self.main_window.run_pyradiomics.connect(self.show_pyradi_progress) # Once the MainWindow has finished loading (which takes some time) close all the other open windows. progress_window.update_progress(("Loading complete!", 100)) progress_window.close() self.main_window.show() self.open_patient_window.close() def show_pyradi_progress(self, path, filepaths, target_path): """ Display pyradiomics progress bar """ self.pyradi_progressbar = PyradiProgressBar(path, filepaths, target_path) self.pyradi_progressbar.progress_complete.connect( self.close_pyradi_progress) self.pyradi_progressbar.show() def close_pyradi_progress(self): """ Close pyradiomics progress bar """ self.pyradi_progressbar.close()
class Controller: # Initialisation function that creates an instance of each window def __init__(self, default_directory=None): self.first_time_welcome_window = QtWidgets.QMainWindow() self.welcome_window = QtWidgets.QMainWindow() self.open_patient_window = QtWidgets.QMainWindow() self.main_window = QtWidgets.QMainWindow() self.batch_window = QtWidgets.QMainWindow() self.pyradi_progressbar = QtWidgets.QWidget() # This will contain a filepath of a folder that is dragged onto self.default_directory = default_directory self.image_fusion_window = QtWidgets.QMainWindow() self.pt_ct_window = QtWidgets.QMainWindow() # the executable icon def show_first_time_welcome(self): """ Display first time welcome page """ self.first_time_welcome_window = FirstTimeWelcomeWindow() self.first_time_welcome_window.update_directory.connect( self.update_default_directory) self.first_time_welcome_window.go_next_window.connect( self.show_open_patient) self.first_time_welcome_window.show() def update_default_directory(self, new_directory): self.default_directory = new_directory def show_welcome(self): """ Display welcome page """ self.welcome_window = WelcomeWindow() self.welcome_window.go_next_window.connect(self.show_open_patient) self.welcome_window.go_batch_window.connect(self.show_batch_window) self.welcome_window.show() def show_open_patient(self): """ Display open patient window """ # Close all other open windows first if self.welcome_window.isVisible(): self.welcome_window.close() if self.main_window.isVisible(): self.main_window.close() if self.first_time_welcome_window.isVisible(): self.first_time_welcome_window.close() # only initialize open_patient_window once if not isinstance(self.main_window, MainWindow): self.open_patient_window = OpenPatientWindow( self.default_directory) self.open_patient_window.go_next_window.connect( self.show_main_window) self.open_patient_window.show() # Run check_selected_items() upon open patient window is shown self.open_patient_window.check_selected_items() def show_main_window(self, progress_window): """ Displays the main patient window after completing the loading. :param progress_window: An instance of ProgressWindow :return: """ # Only initialize main window once if not isinstance(self.main_window, MainWindow): self.main_window = MainWindow() self.main_window.open_patient_window.connect( self.show_open_patient) self.main_window.run_pyradiomics.connect(self.show_pyradi_progress) self.main_window.pt_ct_signal.connect( self.show_pt_ct_select_window) # Connect the signal from GUIController self.main_window.image_fusion_signal.connect( self.show_image_fusion_select_window) else: self.main_window.update_ui() if isinstance(self.image_fusion_window, ImageFusionWindow): progress_window.update_progress( ("Registering Images...\nThis may take a few minutes.", 90)) self.main_window.update_image_fusion_ui() if isinstance(self.pt_ct_window, OpenPTCTPatientWindow): progress_window.update_progress(("Loading Viewer", 90)) self.main_window.load_pt_ct_tab() # Once the MainWindow has finished loading (which takes some # time), close all the other open windows. progress_window.update_progress(("Loading complete!", 100)) progress_window.close() self.main_window.show() self.open_patient_window.close() self.image_fusion_window.close() self.pt_ct_window.close() def show_batch_window(self): # Only initialise the batch processing window once if not isinstance(self.batch_window, BatchWindow): self.batch_window = BatchWindow() # Close the main window and show the batch processing window self.batch_window.show() self.welcome_window.close() def show_pyradi_progress(self, path, filepaths, target_path): """ Display pyradiomics progress bar """ self.pyradi_progressbar = PyradiProgressBar( path, filepaths, target_path) self.pyradi_progressbar.progress_complete.connect( self.close_pyradi_progress) self.pyradi_progressbar.show() def close_pyradi_progress(self): """ Close pyradiomics progress bar """ self.pyradi_progressbar.close() def show_image_fusion_select_window(self): # only initialize image fusion window if not isinstance(self.image_fusion_window, ImageFusionWindow): self.image_fusion_window = ImageFusionWindow( self.default_directory) self.image_fusion_window.go_next_window.connect( self.show_main_window) else: self.image_fusion_window.update_ui() self.image_fusion_window.show() def show_pt_ct_select_window(self): """ Loads and activates the OpenPTCTPatientWindow """ if not isinstance(self.pt_ct_window, OpenPTCTPatientWindow): self.pt_ct_window = OpenPTCTPatientWindow(self.default_directory) self.pt_ct_window.go_next_window.connect(self.show_main_window) self.pt_ct_window.show()