-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_album_arguments.py
73 lines (50 loc) · 1.88 KB
/
generate_album_arguments.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import pandas as pd
import yaml
import os
import json
# From functions_common module
def read_parameters():
parameters = dict()
with open("base/parameters.yml") as file:
parameters = yaml.load(file, Loader=yaml.FullLoader)
with open("local/parameters.yml") as file:
parameters_local = yaml.load(file, Loader=yaml.FullLoader)
# overwrite global parameters with local setting
for key in parameters_local:
parameters[key] = parameters_local[key]
return parameters
def read_key_file(parameters):
file_path = parameters['data_folder'] + parameters["key_file_path"]
key_file = pd.read_excel(file_path)
return key_file
### read parameters
parameters = read_parameters()
print("#" * 5, "parameters", "#" * 5)
print(parameters)
key_file = read_key_file(parameters)
print("#" * 5, "key_file", "#" * 5)
print(key_file.head())
data_path = parameters["data_folder"]
folder_2d_data = "/03_Preprocessed_Data/01_2D/"
folder_3d_data = "/03_Preprocessed_Data/02_3D/"
folder_macrophage_annotations = '/04_Processed_Data/01_Annotated_Macrophages/'
use_gpu = parameters["use_gpu"]
output_folder = parameters["output_folder"]
experiments = "annotated"
#experiments = "all"
param_list = []
for index, row in key_file.iterrows():
short_name = str(row["short_name"])
file_path = data_path + folder_3d_data + short_name + ".tif"
csv_path = data_path + folder_macrophage_annotations + short_name + ".tif"
# print([index, row])
if not os.path.exists(file_path):
continue
if (experiments == "annotated") and (not row["macrophages_annotated"]):
print("No annotation available for %s" % short_name)
continue
# print("open image file %s" % file_path)
args = {'image_filename':file_path, 'csv_filename':csv_path}
param_list += [args]
with open('arguments.json', 'w') as fout:
json.dump(param_list, fout)