Skip to content

Commit

Permalink
fixing error when no crop provided. this refs #50
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBilheux committed Feb 16, 2022
1 parent addfcc7 commit 4f9c9dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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']
Expand Down
14 changes: 2 additions & 12 deletions src/pyMBIR_UI/reconstruction_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand All @@ -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)

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4f9c9dd

Please sign in to comment.