From 4f9c9dd7e2f96ebb3d3297476e93b150242a8c9b Mon Sep 17 00:00:00 2001 From: JeanBilheux Date: Wed, 16 Feb 2022 16:23:16 -0500 Subject: [PATCH] fixing error when no crop provided. this refs #50 --- .../advanced_settings_initialization.py | 10 +++++----- src/pyMBIR_UI/reconstruction_launcher.py | 14 ++------------ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/pyMBIR_UI/advanced_settings/advanced_settings_initialization.py b/src/pyMBIR_UI/advanced_settings/advanced_settings_initialization.py index 0e88ef3..50c28c0 100644 --- a/src/pyMBIR_UI/advanced_settings/advanced_settings_initialization.py +++ b/src/pyMBIR_UI/advanced_settings/advanced_settings_initialization.py @@ -57,12 +57,12 @@ def from_config_to_session_dict(self): session_dict = self.parent.session_dict if session_dict.get('crop', None) is None: image_width = self.parent.image_size['width'] - n_vox_x = int(int(image_width / vox_xy_to_use) * det_x_to_use) - n_vox_y = int(int(image_width / vox_xy_to_use) * det_x_to_use) + n_vox_x = int(int(image_width / vox_xy_to_use) * det_x_to_use) - 1 + n_vox_y = int(int(image_width / vox_xy_to_use) * det_x_to_use) - 1 n_vox_x_y_value = n_vox_x else: crop_width = session_dict['crop']['width'] - n_vox_x_y_value = int(int(crop_width / vox_xy_to_use) * det_x_to_use) + n_vox_x_y_value = int(int(crop_width / vox_xy_to_use) * det_x_to_use) - 1 n_vox_x = n_vox_x_y_value n_vox_y = n_vox_x_y_value n_vox_x_to_use = n_vox_x @@ -74,10 +74,10 @@ def from_config_to_session_dict(self): else: if session_dict.get('crop', None) is None: image_height = self.parent.image_size['height'] - n_vox_z = int(int(image_height / vox_z_to_use) * det_y_to_use) + n_vox_z = int(int(image_height / vox_z_to_use) * det_y_to_use) - 1 else: crop_height = session_dict['crop']['to slice - from slice'] - n_vox_z = int(int(crop_height / vox_z_to_use) * det_y_to_use) + n_vox_z = int(int(crop_height / vox_z_to_use) * det_y_to_use) - 1 n_vox_z_to_use = n_vox_z write_output_flag = config['write output'] diff --git a/src/pyMBIR_UI/reconstruction_launcher.py b/src/pyMBIR_UI/reconstruction_launcher.py index 63fcad2..d510973 100644 --- a/src/pyMBIR_UI/reconstruction_launcher.py +++ b/src/pyMBIR_UI/reconstruction_launcher.py @@ -138,12 +138,8 @@ def run(self): dictionary_of_arguments = o_dictionary.get_dictionary() dictionary_of_arguments['running_mode'] = 'batch' - base_output_folder = os.path.basename(dictionary_of_arguments['data_path']) full_output_folder = os.path.join(dictionary_of_arguments['op_path']) - # full_output_folder = os.path.join(dictionary_of_arguments['op_path'], base_output_folder + - # "_pymbir_reconstructed") -# dictionary_of_arguments['op_path'] = full_output_folder logging.info(f"Final image will be output in {full_output_folder}") make_folder(dictionary_of_arguments['op_path']) logging.info(f"Making sure output folder ({full_output_folder}) exists!") @@ -161,9 +157,9 @@ def run(self): self.dictionary_of_arguments = dictionary_of_arguments - logging.info(f"-> Saving config file to be called from command line script") home_folder = os.path.expanduser("~") json_file_name = os.path.join(home_folder, "config_batch_mode.json") + logging.info(f"-> Saving config file to be called from command line script into {json_file_name}") with open(json_file_name, 'w') as json_file: json.dump(dictionary_of_arguments, json_file) @@ -173,8 +169,7 @@ def run(self): proc = subprocess.Popen(['python', script_exe, '--input_json', - json_file_name, -], + json_file_name], shell=False) self.batch_process_id = proc @@ -292,14 +287,9 @@ def check_output_file(self): o_event.update_output_plot() def check_output_3d_volume(self): - print("in check 3D") - base_output_folder = os.path.basename(self.dictionary_of_arguments['data_path']) output_folder = self.dictionary_of_arguments['op_path'] - print(f"output_folder: {output_folder}") list_tiff_files_in_output_folder = glob.glob(os.path.join(output_folder, "*.tif?")) - print(f"list tiff:{list_tiff_files_in_output_folder}") number_of_files_in_output_folder = len(list_tiff_files_in_output_folder) - print(f"number of files: {number_of_files_in_output_folder}") if number_of_files_in_output_folder == 0: self.parent.ui.tabWidget_3.setTabEnabled(1, False) return