-
Notifications
You must be signed in to change notification settings - Fork 104
add a class that allows storing locations of errors #46
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
Open
moenigin
wants to merge
10
commits into
google:master
Choose a base branch
from
moenigin:proofreading_updates
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
54a34dd
Update proofreading.py
moenigin 6bc2857
pyink run on proofreading.py
moenigin 94c7229
Merge remote-tracking branch 'upstream/master' into proofreading_updates
moenigin e5d48b9
Update proofreading.py
moenigin 813ce6d
Update proofreading.py
moenigin b09792f
Update proofreading.py
moenigin d3cfa96
Update proofreading.py
moenigin 5f7c55e
Update proofreading.py
moenigin 45f2090
several fixes
moenigin 448f18a
Merge remote-tracking branch 'upstream/master' into proofreading_updates
moenigin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -367,7 +367,7 @@ def __init__( | |
| seg_error_coordinates: A dictionary of error coordinates. | ||
| load_annotations: A flag to indicate if annotations should be loaded. | ||
| """ | ||
| super(ObjectReviewStoreLocation, self).__init__(objects, bad) | ||
| super().__init__(objects, bad) | ||
| self.seg_error_coordinates = seg_error_coordinates | ||
| if load_annotations and seg_error_coordinates: | ||
| for k, v in seg_error_coordinates.items(): | ||
|
|
@@ -459,19 +459,19 @@ def store_error_location( | |
| self.temp_coord_list = [] | ||
|
|
||
| def annotate_error_locations( | ||
| self, coordinate_lst: list[list[int]], id_: str | ||
| self, coordinates: list[list[int]], error_id: str | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Iterable[Point]? |
||
| ) -> None: | ||
| """Annotate the error locations in the viewer. | ||
|
|
||
| Args: | ||
| coordinate_lst: List of coordinates to be annotated. | ||
| id_: Unique identifier for the error. | ||
| coordinates: List of coordinates to be annotated. | ||
| error_id: Unique identifier for the error. | ||
| """ | ||
| for i, coord in enumerate(coordinate_lst): | ||
| annotation_id = id_ + f"_{i}" | ||
| self.mk_point_annotation(coord, annotation_id) | ||
| for i, coord in enumerate(coordinates): | ||
| annotation_id = f"{error_id}_{i}" | ||
| self.make_point_annotation(coord, annotation_id) | ||
|
|
||
| def mk_point_annotation( | ||
| def make_point_annotation( | ||
| self, coordinate: list[int], annotation_id: str | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Point? |
||
| ) -> None: | ||
| """Create a point annotation in the viewer. | ||
|
|
@@ -488,8 +488,7 @@ def mk_point_annotation( | |
| id=annotation_id, point=coordinate, props=[color] | ||
| ) | ||
| with self.viewer.txn() as s: | ||
| annotations = s.layers["annotation"].annotations | ||
| annotations.append(annotation) | ||
| s.layers["annotation"].annotations.append(annotation) | ||
|
|
||
| def get_annotation_id( | ||
| self, action_state: neuroglancer.viewer_config_state.ActionState | ||
|
|
@@ -519,17 +518,17 @@ def delete_location_from_annotation( | |
| Args: | ||
| action_state: State of the viewer during the action. | ||
| """ | ||
| id_ = self.get_annotation_id(action_state) | ||
| if id_ is None: | ||
| ann_id = self.get_annotation_id(action_state) | ||
| if ann_id is None: | ||
| return | ||
|
|
||
| target_key = id_[:2] | ||
| target_key, _ = ann_id.split("_") | ||
| del self.seg_error_coordinates[target_key] | ||
|
|
||
| to_remove = [target_key + "_0", target_key + "_1"] | ||
| to_remove = frozenset([target_key + "_0", target_key + "_1"]) | ||
| self.delete_annotation(to_remove) | ||
|
|
||
| def delete_annotation(self, to_remove: list[str]) -> None: | ||
| def delete_annotation(self, to_remove: frozenset[str]) -> None: | ||
| """Delete specified annotations from the viewer. | ||
|
|
||
| Args: | ||
|
|
@@ -540,9 +539,9 @@ def delete_annotation(self, to_remove: list[str]) -> None: | |
| annotations = [a for a in annotations if a.id not in to_remove] | ||
| s.layers["annotation"].annotations = annotations | ||
|
|
||
| def delete_last_location(self): | ||
| def delete_last_location(self) -> None: | ||
| """Delete the last error location pair tagged.""" | ||
| last_key = list(self.seg_error_coordinates.keys())[-1] | ||
| last_key = next(reversed(self.seg_error_coordinates)) | ||
| del self.seg_error_coordinates[last_key] | ||
|
|
||
| to_remove = [last_key + "_0", last_key + "_1"] | ||
|
mjanusz marked this conversation as resolved.
Outdated
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's a use case where you would provide seg_error_coordinates, but set load_annotations to False?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A combination of laziness and generak flaws of the tool as is now. 1. If I pick up the review after a break I don't want to patch the final list of coordinates from different review session. 2. The annotation layer shows all annotations not only for the segment you are currently viewing. If in the last review session you already verfied that all locations you flagged in that session are correct, you may want to visualize only the novel locations.
Hope I am kind of making this clear here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, so is the idea that when load_annotations == False, the seg_error_coordinates are just stored (and appended to as you annotate more), but not actually displayed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was my idea behind this because R. had already annotated >100 splits by the time we started this. Large numbers of annotations could be confusing. So if they are not needed because they are all verified from a previous revision round one can leave them out this way...
(Alternatively one could link the annotation to the errorneous segment of the todo list (requiring batch size to be one). By overriding update_segments one could only display the locations associated with a given batch of segments from the todo list. To view all marked location one could create a "show_all" function. However, as mentioned in the email thread I am not sure whether getting to split locations as implemented here is the most efficient way. Assembling segments belonging to one neurite by selection is usually faster. This would yield more coordinate pairs for a given split, but the would not necessarily be in close proximity to each other. If the latter is what you are after, that should be stated explicitly in the instructions.)