Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TMA FOV validation functions for user sanity checking #30

Merged
merged 44 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c34c794
Initial commit: order auto TMA FOVs
alex-l-kong Jan 24, 2022
28e6275
Add distance parameter to the manual_to_auto_map
alex-l-kong Jan 24, 2022
4be2cf6
Start adding utility functions
alex-l-kong Jan 24, 2022
a2d7241
Add validation functions and error message generation
alex-l-kong Jan 25, 2022
cd42b7e
Add new error message generation on remap
alex-l-kong Jan 25, 2022
7784f2e
Add annotation functionality
alex-l-kong Jan 25, 2022
b8b653c
Allow user to customize which validations they want
alex-l-kong Jan 25, 2022
c7e8942
Add documentation for validation usage
alex-l-kong Jan 25, 2022
9638856
Merge branch 'tiling_add' into tma_validate
alex-l-kong Jan 26, 2022
4ec6898
Update test functions to account for new 'distance' key
alex-l-kong Jan 26, 2022
2889de4
Start adding test cases for validation functions
alex-l-kong Jan 26, 2022
8cd52bb
Merge branch 'tiling_add' into tma_validate
alex-l-kong Jan 26, 2022
0673afc
Merge branch 'tiling_add' of https://github.com/angelolab/creed-helpe…
alex-l-kong Jan 26, 2022
6f09b43
Merge branch 'main' into tma_validate
alex-l-kong Jan 27, 2022
2d0ff91
Tab issue
alex-l-kong Jan 27, 2022
30d0436
PYCODEStYLE
alex-l-kong Jan 27, 2022
caa8948
Test the annotation function generation
alex-l-kong Jan 27, 2022
e11c663
Change notebook import from creed to toffy
alex-l-kong Jan 27, 2022
6b82355
Add type validation checks
alex-l-kong Jan 27, 2022
6a9792d
Merge branch 'main' into tma_validate
alex-l-kong Jan 27, 2022
20faf65
Change width of validation text box to 50%
alex-l-kong Jan 27, 2022
54e4509
Documentation fixes
alex-l-kong Jan 27, 2022
7a60df5
Documentation adjustments
alex-l-kong Jan 28, 2022
2614ba8
Remove unneeded dict
alex-l-kong Jan 28, 2022
c6c6c57
Add a test for manually-defined FOV updates
alex-l-kong Jan 28, 2022
db2e3da
Add test for auto FOV remap dropdown
alex-l-kong Jan 28, 2022
5f10d24
Update the manual FOV dropdown test to reflect more of what an actual…
alex-l-kong Jan 28, 2022
10209cc
Add a test for w_auto
alex-l-kong Jan 28, 2022
2e67937
Add a test for saving the mapping and updating the annotation
alex-l-kong Jan 28, 2022
6130849
Add another mapping saving test
alex-l-kong Jan 28, 2022
c489430
Typo
alex-l-kong Jan 28, 2022
5ef0f95
Add new manual FOV sorting scheme for double-digit num_x and/or num_y
alex-l-kong Jan 28, 2022
c871b61
Ensure that if the user provides their manual FOVs out of order they …
alex-l-kong Jan 28, 2022
d389014
Add a TODO for manual FOV sorting
alex-l-kong Jan 28, 2022
7ded9bd
Change the pipeline to store distances in lookup table rather than in…
alex-l-kong Feb 1, 2022
0e13d95
Changes to check_dist argument
alex-l-kong Feb 1, 2022
b182f34
Merge branch 'main' into tma_validate
alex-l-kong Feb 1, 2022
05bb003
Ensure random seed consistent throughout testing
alex-l-kong Feb 1, 2022
2e36f4e
Documentation simplification
alex-l-kong Feb 1, 2022
7b4ec16
More documentation
alex-l-kong Feb 1, 2022
568626e
Ensure user knows that check_dist is in microns
alex-l-kong Feb 1, 2022
1901ae0
Add units to docstrings
alex-l-kong Feb 1, 2022
91be52c
Ensure tma_corners_path description describes 4 corners
alex-l-kong Feb 1, 2022
9f22b03
Documentation
alex-l-kong Feb 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cache: pip

script:
- python -m pip install --editable .
- python -m pytest --cov=toffy --pycodestyle toffy
- python -m pytest --randomly-seed=42 --randomly-dont-reorganize --cov=toffy --pycodestyle toffy

