Skip to content

Commit

Permalink
all tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffwoollard committed Sep 18, 2024
1 parent 3077f6a commit cb7085e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/cryo_challenge/_map_to_map/map_to_map_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ def __init__(self, config):
self.chunk_size_low_memory = self.config["analysis"]["low_memory"][
"chunk_size_low_memory"
]
self.mask = (
mrcfile.open(self.config["data"]["mask"]["volume"])
.data.astype(bool)
.flatten()
)
if self.config["data"]["mask"]["do"]:
self.mask = (
mrcfile.open(self.config["data"]["mask"]["volume"])
.data.astype(bool)
.flatten()
)

def get_distance(self, map1, map2):
"""Compute the distance between two maps."""
Expand Down Expand Up @@ -142,7 +143,8 @@ def get_distance(self, map1, map2, global_store_of_running_results):
raise NotImplementedError(
f"Normalization method {self.config['analysis']['normalize']['method']} not implemented."
)
map1 = map1[self.mask]
if self.config["data"]["mask"]["do"]:
map1 = map1[self.mask]

return self.compute_cost(map1, map2)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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: dummy-string
analysis:
metrics:
- l2
- corr
- bioem
- fsc
- res
chunk_size_submission: 80
chunk_size_gt: 190
chunk_size_low_memory: 10
low_memory:
do: true
chunk_size_low_memory: 10
normalize:
do: false
method: dummy-string
output: tests/results/test_map_to_map_distance_matrix_submission_0.pkl
2 changes: 2 additions & 0 deletions tests/test_map_to_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ def test_run_map2map_pipeline():
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_nomask_nonormalize.yaml",
],
[
"tests/config_files/test_config_map_to_map_low_memory_subbatch.yaml",
"tests/config_files/test_config_map_to_map_low_memory_subbatch_nomask_nonormalize.yaml",
],
):
args = OmegaConf.create({"config": config_fname})
Expand Down

0 comments on commit cb7085e

Please sign in to comment.