Skip to content

Display normalized values in spectrum viewer image view #2481

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

Merged
merged 4 commits into from
Feb 13, 2025

Conversation

ashleymeigh2
Copy link
Collaborator

@ashleymeigh2 ashleymeigh2 commented Jan 28, 2025

Issue Closes #2456

Description

  • Updated spectrum viewer to display normalized values in the image view when normalization is enabled.
  • Added get_normalized_averaged_image() to the model for normalized image data.
  • Updated presenter to fetch and display the correct image based on normalization state.

Developer Testing

  • Verified unit tests pass: python -m pytest -vs
  • Tested normalized and non-normalized image rendering in the spectrum viewer.

Acceptance Criteria

  • Unit tests pass: python -m pytest -vs
  • Normalized values display when normalization is enabled.
  • Non-normalized values display when normalization is disabled.
  • Edge cases (e.g., missing stacks) handled correctly.

@ashmeigh ashmeigh force-pushed the 2456_normalised-image-in-spectrum-view branch from ef39340 to 3f2ecf9 Compare January 28, 2025 14:17
Copy link
Collaborator

@samtygier-stfc samtygier-stfc left a comment

Choose a reason for hiding this comment

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

I think the test is failing because self.view.normalisation_enabled() will be true by default in the mocked view. Might fix it to add self.view.normalisation_enabled.return_value = False in to the test.

@samtygier-stfc
Copy link
Collaborator

And it would be good to have a test for the new function in model_test.py

@samtygier-stfc
Copy link
Collaborator

Looks like this still needs a yapf fix

@ashmeigh ashmeigh force-pushed the 2456_normalised-image-in-spectrum-view branch from 90d31c2 to 407094c Compare February 7, 2025 15:25
@coveralls
Copy link

Coverage Status

coverage: 73.088% (+0.01%) from 73.075%
when pulling 407094c on 2456_normalised-image-in-spectrum-view
into dbede8a on main.

Copy link
Collaborator

@samtygier-stfc samtygier-stfc left a comment

Choose a reason for hiding this comment

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

Now that there is similar code in 3 places, I think it is worth pulling

        averaged_image = (self.model.get_normalized_averaged_image()
                          if self.view.normalisation_enabled() else self.model.get_averaged_image())
        if averaged_image is None:
            image_shape = self.model.get_image_shape()
            averaged_image = np.zeros(image_shape, dtype=np.float32)
        self.view.set_image(averaged_image, autoLevels=False)

into its own method.

@ashleymeigh2 ashleymeigh2 self-assigned this Feb 11, 2025
samtygier-stfc
samtygier-stfc previously approved these changes Feb 13, 2025
Copy link
Collaborator

@samtygier-stfc samtygier-stfc left a comment

Choose a reason for hiding this comment

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

Looks good now. Thanks

@samtygier-stfc samtygier-stfc force-pushed the 2456_normalised-image-in-spectrum-view branch from ab6b218 to 9886152 Compare February 13, 2025 14:24
@samtygier-stfc samtygier-stfc force-pushed the 2456_normalised-image-in-spectrum-view branch from 9886152 to 8b65457 Compare February 13, 2025 15:31
@samtygier-stfc samtygier-stfc added this pull request to the merge queue Feb 13, 2025
Merged via the queue into main with commit d088873 Feb 13, 2025
8 checks passed
@samtygier-stfc samtygier-stfc deleted the 2456_normalised-image-in-spectrum-view branch February 13, 2025 16:18
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.

Show normalised image in spectrum view
4 participants