From 6f3fd9dc20b8edcc100bedb841b5228ff17b2cd1 Mon Sep 17 00:00:00 2001 From: DSilva27 Date: Fri, 2 Aug 2024 11:50:00 -0400 Subject: [PATCH 1/6] add flip to preprocessing --- src/cryo_challenge/_preprocessing/dataloader.py | 2 ++ src/cryo_challenge/_preprocessing/preprocessing_pipeline.py | 5 +++++ .../submission_x/submission_config.json | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cryo_challenge/_preprocessing/dataloader.py b/src/cryo_challenge/_preprocessing/dataloader.py index 2593c2a..4cc75d6 100644 --- a/src/cryo_challenge/_preprocessing/dataloader.py +++ b/src/cryo_challenge/_preprocessing/dataloader.py @@ -65,6 +65,8 @@ def validate_submission_config(self): raise ValueError(f"Pixel size not found for submission {key}") if "align" not in value.keys(): raise ValueError(f"Align not found for submission {key}") + if "flip" not in value.keys(): + raise ValueError(f"Flip not found for submission {key}") if not os.path.exists(value["path"]): raise ValueError(f"Path {value['path']} does not exist") diff --git a/src/cryo_challenge/_preprocessing/preprocessing_pipeline.py b/src/cryo_challenge/_preprocessing/preprocessing_pipeline.py index 5994e6e..926b2c1 100644 --- a/src/cryo_challenge/_preprocessing/preprocessing_pipeline.py +++ b/src/cryo_challenge/_preprocessing/preprocessing_pipeline.py @@ -107,6 +107,11 @@ def preprocess_submissions(submission_dataset, config): print(" Centering submission") volumes = center_submission(volumes, pixel_size=pixel_size_gt) + # flip handedness + if submission_dataset.submission_config[str(idx)]["flip"] == 1: + print(" Flipping handedness of submission") + volumes = volumes.flip(-1) + # align to GT if submission_dataset.submission_config[str(idx)]["align"] == 1: print(" Aligning submission to ground truth") diff --git a/tests/data/unprocessed_dataset_2_submissions/submission_x/submission_config.json b/tests/data/unprocessed_dataset_2_submissions/submission_x/submission_config.json index 87184aa..354060e 100644 --- a/tests/data/unprocessed_dataset_2_submissions/submission_x/submission_config.json +++ b/tests/data/unprocessed_dataset_2_submissions/submission_x/submission_config.json @@ -11,6 +11,7 @@ "align": 1, "box_size": 244, "pixel_size": 2.146, - "path": "tests/data/unprocessed_dataset_2_submissions/submission_x" + "path": "tests/data/unprocessed_dataset_2_submissions/submission_x", + "flip": 1 } -} \ No newline at end of file +} From f82d37378cfee627712b6b352f0ce1812fff0a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Silva-S=C3=A1nchez?= <31875788+DSilva27@users.noreply.github.com> Date: Mon, 5 Aug 2024 10:35:05 -0400 Subject: [PATCH 2/6] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ba0facf..159e3fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,6 +52,7 @@ dependencies = [ "osfclient<=0.0.5", "seaborn<=0.13.2", "ipyfilechooser<=0.6.0", + "omegaconf<=2.3.0" ] [project.optional-dependencies] @@ -60,7 +61,6 @@ dev = [ "mypy", "pre-commit", "ruff", - "omegaconf<=2.3.0" ] [project.urls] From 9d8aa512d4589524ec3637f6f07ac2cab7405e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Silva-S=C3=A1nchez?= <31875788+DSilva27@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:00:27 -0400 Subject: [PATCH 3/6] Update pyproject.toml --- pyproject.toml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 159e3fd..b83c5ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,26 +38,26 @@ classifiers = [ "Programming Language :: Python :: Implementation :: PyPy", ] dependencies = [ - "torch<=2.3.1", - "numpy<=2.0.0", - "natsort<=8.4.0", - "pandas<=2.2.2", - "dataclasses_json<=0.6.7", - "mrcfile<=1.5.0", - "scipy<=1.13.1", - "cvxpy<=1.5.2", - "POT<=0.9.3", - "aspire<=0.12.2", - "jupyter<=1.0.0", - "osfclient<=0.0.5", - "seaborn<=0.13.2", - "ipyfilechooser<=0.6.0", - "omegaconf<=2.3.0" + torch, + numpy, + natsort, + pandas, + dataclasses_json, + mrcfile, + scipy, + cvxpy, + POT, + aspire, + jupyter, + osfclient, + seaborn", + ipyfilechooser", + omegaconf" ] [project.optional-dependencies] dev = [ - "pytest<=8.2.2", + "pytest", "mypy", "pre-commit", "ruff", From 384eebf6ad3341ab96ac1d75982dd304cc3ea085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Silva-S=C3=A1nchez?= <31875788+DSilva27@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:01:48 -0400 Subject: [PATCH 4/6] Update pyproject.toml --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b83c5ef..9857389 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,9 +50,9 @@ dependencies = [ aspire, jupyter, osfclient, - seaborn", - ipyfilechooser", - omegaconf" + seaborn, + ipyfilechooser, + omegaconf ] [project.optional-dependencies] From bc341a810ea29ef581278603b0dd741a111c7d33 Mon Sep 17 00:00:00 2001 From: DSilva27 Date: Mon, 5 Aug 2024 11:06:02 -0400 Subject: [PATCH 5/6] update pyproject toml --- pyproject.toml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9857389..597890e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,21 +38,21 @@ classifiers = [ "Programming Language :: Python :: Implementation :: PyPy", ] dependencies = [ - torch, - numpy, - natsort, - pandas, - dataclasses_json, - mrcfile, - scipy, - cvxpy, - POT, - aspire, - jupyter, - osfclient, - seaborn, - ipyfilechooser, - omegaconf + "torch", + "numpy", + "natsort", + "pandas", + "dataclasses_json", + "mrcfile", + "scipy", + "cvxpy", + "POT", + "aspire", + "jupyter", + "osfclient", + "seaborn", + "ipyfilechooser", + "omegaconf" ] [project.optional-dependencies] From 626b226115f382ed608017518b88cbc25d006da3 Mon Sep 17 00:00:00 2001 From: DSilva27 Date: Mon, 5 Aug 2024 11:24:53 -0400 Subject: [PATCH 6/6] update tutorial with flip flag --- tutorials/1_tutorial_preprocessing.ipynb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutorials/1_tutorial_preprocessing.ipynb b/tutorials/1_tutorial_preprocessing.ipynb index 0c718e4..cc6a459 100644 --- a/tutorials/1_tutorial_preprocessing.ipynb +++ b/tutorials/1_tutorial_preprocessing.ipynb @@ -136,6 +136,7 @@ " 0: {\n", " \"name\": \"submission1\",\n", " \"align\": 0,\n", + " \"flip\": 0,\n", " \"box_size\": 144,\n", " \"pixel_size\": 1.073 * 2,\n", " \"path\": submission1_path.selected_path,\n", @@ -143,6 +144,7 @@ " 1: {\n", " \"name\": \"submission2\",\n", " \"align\": 1,\n", + " \"flip\": 1,\n", " \"box_size\": 288,\n", " \"pixel_size\": 1.073,\n", " \"path\": submission2_path.selected_path,\n",