diff --git a/codes/ecg-image-generator/README.md b/codes/ecg-image-generator/README.md index 4adf60d..7765c0a 100644 --- a/codes/ecg-image-generator/README.md +++ b/codes/ecg-image-generator/README.md @@ -63,6 +63,8 @@ The basic mode of the tool creates ECG images without distortions. The mode of o - `--random_grid_present`: Probability of the generated images having the ECG paper grid; type: Float, default: 1 (adds the grid to all images). Make sure that `--random_grid_present` $\in$ [0, 1]. When 0, the images do not have the background grid. - `--random_add_header`: Probability of adding printed text to a random set of images; type: Float, default: 0 (no text added). Make sure that `--random_add_header` $\in$ [0, 1]. If `--print_header` is True, code prints text on all the images regardless of the `--random_add_header` attribute. - `--random_bw`: Make random set of images black and white controlled by this parameter; type: Float, default: 0 (generates colored ECG). Make sure that `--random_bw` $\in$ [0, 1]. +- `--standard_grid_color`: Color of the grid lines, 1: brown, 2: pink, 3: blue, 4: green, 5(Default): red .Make sure that `standard_grid_color` $\in$ [1, 5], type: int +- `--random_grid_color`: Generates random colors for the gridlines, If `'--random_bw` > 0, then the color of gridlines for the non black and white ECG images is picked randomly. Default: False. - `--deterministic_lead`: Add lead names to all generated images; default: True - `--store_text_bouding_box`: Store bounding box coordinates for the lead names in a text file in the folder output_directory/text_bouding_box; default: False. - `--bbox`: Store bounding box coordinates for every individual ECG lead signal in a text file in the folder output_directory/lead_bouding_box; default: False. diff --git a/codes/ecg-image-generator/ecg_plot.py b/codes/ecg-image-generator/ecg_plot.py index 22814f8..5593099 100644 --- a/codes/ecg-image-generator/ecg_plot.py +++ b/codes/ecg-image-generator/ecg_plot.py @@ -34,45 +34,21 @@ 'height' : 8.5 } -#standard_major_colors = {'colour1' : (1,0.6823,0.776), - #'colour2' : (1,0.796,0.866), - #'colour3' : (0.933,0.8235,0.8), - #'colour4' : (0.996,0.807,0.8039), - #'colour5' : (0.611,0.627,0.647), - #'colour6' : (0.4901,0.498,0.513), - #'colour7' : (0.4274,0.196,0.1843), - #'colour8' : (0.992,0.7529,0.7254), - #'colour9' : (0.9215,0.9372,0.9725) - #} - -standard_major_colors = {'colour1' : (1,0.6823,0.776), - 'colour2' : (1,0.796,0.866), - 'colour3' : (0.933,0.8235,0.8), - 'colour4' : (0.996,0.807,0.8039), - 'colour5' : (0.4274,0.196,0.1843), - 'colour6' : (0.992,0.7529,0.7254) +standard_major_colors = {'colour1' : (0.4274,0.196,0.1843), #brown + 'colour2' : (1,0.796,0.866), #pink + 'colour3' : (0.0,0.0, 0.4), #blue + 'colour4' : (0,0.3,0.0), #green + 'colour5' : (1,0,0) #red } -standard_minor_colors = {'colour1' : (0.9843,0.9019,0.9529), +standard_minor_colors = {'colour1' : (0.5882,0.4196,0.3960), 'colour2' : (0.996,0.9294,0.9725), - 'colour3' : (0.9529,0.8745,0.8549), - 'colour4' : (0.996,0.9529,0.9529), - 'colour5' : (0.5882,0.4196,0.3960), - 'colour6' : (0.996,0.8745,0.8588) + 'colour3' : (0.0,0, 0.7), + 'colour4' : (0,0.8,0.3), + 'colour5' : (0.996,0.8745,0.8588) } -#standard_minor_colors = {'colour1' : (0.9843,0.9019,0.9529), - #'colour2' : (0.996,0.9294,0.9725), - #'colour3' : (0.9529,0.8745,0.8549), - #'colour4' : (0.996,0.9529,0.9529), - #'colour5' : (0.7607,0.7725,0.7843), - #'colour6' : (0.6039,0.6235,0.6274), - #'colour7' : (0.5882,0.4196,0.3960), - #'colour8' : (0.996,0.8745,0.8588), - #'colour9' : (0.9568,0.9686,0.9843) - #} - papersize_values = {'A0' : (33.1,46.8), 'A1' : (33.1,23.39), 'A2' : (16.54,23.39), @@ -202,13 +178,13 @@ def ecg_plot( fig.suptitle(title) #Mark grid based on whether we want black and white or colour - + if (style == 'bw'): color_major = (0.4,0.4,0.4) color_minor = (0.75, 0.75, 0.75) color_line = (0,0,0) - elif(standard_colours): - random_colour_index = randint(1,6) + elif(standard_colours > 0): + random_colour_index = standard_colours color_major = standard_major_colors['colour'+str(random_colour_index)] color_minor = standard_minor_colors['colour'+str(random_colour_index)] randcolorindex_grey = randint(0,24) 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 72f69f5..0cae8b8 100644 --- a/codes/ecg-image-generator/gen_ecg_image_from_data.py +++ b/codes/ecg-image-generator/gen_ecg_image_from_data.py @@ -45,6 +45,8 @@ def get_parser(): parser.add_argument('--random_resolution',action="store_true",default=False) parser.add_argument('--random_padding',action="store_true",default=False) + parser.add_argument('--random_grid_color',action="store_true",default=False) + parser.add_argument('--standard_grid_color', type=int, default=5) parser.add_argument('--random_dc',type=float,default=0) parser.add_argument('--random_grid_present',type=float,default=1) parser.add_argument('--random_add_header',type=float,default=0) @@ -112,7 +114,10 @@ def run_single_file(args): font = os.path.join('Fonts',random.choice(os.listdir("Fonts"))) if(args.random_bw == 0): - standard_colours = random.choice((True,False)) + if args.random_grid_color == False: + standard_colours = args.standard_grid_color + else: + standard_colours = -1 else: standard_colours = False 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 b61e675..8c2ebbb 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 @@ -43,6 +43,8 @@ def get_parser(): parser.add_argument('--random_resolution',action="store_true",default=False) parser.add_argument('--random_padding',action="store_true",default=False) + parser.add_argument('--random_grid_color',action="store_true",default=False) + parser.add_argument('--standard_grid_color', type=int, default=5) parser.add_argument('--random_dc',type=float,default=0) parser.add_argument('--random_grid_present',type=float,default=1) parser.add_argument('--random_add_header',type=float,default=0)