Skip to content

Commit

Permalink
Merge branch 'dev' into 14-implement-power-spectrum-normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
DSilva27 authored Aug 12, 2024
2 parents 60dfc3a + efb77bc commit a06b96d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
31 changes: 27 additions & 4 deletions src/cryo_challenge/_map_to_map/map_to_map_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def get_computed_assets(self, maps1, maps2, global_store_of_running_results):


class L2DistanceNorm(MapToMapDistance):
"""L2 distance norm"""

def __init__(self, config):
super().__init__(config)

Expand All @@ -43,6 +45,10 @@ def get_distance(self, map1, map2):


class L2DistanceSum(MapToMapDistance):
"""L2 distance.
Computed by summing the squared differences between the two maps."""

def __init__(self, config):
super().__init__(config)

Expand All @@ -55,6 +61,10 @@ def get_distance(self, map1, map2):


class Correlation(MapToMapDistance):
"""Correlation distance.
Not technically a distance metric, but a similarity."""

def __init__(self, config):
super().__init__(config)

Expand All @@ -67,6 +77,8 @@ def get_distance(self, map1, map2):


class BioEM3dDistance(MapToMapDistance):
"""BioEM 3D distance."""

def __init__(self, config):
super().__init__(config)

Expand Down Expand Up @@ -124,6 +136,10 @@ def get_distance(self, map1, map2):


class FSCDistance(MapToMapDistance):
"""Fourier Shell Correlation distance.
One minus the correlation between two maps in Fourier space."""

def __init__(self, config):
super().__init__(config)

Expand Down Expand Up @@ -215,9 +231,10 @@ def compute_cost_fsc_chunk(self, maps_gt_flat, maps_user_flat, n_pix):
return cost_matrix, fsc_matrix

@override
def get_distance_matrix(
self, maps1, maps2, global_store_of_running_results
): # custom method
def get_distance_matrix(self, maps1, maps2, global_store_of_running_results):
"""
Applies a mask to the maps and computes the cost matrix using the Fourier Shell Correlation.
"""
maps_gt_flat = maps1
maps_user_flat = maps2
n_pix = self.config["data"]["n_pix"]
Expand All @@ -242,7 +259,13 @@ def get_computed_assets(self, maps1, maps2, global_store_of_running_results):
return self.stored_computed_assets # must run get_distance_matrix first


class ResDistance(MapToMapDistance):
class FSCResDistance(MapToMapDistance):
"""FSC Resolution distance.
The resolution at which the Fourier Shell Correlation reaches 0.5.
Built on top of the FSCDistance class. This needs to be run first and store the FSC matrix in the computed assets.
"""

def __init__(self, config):
super().__init__(config)

Expand Down
4 changes: 2 additions & 2 deletions src/cryo_challenge/_map_to_map/map_to_map_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Correlation,
L2DistanceSum,
BioEM3dDistance,
ResDistance,
FSCResDistance,
)


Expand All @@ -18,7 +18,7 @@
"corr": Correlation,
"l2": L2DistanceSum,
"bioem": BioEM3dDistance,
"res": ResDistance,
"res": FSCResDistance,
}


Expand Down

0 comments on commit a06b96d

Please sign in to comment.