Skip to content

Commit cb693b1

Browse files
Update data summaries
1 parent 51165a5 commit cb693b1

6 files changed

+60
-20
lines changed

scripts/aggregate_data_information.py

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
def aggregate_vesicle_train_data(roots, test_tomograms, conditions, resolutions):
1616
tomo_names = []
17-
tomo_vesicles = []
17+
tomo_vesicles_all, tomo_vesicles_imod = [], []
1818
tomo_condition = []
1919
tomo_resolution = []
2020
tomo_train = []
@@ -43,14 +43,19 @@ def aggregate_vesicle_train_data(roots, test_tomograms, conditions, resolutions)
4343
except KeyError:
4444
tomo_name = fname
4545

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
5155

5256
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)
5459
tomo_condition.append(this_condition)
5560
tomo_resolution.append(this_resolution)
5661
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)
6065
"condition": tomo_condition,
6166
"resolution": tomo_resolution,
6267
"used_for": tomo_train,
63-
"vesicle_count": tomo_vesicles,
68+
"vesicle_count_all": tomo_vesicles_all,
69+
"vesicle_count_imod": tomo_vesicles_imod,
6470
})
6571

6672
os.makedirs("data_summary", exist_ok=True)
@@ -70,43 +76,43 @@ def aggregate_vesicle_train_data(roots, test_tomograms, conditions, resolutions)
7076
def vesicle_train_data():
7177
roots = {
7278
"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
7480
"test": "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/01_hoi_maus_2020_incomplete", # noqa
7581
},
7682
"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
7884
"test": "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/02_hcc_nanogold", # noqa
7985
},
8086
"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
8288
"test": "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/03_hog_cs1sy7", # noqa
8389
},
8490
"04": {
8591
"train": "",
8692
"test": "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/ground_truth/04Dataset_for_vesicle_eval/", # noqa
8793
},
8894
"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
9096
"test": "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/05_stem750_sv_training", # noqa
9197
},
9298
"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
94100
"test": "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/07_hoi_s1sy7_tem250_ihgp", # noqa
95101
},
96102
"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
98104
"test": "",
99105
},
100106
"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
102108
"test": "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/10_tem_single_release", # noqa
103109
},
104110
"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
106112
"test": "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/11_tem_multiple_release", # noqa
107113
},
108114
"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
110116
"test": "/mnt/lustre-emmy-hdd/projects/nim00007/data/synaptic-reconstruction/cooper/vesicles_processed_v2/testsets/12_chemical_fix_cryopreparation", # noqa
111117
},
112118
}
@@ -397,6 +403,11 @@ def vesicle_domain_adaptation_data():
397403
"MF_05649_P-09175-E_06.h5", "MF_05646_C-09175-B_001B.h5", "MF_05649_P-09175-E_07.h5",
398404
"MF_05649_G-09175-C_001.h5", "MF_05646_C-09175-B_002.h5", "MF_05649_G-09175-C_04.h5",
399405
"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",
400411
]
401412
}
402413

@@ -439,13 +450,42 @@ def vesicle_domain_adaptation_data():
439450
aggregate_da(roots, train_tomograms, test_tomograms, resolutions)
440451

441452

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+
442480
def main():
443481
# active_zone_train_data()
444482
# compartment_train_data()
445483
# mito_train_data()
446-
# vesicle_train_data()
484+
vesicle_train_data()
447485

448-
vesicle_domain_adaptation_data()
486+
# vesicle_domain_adaptation_data()
487+
# get_n_images_frog()
488+
# get_image_sizes_tem_2d()
449489

450490

451491
main()
Binary file not shown.
Binary file not shown.
Binary file not shown.
13.5 KB
Binary file not shown.

scripts/summarize_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,4 @@ def summarize_compartment_train():
151151
# summarize_vesicle_train_data()
152152
# summarize_vesicle_da()
153153
summarize_az_train()
154-
# summarize_compartment_train()
154+
summarize_compartment_train()

0 commit comments

Comments
 (0)