@@ -40,6 +40,7 @@ def main():
40
40
)
41
41
@click .option (
42
42
"--mode" ,
43
+ default = "show" ,
43
44
help = "'show' to display meta information only or 'save' to save "
44
45
"the meta information, default=show" ,
45
46
)
@@ -52,23 +53,43 @@ def main():
52
53
def slide_info (wsi_input , output_dir , file_types , mode , workers = None ):
53
54
"""Displays or saves WSI metadata"""
54
55
file_types = tuple (file_types .split (", " ))
56
+
55
57
if os .path .isdir (wsi_input ):
56
58
files_all = utils .misc .grab_files_from_dir (
57
59
input_path = wsi_input , file_types = file_types
58
60
)
61
+ if output_dir is None and mode == "save" :
62
+ input_dir , _ , _ = utils .misc .split_path_name_ext (wsi_input )
63
+ output_dir = pathlib .Path (input_dir ).joinpath ("meta" )
64
+
59
65
elif os .path .isfile (wsi_input ):
60
66
files_all = [
61
67
wsi_input ,
62
68
]
69
+ if output_dir is None and mode == "save" :
70
+ input_dir , _ , _ = utils .misc .split_path_name_ext (wsi_input )
71
+ output_dir = pathlib .Path (input_dir ).joinpath (".." ).joinpath ("meta" )
63
72
else :
64
73
raise ValueError ("wsi_input path is not valid" )
65
74
66
75
print (files_all )
67
76
68
- dataloader .slide_info .slide_info (
69
- input_path = files_all , output_dir = output_dir , mode = mode , workers = workers ,
77
+ slide_params = dataloader .slide_info .slide_info (
78
+ input_path = files_all , workers = workers ,
70
79
)
71
80
81
+ if mode == "show" :
82
+ for slide_param in slide_params :
83
+ print (slide_param )
84
+
85
+ if mode == "save" :
86
+ output_dir .mkdir (parents = True , exist_ok = True )
87
+ for slide_param in slide_params :
88
+ utils .misc .save_yaml (slide_param ,
89
+ pathlib .Path (output_dir )
90
+ .joinpath (slide_param ["file_name" ] + ".yaml" ))
91
+ print ("Meta files saved at " + str (output_dir ))
92
+
72
93
73
94
@main .command ()
74
95
@click .option ("--wsi_input" , help = "Path to WSI file" )
0 commit comments