14
14
15
15
def aggregate_vesicle_train_data (roots , test_tomograms , conditions , resolutions ):
16
16
tomo_names = []
17
- tomo_vesicles = []
17
+ tomo_vesicles_all , tomo_vesicles_imod = [], []
18
18
tomo_condition = []
19
19
tomo_resolution = []
20
20
tomo_train = []
@@ -43,14 +43,19 @@ def aggregate_vesicle_train_data(roots, test_tomograms, conditions, resolutions)
43
43
except KeyError :
44
44
tomo_name = fname
45
45
46
- n_label_sets = len (f ["labels" ])
47
- if n_label_sets > 2 :
48
- print (tomo_path , "contains the following labels:" , list (f ["labels" ].keys ()))
49
- seg = f ["labels/vesicles" ][:]
50
- n_vesicles = len (np .unique (seg )) - 1
46
+ if "labels/vesicles/combined_vesicles" in f :
47
+ all_vesicles = f ["labels/vesicles/combined_vesicles" ][:]
48
+ imod_vesicles = f ["labels/vesicles/masked_vesicles" ][:]
49
+ n_vesicles_all = len (np .unique (all_vesicles )) - 1
50
+ n_vesicles_imod = len (np .unique (imod_vesicles )) - 2
51
+ else :
52
+ vesicles = f ["labels/vesicles" ][:]
53
+ n_vesicles_all = len (np .unique (vesicles )) - 1
54
+ n_vesicles_imod = n_vesicles_all
51
55
52
56
tomo_names .append (tomo_name )
53
- tomo_vesicles .append (n_vesicles )
57
+ tomo_vesicles_all .append (n_vesicles_all )
58
+ tomo_vesicles_imod .append (n_vesicles_imod )
54
59
tomo_condition .append (this_condition )
55
60
tomo_resolution .append (this_resolution )
56
61
tomo_train .append ("test" if fname in this_test_tomograms else "train/val" )
@@ -60,7 +65,8 @@ def aggregate_vesicle_train_data(roots, test_tomograms, conditions, resolutions)
60
65
"condition" : tomo_condition ,
61
66
"resolution" : tomo_resolution ,
62
67
"used_for" : tomo_train ,
63
- "vesicle_count" : tomo_vesicles ,
68
+ "vesicle_count_all" : tomo_vesicles_all ,
69
+ "vesicle_count_imod" : tomo_vesicles_imod ,
64
70
})
65
71
66
72
os .makedirs ("data_summary" , exist_ok = True )
@@ -70,43 +76,43 @@ def aggregate_vesicle_train_data(roots, test_tomograms, conditions, resolutions)
70
76
def vesicle_train_data ():
71
77
roots = {
72
78
"01" : {
73
- "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/extracted/20240909_cp_datatransfer /01_hoi_maus_2020_incomplete" , # noqa
79
+ "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2 /01_hoi_maus_2020_incomplete" , # noqa
74
80
"test" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/01_hoi_maus_2020_incomplete" , # noqa
75
81
},
76
82
"02" : {
77
- "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/extracted/20240909_cp_datatransfer /02_hcc_nanogold" , # noqa
83
+ "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2 /02_hcc_nanogold" , # noqa
78
84
"test" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/02_hcc_nanogold" , # noqa
79
85
},
80
86
"03" : {
81
- "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/extracted/20240909_cp_datatransfer /03_hog_cs1sy7" , # noqa
87
+ "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2 /03_hog_cs1sy7" , # noqa
82
88
"test" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/03_hog_cs1sy7" , # noqa
83
89
},
84
90
"04" : {
85
91
"train" : "" ,
86
92
"test" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/ground_truth/04Dataset_for_vesicle_eval/" , # noqa
87
93
},
88
94
"05" : {
89
- "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/extracted/20240909_cp_datatransfer /05_stem750_sv_training" , # noqa
95
+ "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2 /05_stem750_sv_training" , # noqa
90
96
"test" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/05_stem750_sv_training" , # noqa
91
97
},
92
98
"07" : {
93
- "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/extracted/20240909_cp_datatransfer /07_hoi_s1sy7_tem250_ihgp" , # noqa
99
+ "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2 /07_hoi_s1sy7_tem250_ihgp" , # noqa
94
100
"test" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/07_hoi_s1sy7_tem250_ihgp" , # noqa
95
101
},
96
102
"09" : {
97
- "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/extracted/20240909_cp_datatransfer /09_stem750_66k" , # noqa
103
+ "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2 /09_stem750_66k" , # noqa
98
104
"test" : "" ,
99
105
},
100
106
"10" : {
101
- "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/extracted/20240909_cp_datatransfer /10_tem_single_release" , # noqa
107
+ "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2 /10_tem_single_release" , # noqa
102
108
"test" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/10_tem_single_release" , # noqa
103
109
},
104
110
"11" : {
105
- "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/extracted/20240909_cp_datatransfer /11_tem_multiple_release" , # noqa
111
+ "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2 /11_tem_multiple_release" , # noqa
106
112
"test" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/11_tem_multiple_release" , # noqa
107
113
},
108
114
"12" : {
109
- "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/extracted/20240909_cp_datatransfer /12_chemical_fix_cryopreparation" , # noqa
115
+ "train" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2 /12_chemical_fix_cryopreparation" , # noqa
110
116
"test" : "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/12_chemical_fix_cryopreparation" , # noqa
111
117
},
112
118
}
@@ -397,6 +403,11 @@ def vesicle_domain_adaptation_data():
397
403
"MF_05649_P-09175-E_06.h5" , "MF_05646_C-09175-B_001B.h5" , "MF_05649_P-09175-E_07.h5" ,
398
404
"MF_05649_G-09175-C_001.h5" , "MF_05646_C-09175-B_002.h5" , "MF_05649_G-09175-C_04.h5" ,
399
405
"MF_05649_P-09175-E_05.h5" , "MF_05646_C-09175-B_000.h5" , "MF_05646_C-09175-B_001.h5"
406
+ ],
407
+ "frog" : [
408
+ "block10U3A_three.h5" , "block30UB_one_two.h5" , "block30UB_two.h5" , "block10U3A_one.h5" ,
409
+ "block184B_one.h5" , "block30UB_three.h5" , "block10U3A_two.h5" , "block30UB_four.h5" ,
410
+ "block30UB_one.h5" , "block10U3A_five.h5" ,
400
411
]
401
412
}
402
413
@@ -439,13 +450,42 @@ def vesicle_domain_adaptation_data():
439
450
aggregate_da (roots , train_tomograms , test_tomograms , resolutions )
440
451
441
452
453
+ def get_n_images_frog ():
454
+ root = "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/rizzoli/extracted/upsampled_by2"
455
+ tomos = ["block10U3A_three.h5" , "block30UB_one_two.h5" , "block30UB_two.h5" , "block10U3A_one.h5" ,
456
+ "block184B_one.h5" , "block30UB_three.h5" , "block10U3A_two.h5" , "block30UB_four.h5" ,
457
+ "block30UB_one.h5" , "block10U3A_five.h5" ]
458
+
459
+ n_images = 0
460
+ for tomo in tomos :
461
+ path = os .path .join (root , tomo )
462
+ with h5py .File (path , "r" ) as f :
463
+ n_images += f ["raw" ].shape [0 ]
464
+ print (n_images )
465
+
466
+
467
+ def get_image_sizes_tem_2d ():
468
+ root = "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/2D_data/maus_2020_tem2d_wt_unt_div14_exported_scaled/good_for_DAtraining/maus_2020_tem2d_wt_unt_div14_exported_scaled" # noqa
469
+ tomos = [
470
+ "MF_05649_P-09175-E_06.h5" , "MF_05646_C-09175-B_001B.h5" , "MF_05649_P-09175-E_07.h5" ,
471
+ "MF_05649_G-09175-C_001.h5" , "MF_05646_C-09175-B_002.h5" , "MF_05649_G-09175-C_04.h5" ,
472
+ "MF_05649_P-09175-E_05.h5" , "MF_05646_C-09175-B_000.h5" , "MF_05646_C-09175-B_001.h5"
473
+ ]
474
+ for tomo in tomos :
475
+ path = os .path .join (root , tomo )
476
+ with h5py .File (path , "r" ) as f :
477
+ print (f ["raw" ].shape )
478
+
479
+
442
480
def main ():
443
481
# active_zone_train_data()
444
482
# compartment_train_data()
445
483
# mito_train_data()
446
- # vesicle_train_data()
484
+ vesicle_train_data ()
447
485
448
- vesicle_domain_adaptation_data ()
486
+ # vesicle_domain_adaptation_data()
487
+ # get_n_images_frog()
488
+ # get_image_sizes_tem_2d()
449
489
450
490
451
491
main ()
0 commit comments