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

Added custom caching for get_spectrum and add ROI handling improvements #2191

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ashmeigh
Copy link
Collaborator

@ashmeigh ashmeigh commented May 7, 2024

Issue

Description

  • Added custom caching for get_spectrum and added ROI handling improvements

  • Added a custom caching mechanism using a dictionary in the model

  • Added methods to manage the cache, including _roi_to_key for converting SensibleROI to hashable keys and clear_cache for clearing the cache.

  • Improved get_spectrumto use tache

  • Added can_incrementally_update` determine if updates are possible based on ROI shifts and size changes.

  • Added update_spectrum` update the spectrum by calculating differences introduced by ROI changes.

  • Added calculate_removed_data and calculate_added_data compute data points removed and added when the ROI changes.

  • Updated update_cached_data to remove and add data into the cached value

Testing

It needs a lot more messing around with to find the errors I have already picked up on a few. Plus other things like thresholds

Acceptance Criteria

Documentation

Updated the documentation in the appropriate file in docs/release_notes to reflect the added functionality for ROI speed optimization.

@ashmeigh ashmeigh changed the title Efficient ROI Handling in SpectrumWidget Added custom caching for get_spectrum and add ROI handling improvements May 14, 2024
@@ -190,26 +193,201 @@ def normalise_issue(self) -> str:
return ""

def get_spectrum(self, roi: str | SensibleROI, mode: SpecType) -> np.ndarray:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the caching be done in get_stack_spectrum()

intersection_bottom = min(old_roi.bottom, new_roi.bottom)

if intersection_right > intersection_left and intersection_bottom > intersection_top:
old_area = (old_roi.right - old_roi.left) * (old_roi.bottom - old_roi.top)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move area and overlap calculation into SensibleROI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants