Skip to content

Commit

Permalink
Merge pull request #62 from flatironinstitute/59-add-handedness-flipp…
Browse files Browse the repository at this point in the history
…ing-as-a-flag-to-preprocessing-pipeline

59 add handedness flipping as a flag to preprocessing pipeline
  • Loading branch information
DSilva27 authored Aug 5, 2024
2 parents c9d649b + 626b226 commit bd2728a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
32 changes: 16 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,29 @@ 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",
"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",
"omegaconf<=2.3.0"
]

[project.urls]
Expand Down
2 changes: 2 additions & 0 deletions src/cryo_challenge/_preprocessing/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions src/cryo_challenge/_preprocessing/preprocessing_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
2 changes: 2 additions & 0 deletions tutorials/1_tutorial_preprocessing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,15 @@
" 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",
" },\n",
" 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",
Expand Down

0 comments on commit bd2728a

Please sign in to comment.