From 1053c238589cc2fa48223f92ed4fdfd89b814e68 Mon Sep 17 00:00:00 2001 From: Deepanshi Date: Fri, 12 Jan 2024 13:35:47 -0500 Subject: [PATCH] ecg gen: resolution bug fix --- codes/ecg-image-generator/ecg_plot.py | 8 ++++---- codes/ecg-image-generator/gen_ecg_image_from_data.py | 4 ++-- .../ecg-image-generator/gen_ecg_images_from_data_batch.py | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/codes/ecg-image-generator/ecg_plot.py b/codes/ecg-image-generator/ecg_plot.py index 5c2b301..fe3980d 100644 --- a/codes/ecg-image-generator/ecg_plot.py +++ b/codes/ecg-image-generator/ecg_plot.py @@ -16,8 +16,8 @@ standard_values = {'y_grid_size' : 0.5, 'x_grid_size' : 0.2, - 'y_grid_inch' : 0.196, - 'x_grid_inch' : 0.196, + 'y_grid_inch' : 5/25.4, + 'x_grid_inch' : 5/25.4, 'grid_line_width' : 0.5, 'lead_name_offset' : 0.5, 'lead_fontsize' : 11, @@ -172,8 +172,8 @@ def ecg_plot( width = papersize_values[papersize][1] height = papersize_values[papersize][0] - y_grid = standard_values['y_grid_inch'] + random_sampler - x_grid = standard_values['x_grid_inch'] + random_sampler + y_grid = standard_values['y_grid_inch'] + x_grid = standard_values['x_grid_inch'] y_grid_dots = y_grid*resolution x_grid_dots = x_grid*resolution diff --git a/codes/ecg-image-generator/gen_ecg_image_from_data.py b/codes/ecg-image-generator/gen_ecg_image_from_data.py index fdca024..b6ff1e3 100644 --- a/codes/ecg-image-generator/gen_ecg_image_from_data.py +++ b/codes/ecg-image-generator/gen_ecg_image_from_data.py @@ -88,8 +88,8 @@ def writeCSV(args): if args.start_index != -1: writer.writerow(["filename","xgrid","ygrid","lead_name","start","end"]) -def run_single_file(args): - if args.seed != -1: +def run_single_file(args): + if hasattr(args, 'st') == True: random.seed(args.seed) filename = args.input_file diff --git a/codes/ecg-image-generator/gen_ecg_images_from_data_batch.py b/codes/ecg-image-generator/gen_ecg_images_from_data_batch.py index 9bb8d8e..6fd12f9 100644 --- a/codes/ecg-image-generator/gen_ecg_images_from_data_batch.py +++ b/codes/ecg-image-generator/gen_ecg_images_from_data_batch.py @@ -72,6 +72,7 @@ def get_parser(): return parser def run(args): + random.seed(args.seed) if os.path.isabs(args.input_directory) == False: args.input_directory = os.path.normpath(os.path.join(os.getcwd(), args.input_directory))