Skip to content

Commit

Permalink
ecg gen: printed template fix
Browse files Browse the repository at this point in the history
  • Loading branch information
deepanshi-s committed Jan 24, 2024
1 parent 4beea3a commit 2f8282a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
27 changes: 14 additions & 13 deletions codes/ecg-image-generator/TemplateFiles/generate_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ def generate_template(header_file):
attributes = {}
attributes['Date'] = fields.base_date
attributes['Time'] = str(fields.base_time)
attributes['Name'] = filename.split('/')[-1]
attributes['ID'] = str(str(random.randint(10**(8-1), (10**8)-1)))
attributes['Name'] = 'Name: ' + filename.split('/')[-1]
attributes['ID'] = 'ID: ' #+ str(str(random.randint(10**(8-1), (10**8)-1)))

if attributes['Date'] == None:
attributes['Date'] = date.today()

dates_bet = attributes['Date'] - test_date1
total_days = dates_bet.days
Expand All @@ -59,19 +57,22 @@ def generate_template(header_file):
val = val.replace(" ", "")
attributes[str(col)] = val

if 'Age' in attributes:
attributes['DOB'] = attributes['Date'] - timedelta(days=int(attributes['Age'])*365)
if 'DOB' in attributes.keys():
attributes['DOB'] = 'DOB: ' + attributes['DOB']
if 'Age' in attributes.keys():
attributes['DOB'] += '(Age: ' + attributes['Age'] + ' yrs)'
else:
attributes['DOB'] = test_date1 + timedelta(days=randay)
attributes['Age'] = str(attributes['Date'].year - attributes['DOB'].year)

attributes['DOB'] = str(attributes['DOB']) + '(' + str(attributes['Age']) + 'yrs)'
attributes['DOB'] = 'Age: ' + attributes['Age'] + ' yrs'

if attributes['Weight'] != '':
attributes['Weight'] += ' kgs'
attributes['Weight'] = 'Weight: ' + attributes['Weight'] + ' Kgs'

attributes['Height'] = 'Height: ' + attributes['Height']

attributes['Date'] = str(attributes['Date'])
attributes['Date'] = 'Date: '+ attributes['Date'] + ', ' + attributes['Time']
attributes['Sex'] = 'Sex: ' + attributes['Sex']

attributes['Date'] = str(attributes['Date']) + ', ' + attributes['Time']

printedText = {}
printedText[0] = ['Name', 'ID', 'Date']
printedText[1] = ['DOB', 'Height', 'Weight']
Expand Down
5 changes: 1 addition & 4 deletions codes/ecg-image-generator/ecg_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,7 @@ def ecg_plot(
for l in range(0, len(printed_text), 1):

for j in printed_text[l]:
if j == 'ID':
curr_l = 'ID: '
else:
curr_l = ''
curr_l = ''
if j in attributes.keys():
curr_l += str(attributes[j])
ax.text(x_offset, y_offset, curr_l, fontsize=lead_fontsize)
Expand Down

0 comments on commit 2f8282a

Please sign in to comment.