imr-framework / pypulseq

Pulseq in Python
https://pypulseq.readthedocs.io
GNU Affero General Public License v3.0
115 stars 62 forks source link

matplotlib backend TkAgg in sequence problematic in other backends #40

Closed KerstinKaspar closed 3 years ago

KerstinKaspar commented 3 years ago

The hardcoded setting of TkAgg right on top of pypulseq.Sequence.sequence with mpl.use('TkAgg') can lead to problems with another backend like QT5. It raises: ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'qt5' is currently running

In many cases, this can be helped by manually changing the framework to 'tk', if you read up on it. However, we like to read sequence files in a QT5 framework (a Qt5 based application). You can reproduce it by setting the matplotlib framewrk to 'qt5' or other than 'tk'.

Is the TkAgg backend absolutely necessary? If so, would it be possible to separate the backend switch (and maybe the plot function) from the rest of the sequence code?

It would be best if the plot is not dependent on the backend, but it would suffice for us it the functions that do not depend on matplotlib can be imported without the backend switch.

Thanks for your help!

sravan953 commented 3 years ago

Hi @KerstinHut . IIRC I fixed this in an earlier commit (f9dc7bfe7c76bc866ab142bc02dde72c315b91ee). Is this still an issue?

KerstinKaspar commented 3 years ago

Seems to be fine, thanks!