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

Rob/mdanse trajectory filter #615

Open
wants to merge 128 commits into
base: protos
Choose a base branch
from

Conversation

RobBuchananCompPhys
Copy link
Collaborator

@RobBuchananCompPhys RobBuchananCompPhys commented Nov 28, 2024

Description of work
TODO:

(Probably don't need to solve all of these immediately - some may become issues for further work after this is completed)

UI

  • Odd crash occurs when returning to TrajectoryFilter job page from another job, error appears to be due to deleted grid layout components in the trajectory filter widget
  • Trajectory filter widget panel inputs move around alot in layout - will change to a grid layout for all input components to improve stability
  • Allow user to visualise the attenuated trajectory power spectrum alongside filter (currently non-enabled "Show attenuation" checkbox)
  • When x-axis is set to energy units, the axis contracts - this should remain the same scale as for frequency units

UI &/or Backend

  • Number of simulation frames post-filtering exceeds original frame count
  • Investigate cause of atoms collapsing to 'ugly blob' when certain filter variants (seems to be highpass and bandpass removing low frequency vibrations) are applied to trajectory
  • Ensure the Z- and S- domain representations of the transfer function polynomial are correct

Backend

  • Filter class and filter-variant child classes
  • Write metadata (filter configuration)

Tests

  • Basic unit tests for correct functioning of filter class
  • Full end-to-end test for a more complex molecular dynamics trajectory

Other

  • Ensure sensible default values for filters
  • Complete numpy docstrings for methods
  • Apply black formatting

Fixes
A list of fixes.

To test
Please describe the tests that were run to verify the changes.

@RobBuchananCompPhys RobBuchananCompPhys marked this pull request as ready for review December 16, 2024 10:51
Comment on lines 429 to 455
if on:
self.bound_freq_widget.setEnabled(True)
return
self.bound_freq_widget.setEnabled(False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if on:
self.bound_freq_widget.setEnabled(True)
return
self.bound_freq_widget.setEnabled(False)
self.bound_freq_widget.setEnabled(on)

Copy link
Collaborator

Choose a reason for hiding this comment

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

In fact this function could just be:

      toggle_bound_frequencies = self.bound_freq_widget.setEnabled

Copy link
Collaborator Author

@RobBuchananCompPhys RobBuchananCompPhys Feb 10, 2025

Choose a reason for hiding this comment

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

This change loses expected behaviour, tested on a bandpass filter which requires the frequency other bound to become enabled and it does not.

@RobBuchananCompPhys RobBuchananCompPhys force-pushed the rob/mdanse-trajectory-filter branch 2 times, most recently from 7afa869 to 97b6ec8 Compare February 27, 2025 16:40
@MBartkowiakSTFC
Copy link
Collaborator

It would be good to have a way of adjusting the view in the filter designer window. I have some use cases where the relevant part of the data is all in the corner.
Screenshot 2025-02-28 at 13 30 55

Probably just a standard matplotlib toolbar could be added to control behaviour like zooming in and out. PlotWidget.py does this using NavigationToolbar2QT.

@MBartkowiakSTFC
Copy link
Collaborator

Also, let me see if I got this right: the instrument resolution and projection inputs affect the power spectrum in the preview - but do they affect the results produced by the filter?

@RobBuchananCompPhys
Copy link
Collaborator Author

Also, let me see if I got this right: the instrument resolution and projection inputs affect the power spectrum in the preview - but do they affect the results produced by the filter?

No effect on the filtered trajectory, only required for the power spectrum calculation.

@RobBuchananCompPhys RobBuchananCompPhys force-pushed the rob/mdanse-trajectory-filter branch from 8495046 to 68377e1 Compare March 5, 2025 10:31
@MBartkowiakSTFC
Copy link
Collaborator

I think that problems can still occur if you run the filter for a trajectory, and then load a different trajectory and switch to it. I lost the ability to switch from "lowpass" to other modes. I changed the filter type and then the other options were still in the combo box, but they would trigger this error output:

2025-03-06 12:28:43,221 - ERROR - process[22318] - main 35 - EXCEPTION:
<class 'RuntimeError'>
wrapped C/C++ object of type QAction has been deleted
<traceback object at 0x300c830c0>
Traceback (most recent call last):
  File "MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py", line 412, in <lambda>
    signal.connect(lambda val: self.edit_current_filter(setting_key, val))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py", line 239, in edit_current_filter
    self.render_canvas_assets()
  File "MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py", line 762, in render_canvas_assets
    self.render_graph(
  File "MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py", line 660, in render_graph
    self._figure.clear()
  File "lib/python3.11/site-packages/matplotlib/figure.py", line 3133, in clear
    toolbar.update()
  File "lib/python3.11/site-packages/matplotlib/backend_bases.py", line 3281, in update
    self.set_history_buttons()
  File "lib/python3.11/site-packages/matplotlib/backends/backend_qt.py", line 847, in set_history_buttons
    self._actions['back'].setEnabled(can_backward)
RuntimeError: wrapped C/C++ object of type QAction has been deleted

@RobBuchananCompPhys
Copy link
Collaborator Author

I think that problems can still occur if you run the filter for a trajectory, and then load a different trajectory and switch to it. I lost the ability to switch from "lowpass" to other modes. I changed the filter type and then the other options were still in the combo box, but they would trigger this error output:

2025-03-06 12:28:43,221 - ERROR - process[22318] - main 35 - EXCEPTION:
<class 'RuntimeError'>
wrapped C/C++ object of type QAction has been deleted
<traceback object at 0x300c830c0>
Traceback (most recent call last):
  File "MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py", line 412, in <lambda>
    signal.connect(lambda val: self.edit_current_filter(setting_key, val))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py", line 239, in edit_current_filter
    self.render_canvas_assets()
  File "MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py", line 762, in render_canvas_assets
    self.render_graph(
  File "MDANSE_GUI/InputWidgets/TrajectoryFilterWidget.py", line 660, in render_graph
    self._figure.clear()
  File "lib/python3.11/site-packages/matplotlib/figure.py", line 3133, in clear
    toolbar.update()
  File "lib/python3.11/site-packages/matplotlib/backend_bases.py", line 3281, in update
    self.set_history_buttons()
  File "lib/python3.11/site-packages/matplotlib/backends/backend_qt.py", line 847, in set_history_buttons
    self._actions['back'].setEnabled(can_backward)
RuntimeError: wrapped C/C++ object of type QAction has been deleted

Looks to be related to the recently introduced toolbar for the filter designer, I'll look into it

@MBartkowiakSTFC
Copy link
Collaborator

One more thing: the spin boxes in the filter dialog could be made less restrictive. One of them does not allow values lower than 1.0, and the step size is also quite large. This is still OK most of the time, but we cannot exclude the possibility that for some trajectory this will stop the user from applying the filter they wanted.

Would it make sense to check the energy axis of the position power spectrum, and then set the step of the spin box to a single step on the energy axis? Also, if it is important not to allow 0 as an input in that spin box, the minimum could be set to the first non-zero energy value.

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.

4 participants