Skip to content

collect_ground_truth

collect_ground_truth

collect_ground_truth(data_dir, external_gt_file)

To collect the ground truth from the user and save them to a csv file

Parameters

data_dir : path of the directory which the csv file should be saved

Source code in redesign_pipeline/utils/collect_ground_truth.py
 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
31
32
33
34
35
36
37
def collect_ground_truth(data_dir,external_gt_file):
    """
    To collect the ground truth from the user and save them to a csv file

    Parameters
    ----------

    data_dir : path of the directory which the csv file should be saved

    """
    if external_gt_file is not None:
        shutil.copy(external_gt_file, data_dir)

    else:

        ground_truth_file = os.path.join(data_dir,'ground_truth.csv')
        with open(ground_truth_file, 'w', newline="") as file:
            csv_file = csv.writer(file)
            csv_file.writerow(['HR', 'RR', 'SpO2', 'RMSSD', 'SDNN', 'PNN50', 'LF', 'HF'])
            print('\nPlease enter ground truth values below')
            # collect the ground truth from the user inputs
            HR = input("HR " + ": Enter HR: ")
            RR = input("RR " + ": Enter RR: ")
            SpO2 = input("SpO2 " + ": Enter SpO2: ")
            RMSSD = input("RMSSD " + ": Enter RMSSD: ")
            SDNN = input("SDNN " + ": Enter SDNN: ")
            PNN50 = input("PNN50 " + ": Enter PNN50: ")
            LF = input("LF " + ": Enter LF: ")
            HF = input("HF " + ": Enter HF: ")

            print('Thank you! data recorded\n')

            csv_file.writerow([HR, RR, SpO2, RMSSD, SDNN, PNN50, LF, HF])