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

ENH: new coreg gui features (part 2) #10085

Merged
merged 48 commits into from
Dec 10, 2021

Conversation

GuillaumeFavelier
Copy link
Contributor

@GuillaumeFavelier GuillaumeFavelier commented Dec 3, 2021

This PR is based on #10015 and adds the following:

  • improve status bar, add infos about omitted points (i.e. how many are left), infos about save/load trans files
  • add units (mm.) to grow hair & omit distance widgets
  • display (mean/min/max) dig/mri distance estimation during fitting
  • display axes
  • display distance to fiducials in mm.

It's part of #8833

Can only be merged after #10015

@larsoner
Copy link
Member

larsoner commented Dec 6, 2021

Looking forward to this now that #10015 is in!

@GuillaumeFavelier
Copy link
Contributor Author

for some reason the message "Fit fiducials" is cropped for me in the status

Assuming that your issue is related to _status_bar_show_message and the stretch parameter, I reworked the function to use QTimer instead. Can you try it again @agramfort ?

@larsoner
Copy link
Member

larsoner commented Dec 8, 2021

Looks nice!

One comment is that when ICP runs, the distances are now shown in two places: in the fitting pane, and another in the status bar:

Screenshot from 2021-12-08 12-54-17

In general, people should ideally have one place they can always look for any given type of information. For distances in particular, I'd keep it all in the right "Fitting" bar. Then the status bar can just show stuff about the number of iterations, and then at the end how many iterations were done and how long it took. Same thing would then goes for "Fitting ICP - Iteration N". This shows up in the 3D plot, but would now be better just in the status bar. In other words:

  1. Status bar = what is being done, or what was last done (and how long it took)
  2. Right "Fitting" panel = all the distance information that is deemed useful

I reworked the function to use QTimer instead.

I'd prefer actually that whatever the last message was just stays put. I don't see much advantage to removing the last status message displayed. It's even helpful to have it stay forever in some cases to remind people what the last thing they did was!

@larsoner
Copy link
Member

larsoner commented Dec 8, 2021

... also when running at some point I got:

Traceback (most recent call last):
  File "/home/larsoner/python/mne-python/mne/gui/_coreg.py", line 865, in _fit_icp
    self._last_log +
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

@agramfort
Copy link
Member

agramfort commented Dec 8, 2021 via email

@GuillaumeFavelier
Copy link
Contributor Author

GuillaumeFavelier commented Dec 9, 2021

In the end, I found that the simplest solution is to display all the messages in the status bar with _display_message().
I also moved all the 'distance' code to _update_distance_estimation().
These changes should make for a cleaner interface.

image

@GuillaumeFavelier
Copy link
Contributor Author

And this method is actually compatible with the notebook backend (status bar post-processed in blue):

image

It feels a bit cramped but it is a work in progress after all

@GuillaumeFavelier
Copy link
Contributor Author

what about now @larsoner, @agramfort ?

@GuillaumeFavelier GuillaumeFavelier self-assigned this Dec 9, 2021
@GuillaumeFavelier GuillaumeFavelier changed the title ENH: new coreg gui features (part 2) WIP,ENH: new coreg gui features (part 2) Dec 9, 2021
@GuillaumeFavelier
Copy link
Contributor Author

GuillaumeFavelier commented Dec 9, 2021

I changed it back to WIP because @agramfort found 2 bugs:

  1. the distances are not updated during fitting
  2. the distances should take into account only the points that are not excluded by 'Omit' (instead of all at the moment)

@GuillaumeFavelier
Copy link
Contributor Author

GuillaumeFavelier commented Dec 9, 2021

the distances are not updated during fitting

I do not have this behaviour on my linux and I checked that self._renderer._process_events() is called at each iteration of fit_icp(). This could be yet another inconsistency of Qt on MacOS?

I will start by looking into 2).

@GuillaumeFavelier
Copy link
Contributor Author

I added a few calls to _update_distance_estimation(), this should be enough for 2).

I tried 2d4b4b7 for MacOS based on what is used on _pyvista.py 🤞

@GuillaumeFavelier
Copy link
Contributor Author

371b86a is my latest attempt at fixing 1) on MacOS

@GuillaumeFavelier
Copy link
Contributor Author

GuillaumeFavelier commented Dec 10, 2021

Okay, it's better than I thought. So @agramfort, in order to move forward with this one, I can report that there could be a delay with updating the distances on MacOS on #8833

I was able to check that the status bar and the render view are updated correctly so it's ready to go on my side.

@GuillaumeFavelier GuillaumeFavelier changed the title WIP,ENH: new coreg gui features (part 2) ENH: new coreg gui features (part 2) Dec 10, 2021
Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

Just a couple of small tweaks / ideas we can keep in mind moving forward. Works great so I'll merge, thanks @GuillaumeFavelier !

@@ -1963,3 +1969,57 @@ def reset(self):
self._extra_points_filter = None
self._update_nearest_calc()
return self

def _get_fiducials_distance(self):
distance = OrderedDict()
Copy link
Member

Choose a reason for hiding this comment

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

No longer need OrderedDict because we are 3.7+. I think our existing ones are mostly there for cruft reasons

Comment on lines +837 to +840
if not self._lock_fids:
self._display_message(
"Fitting is disabled, lock the fiducials first.")
return
Copy link
Member

Choose a reason for hiding this comment

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

In the future we should properly disable in a UI way (button.setEnabled(False) in Qt parlance for example) the things that people are not supposed to use

@larsoner larsoner merged commit 2695271 into mne-tools:main Dec 10, 2021
@GuillaumeFavelier GuillaumeFavelier deleted the enh/coreg_feats_2 branch December 10, 2021 18:17
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.

3 participants