raamana / visualqc

VisualQC : assistive tool to ease the quality control workflow of neuroimaging data.
https://raamana.github.io/visualqc/
Apache License 2.0
73 stars 13 forks source link

NonGuiException when running visualqc_freesurfer #77

Open jbramen opened 1 year ago

jbramen commented 1 year ago

Description

When I execute visualqc_freesurfer, it successfully opens the FreeView GUI a few times, but then returns an error.

What I Did

(venv) daniel@yoda:[~/vqc]: visualqc_freesurfer -f ~/vqc

Freesurfer QC module
Time stamp : 2023-08-13 10:19:42

version info: visualqc 0.6.7.dev2+g3b66e64
numpy 1.25.2 / scipy 1.11.1 / matplotlib 3.7.2
python 3.11.4 (main, Aug  6 2023, 09:08:03) [GCC 7.3.1 20180712 (Red Hat 7.3.1-15)]
platform Linux-4.14.290-217.505.amzn2.x86_64-x86_64-with-glibc2.26
#1 SMP Wed Aug 10 09:52:16 UTC 2022

    Linux distribution: {'NAME': 'Amazon Linux', 'ID': 'amzn', 'PRETTY_NAME': 'Amazon Linux 2', 'VERSION': '2', 'ID_LIKE': 'centos rhel fedora', 'VERSION_ID': '2', 'ANSI_COLOR': '0;33', 'CPE_NAME': 'cpe:2.3:o:amazon:amazon_linux:2', 'HOME_URL': 'https://amazonlinux.com/'}
/opt/visualqc/visualqc/utils.py:823: UserWarning: The following subjects do NOT have all the required files or some are empty - skipping them!
  warnings.warn('The following subjects do NOT have all the required files'
visualqc

The following files do not exist or empty: 
 /home/daniel/vqc/visualqc/mri/orig.mgz
/home/daniel/vqc/visualqc/mri/aparc+aseg.mgz 

1 subjects are usable for review.

Number of samples to review = 1 < 10:  insufficient for outlier detection, disabling it.

Input folder: /home/daniel/vqc
Output folder: /home/daniel/vqc/visualqc
outlier detection: disabled, as requested.

Attempting to generate surface visualizations of parcellation ...
Processing PREV_001_S1_T1_sag.nii

Restoring ratings from previous session(s), if they exist ..
To be reviewed : 1

Reviewing PREV_001_S1_T1_sag.nii
Traceback (most recent call last):
  File "/opt/visualqc/venv/bin/visualqc_freesurfer", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/visualqc/visualqc/__freesurfer__.py", line 12, in main
    freesurfer.cli_run()
  File "/opt/visualqc/visualqc/freesurfer.py", line 1193, in cli_run
    wf.run()
  File "/opt/visualqc/visualqc/workflows.py", line 98, in run
    self.loop_through_units()
  File "/opt/visualqc/visualqc/workflows.py", line 271, in loop_through_units
    self.show_fig_and_wait()
  File "/opt/visualqc/visualqc/workflows.py", line 309, in show_fig_and_wait
    self.fig.canvas.manager.show()
  File "/opt/visualqc/venv/lib/python3.11/site-packages/matplotlib/backend_bases.py", line 2921, in show
    raise NonGuiException(
matplotlib.backend_bases.NonGuiException: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
raamana commented 1 year ago

Hi Jennifer, thanks for opening the issues and sharing the details. As the log says: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.

it appears the issue is you don't have an X-server/display environment setup right? seeing keywords like amazon it seems you are trying to run VisualQC over the cloud? if so, you need to add flags to your command such as -X or -Y so they forward the GUI as well. That said, I highly recommend you download the Freesurfer outputs to locally and then run VisualQC, it would be much much faster and more reliable that way. See some helpful notes here: https://raamana.github.io/visualqc/examples_freesurfer.html#generating-and-downloading-required-files-from-a-remote-ssh-server

if that doesn't help, let me know, with all the logs of errors you run into.

raamana commented 1 year ago

Hi Jennifer @jbramen, did you make progress? it's fine if you haven't had a chance to look into this :)

jbramen commented 1 year ago

This is actually running on a Amazon Linux 2 cloud machine with a MATE desktop, so I would think the GUI should work. I am running it through remote desktop, not over an SSH connection.

If you don't have any immediate ideas, I can try running some isolated tests with matplotlib outside of this application and see if I can narrow down any issues there.

raamana commented 1 year ago

that's rather a special OS/setup that we are not familiar with at all TBH. We tested it extensively on CentOS, and Amazon Linux is supposed to be CentOS, but there might some differences in setup causing the issues. Is it possible for you to spin up a CentOS instance on your cloud server? that would be easiest solution for now.

Also, again, if it is possible for you I highly recommend you download the Freesurfer outputs to your local linux machine and then run VisualQC, it would be much much faster and more reliable that way. See some helpful notes here: https://raamana.github.io/visualqc/examples_freesurfer.html#generating-and-downloading-required-files-from-a-remote-ssh-server