Skip to content

annotation window does not close properly #10454

Closed

Description

@jasmainak

Describe the bug

when doing raw.plot(), the annotation window does not close even if the main browser is closed. Attempting to close that window throws a spurious error:

In [8]: 

Traceback (most recent call last):
  File "/Users/mainak/anaconda3/envs/mne/lib/python3.9/site-packages/matplotlib/cbook/__init__.py", line 270, in process
    func(*args, **kwargs)
  File "/Users/mainak/Documents/github_repos/mne-python/mne/viz/_mpl_figure.py", line 180, in _close
    super()._close(event)
  File "/Users/mainak/Documents/github_repos/mne-python/mne/viz/_mpl_figure.py", line 103, in _close
    self.mne.parent_fig.mne.child_figs.remove(self)
ValueError: list.remove(x): x not in list

Steps to reproduce

import os
import numpy as np
import mne

sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
                                    'sample_audvis_filt-0-40_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file)
raw.plot()

Now press 'a' to open the annotation window, then draw an annotation, then attempt to close the main window. It does not close the annotation window. Next, try to close the annotation window to get the error.

Expected results

The annotation window should close when the main window closes and there should not be any error.

Additional information

I am on latest master of MNE-Python

Activity

  1. agramfort commented on Mar 23, 2022

    @agramfort
    SponsorMember
  2. jasmainak commented on Mar 23, 2022

    @jasmainak
    MemberAuthor

    I was using ipython --matplotlib but I just checked and the error can be reproduced also on ipython --matplotlib=qt

  3. hoechenberger commented on Mar 25, 2022

    @hoechenberger
    Member

    I think @agramfort wanted to know whether you are using the good old Matplotlib-based GUI or the fancy new one, which is our new default in MNE 1.0

  4. agramfort commented on Mar 25, 2022

    @agramfort
    SponsorMember
  5. marsipu commented on Mar 25, 2022

    @marsipu
    Member

    Child figures are handled by each browser-backend (matplotlib, qt) individually:

    matplotlib

    self.mne.child_figs.append(fig)

    self.mne.parent_fig.mne.child_figs.remove(self)

    qt

    https://github.com/mne-tools/mne-qt-browser/blob/c0a7d32259c13097dbd0f2553725ba7049c83b3e/mne_qt_browser/_pg_figure.py#L1492
    https://github.com/mne-tools/mne-qt-browser/blob/c0a7d32259c13097dbd0f2553725ba7049c83b3e/mne_qt_browser/_pg_figure.py#L1529

    But since a separate window for annotations by pressing a only occurs for the matplotlib-backend I think this bug is specific for matplotlib.

  6. jasmainak commented on Mar 26, 2022

    @jasmainak
    MemberAuthor

    Oh, I didn't realize the Qt-based browser was also available now. Just gave it a shot and it's super nice!

    But I do get a similar error:

    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    TypeError: closeEvent() takes 1 positional argument but 2 were given
    ---------------------------------------------------------------------------
    RuntimeError                              Traceback (most recent call last)
    ~/anaconda3/envs/mne/lib/python3.9/site-packages/mne_qt_browser/_pg_figure.py in closeEvent(self, event)
       4493             if hasattr(self.mne, 'child_figs'):
       4494                 for fig in self.mne.child_figs:
    -> 4495                     fig.close()
       4496                 self.mne.child_figs.clear()
       4497             for attr in ('traces', 'event_lines', 'regions'):
    
    RuntimeError: wrapped C/C++ object of type SettingsDialog has been deleted
    Out[1]: <mne_qt_browser._pg_figure.PyQtGraphBrowser at 0x12ef2f550>

    not quite sure what sequence of operations led to it though.

    Also it doesn't allow me to see the time instant by clicking as in the matplotlib browser

  7. marsipu commented on Mar 26, 2022

    @marsipu
    Member

    @jasmainak Ok, this looks like qt-browser seems to have a bug too related to closing the Settings-Dialog. Maybe you could open an issue about that at mne-qt-browser?

  8. jasmainak commented on Mar 29, 2022

    @jasmainak
    MemberAuthor

    humm ... acually that gives a different error than the one I got. I posted that on the mne-qt-browser github along with another issue I had. I haven't been able to reproduce the error above again. I'll post back if I manage to do that

  9. hoechenberger commented on May 5, 2022

    @hoechenberger
    Member

    @jasmainak has this meanwhile been resolved?

  10. added 2 commits that reference this issue on Jun 15, 2022
    733c1ae
    425e000
  11. added a commit that references this issue on Apr 1, 2024
    37a9e55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions