Skip to content

Commit

Permalink
tests for masking and normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffwoollard committed Sep 11, 2024
1 parent f20344e commit 6def1bf
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
data:
n_pix: 16
psize: 30.044
submission:
fname: tests/data/dataset_2_submissions/submission_1000.pt
volume_key: volumes
metadata_key: populations
label_key: id
ground_truth:
volumes: tests/data/Ground_truth/test_maps_gt_flat_10.npy
metadata: tests/data/Ground_truth/test_metadata_10.csv
mask:
do: false
volume: tests/data/Ground_truth/test_mask_dilated_wide.mrc
analysis:
metrics:
- l2_low_memory
- corr_low_memory
- bioem_low_memory
- fsc_low_memory
- res_low_memory
chunk_size_submission: 80
chunk_size_gt: 190
normalize:
do: false
method: median_zscore
output: tests/results/test_map_to_map_distance_matrix_submission_0.pkl
27 changes: 27 additions & 0 deletions tests/config_files/test_config_map_to_map_nomask_nonormalize.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
data:
n_pix: 16
psize: 30.044
submission:
fname: tests/data/dataset_2_submissions/submission_1000.pt
volume_key: volumes
metadata_key: populations
label_key: id
ground_truth:
volumes: tests/data/Ground_truth/test_maps_gt_flat_10.pt
metadata: tests/data/Ground_truth/test_metadata_10.csv
mask:
do: false
volume: tests/data/Ground_truth/test_mask_dilated_wide.mrc
analysis:
metrics:
- l2
- corr
- bioem
- fsc
- res
chunk_size_submission: 80
chunk_size_gt: 190
normalize:
do: false
method: median_zscore
output: tests/results/test_map_to_map_distance_matrix_submission_0.pkl
56 changes: 31 additions & 25 deletions tests/test_map_to_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,37 @@


def test_run_map2map_pipeline():
args = OmegaConf.create(
{"config": "tests/config_files/test_config_map_to_map.yaml"}
)
results_dict = run_map2map_pipeline.main(args)
for config_fname, config_fname_low_memory in zip(
[
"tests/config_files/test_config_map_to_map.yaml",
"tests/config_files/test_config_map_to_map.yaml",
],
[
"tests/config_files/test_config_map_to_map_low_memory.yaml",
"tests/config_files/test_config_map_to_map_low_memory.yaml",
],
):
args = OmegaConf.create({"config": config_fname})
results_dict = run_map2map_pipeline.main(args)

args_low_memory = OmegaConf.create(
{"config": "tests/config_files/test_config_map_to_map_low_memory.yaml"}
)
results_dict_low_memory = run_map2map_pipeline.main(args_low_memory)
for metric in ["fsc", "corr", "l2", "bioem"]:
if metric == "fsc":
args_low_memory = OmegaConf.create({"config": config_fname_low_memory})
results_dict_low_memory = run_map2map_pipeline.main(args_low_memory)
for metric in ["fsc", "corr", "l2", "bioem"]:
if metric == "fsc":
np.allclose(
results_dict[metric]["computed_assets"]["fsc_matrix"],
results_dict_low_memory[metric + "_low_memory"]["computed_assets"][
"fsc_matrix"
],
)
elif metric == "res":
np.allclose(
results_dict[metric]["computed_assets"]["fraction_nyquist"],
results_dict_low_memory[metric + "_low_memory"]["computed_assets"][
"fraction_nyquist"
],
)
np.allclose(
results_dict[metric]["computed_assets"]["fsc_matrix"],
results_dict_low_memory[metric + "_low_memory"]["computed_assets"][
"fsc_matrix"
],
results_dict[metric]["cost_matrix"].values,
results_dict_low_memory[metric + "_low_memory"]["cost_matrix"].values,
)
elif metric == "res":
np.allclose(
results_dict[metric]["computed_assets"]["fraction_nyquist"],
results_dict_low_memory[metric + "_low_memory"]["computed_assets"][
"fraction_nyquist"
],
)
np.allclose(
results_dict[metric]["cost_matrix"].values,
results_dict_low_memory[metric + "_low_memory"]["cost_matrix"].values,
)

0 comments on commit 6def1bf

Please sign in to comment.