-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbones_info_extractor.py
More file actions
30 lines (26 loc) · 1.11 KB
/
bones_info_extractor.py
File metadata and controls
30 lines (26 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import csv
import os
def get_bone_ages(is_test = False):
"""
extracts bone's info from the bones csv file and returns two dictionaries bones_ages_dict , bones_is_male_dict
that given the bone's id return it's age and it's gender
--test file doesn't contain the ages of the bones, we should consider this.
"""
if(is_test):
raise NotImplementedError
file_name = "boneage-test-dataset.csv" if is_test else "boneage-training-dataset.csv"
with open(os.path.dirname(os.path.realpath(__file__)) + '\\' + file_name) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
bones_ages_dict = {}
bones_is_male_dict = {}
for row in csv_reader:
if line_count == 0:
line_count += 1
else:
bone_id = int(row[0])
bone_age = int(row[1])
is_male = bool(row[2])
bones_ages_dict[bone_id] = bone_age
bones_is_male_dict[bone_id] = is_male
return bones_ages_dict , bones_is_male_dict