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

Fix long evaluation time on microscopy images #1081

Merged
merged 15 commits into from
Sep 11, 2022

Conversation

mariehbourget
Copy link
Member

@mariehbourget mariehbourget commented Feb 17, 2022

Checklist

GitHub

  • I've given this PR a concise, self-descriptive, and meaningful title
  • I've linked relevant issues in the PR body
  • I've applied the relevant labels to this PR
  • I've assigned a reviewer

PR contents

Description

This PR aims to fix long evaluation time on large microscopy images with the axons and myelin segmentation task.

  • It adds a object_detection_metrics param in the evaluation_parameters of the config file.
  • The default is True.
  • When True, it computes lesions true positive and false detection rates + Hausdorff score at evaluation time.
  • When False, those metrics are skipped (they are not appropriate for axon+myelin segmentation and would create the bottleneck when running evaluation on large images).
  • When False, the "painted" predictions in the pred_masks are also skipped since they are based on lesions true positive and false detection rates.
  • Doc and microscopy tutorial are updated accordingly.

Linked issues

Fixes #975

@mariehbourget mariehbourget added the bug category: fixes an error in the code label Feb 17, 2022
@coveralls
Copy link

coveralls commented Feb 17, 2022

Pull Request Test Coverage Report for Build 2783521423

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 14 of 20 (70.0%) changed or added relevant lines in 3 files are covered.
  • 14 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+9.9%) to 79.09%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ivadomed/evaluation.py 8 14 57.14%
Files with Coverage Reduction New Missed Lines %
ivadomed/metrics.py 5 96.09%
ivadomed/main.py 9 55.52%
Totals Coverage Status
Change from base Build 2771735045: 9.9%
Covered Lines: 4883
Relevant Lines: 6174

💛 - Coveralls

@mariehbourget
Copy link
Member Author

This PR is now ready for review.
It adds a parameter to skip object detection metrics that were not useful for the axon+myelin tasks and causing a significant bottleneck when evaluating large images (as of #975).
The full description of the PR changes are in the first comment above.

Expected behavior:

With object_detection_metrics=True:

  • Hausdorff distance is included in the metrics printed in the terminal
2022-08-12 14:51:29.097 | INFO     | ivadomed.testing:test:88 - {'dice_score': 0.21474601221146625, 'multi_class_dice_score': 0.1535026128012612, 'precision_score': 0.22883224487304688, 'recall_score': 0.2024238745931438, 'specificity_score': 0.7721640585401799, 'intersection_over_union': 0.12044042384784692, 'accuracy_score': 0.629604126767127, 'hausdorff_score': 0.0}
  • The evaluation_3Dmetrics.csv file in results_eval has values in columns lfdr_class0 and ltpr_class0.
  • "painted" predictions are in pred_masks.

With object_detection_metrics=False

  • No Hausdorff distance in the metrics printed in the terminal
2022-08-12 14:51:29.097 | INFO     | ivadomed.testing:test:88 - {'dice_score': 0.21474601221146625, 'multi_class_dice_score': 0.1535026128012612, 'precision_score': 0.22883224487304688, 'recall_score': 0.2024238745931438, 'specificity_score': 0.7721640585401799, 'intersection_over_union': 0.12044042384784692, 'accuracy_score': 0.629604126767127}
  • The evaluation_3Dmetrics.csv file in results_eval does not have values in columns lfdr_class0 and ltpr_class0 (the columns are there but are empty).
  • No "painted" predictions in pred_masks.

Without any evaluation parameters:

  • Same behavior as True.

metric_fns = [dice_score,
multi_class_dice_score,
precision_score,
recall_score,
specificity_score,
intersection_over_union,
accuracy_score]
if task == "segmentation":
if eval_params:
object_detection_metrics = eval_params['object_detection_metrics']
Copy link
Member

@dyt811 dyt811 Sep 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use dict.get() pattern to avoid invalid key error as upstream JSON is never fully validated.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the key 'object_detection_metrics' has already defined in 'config_default.json' file, so it wouldn't be invalid key error show up here.

Copy link
Collaborator

@LuluSzutu LuluSzutu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code has been reviewed, and test runed, should be 'good to merge'.
But have one concern about skipping the metrics of true positive and false detection rates. I feel TP and FN rates are the important for evaluate the image segmentation result. Maybe we should let the user has a choice of skipping only the Hausdorff score and skipping the TP FN as well. This can be addressed in a separate issue if need.

@LuluSzutu LuluSzutu merged commit a260b42 into master Sep 11, 2022
@LuluSzutu LuluSzutu deleted the mhb/975-skip-object-detection-metrics branch September 11, 2022 20:27
@mariehbourget mariehbourget added this to the new release milestone Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug category: fixes an error in the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time issue when running --test on large microscopy images
4 participants