after_success:
- coveralls
3 changes: 2 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
coveralls>=1.8.2,<2.0.0
pytest<6.0.0
pytest-cases>=3.6.0,<4
pytest-cov<3.0.0
pytest-mock<4.0.0
pytest-pycodestyle<3.0.0
pytest-cases>=3.6.0,<4
pytest-randomly>=3.11.0,<4
75 changes: 39 additions & 36 deletions templates/autolabel_tma_cores.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"\n",
"The following input files are required for the script to run:\n",
"\n",
"* `tma_corners_path`: the path to the JSON file containing FOVs defining the upper-left corner and bottom-right corner. It should be named `example_tma_corners.json`, where `example_tma` is replaced with the tma_prefix. \n",
"* `tma_corners_path`: the path to the JSON file containing FOVs defining the four corners (top-left, top-right, bottom-left, and bottom-right, in that order). It should be named `example_tma_corners.json`, where `example_tma` is replaced with the `tma_prefix`. \n",
"* `manual_run_path`: the path to your run file with the manually selected FOVs. It should be named `example_tma_manual_run.json`.\n",
"* `slide_path`: the path to the slide image of the TMA"
]
Expand Down Expand Up @@ -157,69 +157,65 @@
},
{
"cell_type": "markdown",
"id": "18895a56",
"id": "7e0b2449",
"metadata": {},
"source": [
"### Map proposed tiles to their closest automatically-generated tile (Euclidean)"
"### Visualize and remap tiles"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "931a51af",
"cell_type": "markdown",
"id": "63643da2",
"metadata": {},
"outputs": [],
"source": [
"manual_to_auto_map, manual_fovs_info, auto_fovs_info = tiling_utils.assign_closest_fovs(\n",
" manual_fov_regions,\n",
" auto_fov_regions\n",
")"
"Set these parameters to view validation warnings while remapping (mappings are between FOVs in `manual_fov_regions` to FOVs in `auto_fov_regions`):\n",
"\n",
"* `check_dist`: set to a positive value to notify of FOV mappings at a distance greater than this value (measured in microns), sorted by decreasing distance. Set to `None` to bypass.\n",
"* `check_duplicates`: set to `True` to notify of FOVs in `auto_fov_regions` with multiple FOVs mapping to it. Set to `False` to bypass.\n",
"* `check_mismatches`: set to `True` to notify of FOV mappings with mismatched names. Set to `False` to bypass."
]
},
{
"cell_type": "markdown",
"id": "7e0b2449",
"cell_type": "code",
"execution_count": null,
"id": "1fcb1768-7cf9-4aea-90d8-7b6e63d79694",
"metadata": {},
"outputs": [],
"source": [
"### Visualize and remap tiles"
"# define which validation checks to display in the FOV pair validation checks box\n",
"check_dist = 2000\n",
"check_duplicates = True\n",
"check_mismatches = True"
]
},
{
"cell_type": "markdown",
"id": "63643da2",
"id": "30ee9a89-ed9c-4e45-bcab-83383da8a35d",
"metadata": {},
"source": [
"Usage notes:\n",
"\n",
"* Proposed FOVs are drawn in red. Automatically-generated FOVs are drawn in blue.\n",
"* The selected proposed FOV and its mapped automatically-generated FOV are colored a darker shade.\n",
"* The `Manually-defined FOV` menu can be used to visualize current mappings to automatically-generated FOVs.\n",
"* The `Automatically-generated FOV` menu is used for re-mapping a FOV created by this script to one of yours.\n",
"* When you're done generating your desired mapping, click the `Save mapping`. This will save your mapping to `mapping_path` specified earlier.\n",
"Each FOV in `manual_fov_regions` are mapped to their closest corresponding FOV in `auto_fov_regions` by default. To see the current mappings, select FOVs in the `Manually-defined FOV` menu. To remap a manual FOV to a different auto FOV, use the `Automatically-generated FOV` menu.\n",
"\n",
"Note:\n",
"\n",
"* The cells after this interactive widget (in the section `Use mapping to rename FOVs in manual_fov_regions`) are only to be run after you're satisfied with the mapping and clicked `Save mapping`.\n",
"* Prior to clicking `Save mapping` and re-running the cells in that section, ignore any error messages that may appear in that section.\n",
"* If you change your mind after saving the remapped FOVs, you can come back here to redo your mappings, save again, and re-run the code to remap the FOVs."
"After you're done finished, click `Save mapping` and run the cells afterward (ignore any error messages that may appear there beforehand). You can always come back here and redo your mappings if you change your mind."
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "60fa546d",
"metadata": {},
"outputs": [],
"source": [
"%matplotlib widget\n",
"tiling_utils.interactive_remap(\n",
" manual_to_auto_map,\n",
" manual_fovs_info,\n",
" auto_fovs_info,\n",
"tiling_utils.tma_interactive_remap(\n",
" manual_fov_regions,\n",
" auto_fov_regions,\n",
" slide_data,\n",
" mapping_path,\n",
" draw_radius=7,\n",
" figsize=(7, 7)\n",
" figsize=(7, 7),\n",
" check_dist=check_dist,\n",
" check_duplicates=check_duplicates,\n",
" check_mismatches=check_mismatches\n",
")"
]
},
Expand All @@ -243,17 +239,24 @@
" mapping = json.load(mp)"
]
},
{
"cell_type": "markdown",
"id": "958dd308-5cdf-4d6f-913f-b40705eb4757",
"metadata": {},
"source": [
"* `randomize`: shuffle the order of the FOVs in `remapped_fov_regions`\n",
"* `moly_insert`: insert a Moly point (specified by `moly_path`) between a specified interval of FOVs\n",
"* `moly_interval`: if `moly_insert` is set, insert Moly points at this interval"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "840c7372",
"metadata": {},
"outputs": [],
"source": [
"# whether to randomize the FOVs in remapped_fov_regions\n",
"randomize = True\n",
"\n",
"# whether to insert Moly points between a specified interval of FOVs in remapped_fov_regions\n",
"moly_insert = True\n",
"moly_interval = 5"
]
Expand Down
Loading