-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into 96-alignment-invariant-map-to-map-distance
- Loading branch information
Showing
29 changed files
with
1,921 additions
and
669 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
path_to_volumes: /path/to/volumes | ||
box_size_ds: 32 | ||
submission_list: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] | ||
experiment_mode: "all_vs_ref" # options are "all_vs_all", "all_vs_ref" | ||
# optional unless experiment_mode is "all_vs_ref" | ||
path_to_reference: /path/to/reference/volumes.pt | ||
dtype: "float32" # options are "float32", "float64" | ||
output_options: | ||
# path will be created if it does not exist | ||
output_path: /path/to/output | ||
# whether or not to save the processed volumes (downsampled, normalized, etc.) | ||
save_volumes: True | ||
# whether or not to save the SVD matrices (U, S, V) | ||
save_svd_matrices: True | ||
path_to_submissions: path/to/preprocessed/submissions/ # where all the submission_i.pt files are | ||
#excluded_submissions: # you can exclude some submissions by filename, default = [] | ||
# - "submission_0.pt" | ||
# - "submission_1.pt" | ||
voxel_size: 1.0 # voxel size of the input maps (will probably be removed soon) | ||
|
||
dtype: float32 # optional, default = float32 | ||
svd_max_rank: 5 # optional, default = full rank svd | ||
normalize_params: # optional, if not given there will be no normalization | ||
mask_path: path/to/mask.mrc # default = None, no masking applied | ||
bfactor: 170 # default = None, no bfactor applied | ||
box_size_ds: 16 # default = None, no downsampling applied | ||
|
||
gt_params: # optional, if provided there will be extra results | ||
gt_vols_file: path/to/gt_volumes.npy # volumes must be in .npy format (memory stuff) | ||
skip_vols: 1 # default = 1, no volumes skipped. Equivalent to volumes[::skip_vols] | ||
|
||
output_params: | ||
output_file: path/to/output_file.pt # where the results will be saved | ||
save_svd_data: True # optional, default = False | ||
generate_plots: True # optional, default = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<h1 align='center'>How to setup Zernike3D distance?</h1> | ||
|
||
<p align="center"> | ||
|
||
<img alt="Supported Python versions" src="https://img.shields.io/badge/Supported_Python_Versions-3.8_%7C_3.9_%7C_3.10_%7C_3.11_%7C_3.12-blue"> | ||
<img alt="GitHub Downloads (all assets, all releases)" src="https://img.shields.io/github/downloads/I2PC/Flexutils-Toolkit/total"> | ||
<img alt="GitHub License" src="https://img.shields.io/github/license/I2PC/Flexutils-Toolkit"> | ||
|
||
</p> | ||
|
||
<p align="center"> | ||
|
||
<img alt="Flexutils" src="https://github.com/scipion-em/scipion-em-flexutils/raw/devel/flexutils/icon.png" width="200" height="200"> | ||
|
||
</p> | ||
|
||
|
||
|
||
Zernike3D distance relies on the external software **[Flexutils](https://github.com/I2PC/Flexutils-Toolkit)**. The following document includes the installation guide to setup this software in your machine, as well as some guidelines on the parameters and characteristics of the Zernike3D distance. | ||
|
||
# Flexutils installation | ||
**Flexutils** can be installed in your system with the following commands: | ||
|
||
```bash | ||
git clone https://github.com/I2PC/Flexutils-Toolkit.git | ||
cd Flexutils-Toolkit | ||
bash install.sh | ||
``` | ||
|
||
Any errors raised during the installation of the software or the computation of the Zernike3D distance can be reported through Flexutils GitHub issue [webpage](https://github.com/I2PC/Flexutils-Toolkit/issues). | ||
|
||
# Defining the config file parameters | ||
Zernike3D distance relies on the approximation of a deformation field between two volumes to measure their similarity metric. A detailed explanation on the theory behind the computation of these deformation fields is provided in the following publications: [Zernike3D-IUCRJ](https://journals.iucr.org/m/issues/2021/06/00/eh5012/) and [Zernike3D-NatComm](https://www.nature.com/articles/s41467-023-35791-y). | ||
|
||
The software follows a neural network approximation, so the usage of a GPU is strongly recommended. | ||
|
||
The Zernike3D distance requires a set of additional execution parameters that need to be supplied through the `config_map_to_map.yaml` file passed to the distance compution step. These additional parameters are presented below: | ||
|
||
- **gpuID**: An integer larger than 0 determining the GPU to be used to train the Zernike3Deep neural network. | ||
- **tmpDir**: A path to a folder needed to store the intermediate files generated by the software. This folder is **NOT** emptied once the execution finishes. | ||
- **thr**: An integer larger than 0 determining the number of processes to use during the execution of the software. | ||
|
||
```yaml | ||
metrics: | ||
- zernike3d | ||
zernike3d_extra_params: | ||
gpuID: 0 | ||
tmpDir: where/to/save/intermediate/files/folder | ||
thr: 20 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
""" | ||
Some random code that I have found to be useful for plotting figures. | ||
This should become part of the main repo at some point, I will leave it out for now. | ||
- David | ||
""" | ||
|
||
from natsort import natsorted | ||
|
||
# Here is how I generate the general dictionary parameter for plots | ||
COLORS = { | ||
"Coffee": "#97b4ff", | ||
"Salted Caramel": "#97b4ff", | ||
"Neapolitan": "#648fff", | ||
"Peanut Butter": "#1858ff", | ||
"Cherry": "#b3a4f7", | ||
"Pina Colada": "#8c75f2", | ||
"Chocolate": "#785ef0", | ||
"Cookie Dough": "#512fec", | ||
"Chocolate Chip": "#3d18e9", | ||
"Vanilla": "#e35299", | ||
"Mango": "#dc267f", | ||
"Black Raspberry": "#ff8032", | ||
"Rocky Road": "#fe6100", | ||
"Ground Truth": "#ffb000", | ||
"Mint Chocolate Chip": "#ffb000", | ||
"Bubble Gum": "#ffb000", | ||
} | ||
|
||
PLOT_SETUP = { | ||
"Salted Caramel": {"category": "1", "marker": "o"}, | ||
"Neapolitan": {"category": "1", "marker": "v"}, | ||
"Peanut Butter": {"category": "1", "marker": "^"}, | ||
"Coffee": {"category": "1", "marker": "<"}, | ||
"Cherry": {"category": "2", "marker": "o"}, | ||
"Pina Colada": {"category": "2", "marker": "v"}, | ||
"Cookie Dough": {"category": "2", "marker": "^"}, | ||
"Chocolate Chip": {"category": "2", "marker": "<"}, | ||
"Chocolate": {"category": "2", "marker": ">"}, | ||
"Vanilla": {"category": "3", "marker": "o"}, | ||
"Mango": {"category": "3", "marker": "v"}, | ||
"Rocky Road": {"category": "4", "marker": "o"}, | ||
"Black Raspberry": {"category": "4", "marker": "v"}, | ||
"Ground Truth": {"category": "5", "marker": "o"}, | ||
"Bubble Gum": {"category": "5", "marker": "v"}, | ||
"Mint Chocolate Chip": {"category": "5", "marker": "^"}, | ||
} | ||
|
||
for key in list(PLOT_SETUP.keys()): | ||
# PLOT_SETUP[key]["color"] = COLORS[PLOT_SETUP[key]["category"]] | ||
PLOT_SETUP[key]["color"] = COLORS[key] | ||
|
||
|
||
# These two functions are useful when setting the order of how to plot figures | ||
def compare_strings(fixed_string, other_string): | ||
return other_string.startswith(fixed_string) | ||
|
||
|
||
def sort_labels_category(labels, plot_setup): | ||
labels_sorted = [] | ||
for i in range(5): # there are 5 categories | ||
for label in labels: | ||
if plot_setup[label]["category"] == str(i + 1): | ||
labels_sorted.append(label) | ||
|
||
return labels_sorted | ||
|
||
|
||
labels = ... # get labels from somwhere (pipeline results for example) | ||
|
||
# This is the particular plot_setup for your data | ||
plot_setup = {} | ||
for i, label in enumerate(labels): | ||
for ( | ||
possible_label | ||
) in PLOT_SETUP.keys(): # generalized for labels like FLAVOR 1, FLAVOR 2, etc. | ||
# print(label, possible_label) | ||
if compare_strings(possible_label, label): | ||
plot_setup[label] = PLOT_SETUP[possible_label] | ||
|
||
for label in labels: | ||
if label not in plot_setup.keys(): | ||
raise ValueError(f"Label {label} not found in PLOT_SETUP") | ||
|
||
labels = sort_labels_category(natsorted(labels), plot_setup) | ||
|
||
|
||
# Then I do something like this, which let's me configure how the | ||
# labels will be displayed in the plot | ||
labels_for_plot = { | ||
"Neapolitan": "Neapolitan R1", | ||
"Neapolitan 2": "Neapolitan R2", | ||
"Peanut Butter": "Peanut Butter R1", | ||
"Peanut Butter 2": "Peanut Butter R2", | ||
"Salted Caramel": "Salted Caramel R1", | ||
"Salted Caramel 2": "Salted Caramel R2 1", | ||
"Salted Caramel 3": "Salted Caramel R2 2", | ||
"Chocolate": "Chocolate R1", | ||
"Chocolate 2": "Chocolate R2", | ||
"Chocolate Chip": "Chocolate Chip R1", | ||
"Cookie Dough": "Cookie Dough R1", | ||
"Cookie Dough 2": "Cookie Dough R2", | ||
"Pina Colada 1": "Piña Colada R2", | ||
"Mango": "Mango R1", | ||
"Vanilla": "Vanilla R1", | ||
"Vanilla 2": "Vanilla R2", | ||
"Black Raspberry": "Black Raspberry R1", | ||
"Black Raspberry 2": "Black Raspberry R2", | ||
"Rocky Road": "Rocky Road R1", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.