You can use a virtual frame buffer. I wrote a frontend for one to do just this

here is the help

# fsxvfb - a simple application of the virtual frame buffer (vrb) for
# X This can run graphical commands in a "headless" way, ie, without
# needing to create a window. This can be handy when you want to, eg,
# create images using freeview but you don't want windows continuously
# popping up. Just run something like:

# "fsxvrb freeview -v orig.mgz -viewport x -ss pic1.jpg"

# This script has a procedure for looking for an open display port
# starting at 10. The port is relinquished after the command
# finishes. Ports are locked if the file /tmp/.X$D-lock (where $D is
# the display) exists or a previous Xvfb launched with the port is
# still running. If this file exists, then that display cannot be
# used. This can happen if the command does not return and you kill it
# (it should handle control-c ok).  You can always delete the lock
# file and kill the Xvfb by hand.  Rebooting will also clean things
# up.


On 12/2/2024 3:32 PM, Blujus, Jenna wrote:

        External Email - Use Caution        

Hello,

I have run vertex-wise cortical thickness analyses via command line (mris_preproc, mri_glmfit, mri_glmfit-sim) using Freesurfer v7.3.2 (freesurfer-linux-centos7_x86_64-7.3.2-20220804-6354275). I am now attempting to take a screenshot of the resulting significant clusters with Freeview. 

I am running multiple analyses so I set up an sbatch job to be submitted via our hpc cluster scheduler. The issue is that GUIs can't be launched via sbatch, so no screenshot is generated. I could do this via command line but I was hoping to automate the process. Is there any flag added or alternative approach that can be taken to generate the screenshot via sbatch jobs?

Below is the command:
freeview -f ${SUBJECTS_DIR}/fsaverage/surf/lh.inflated:overlay=lh.gender.glmdir/group.diff/cache.th30.abs.sig.cluster.mgh:overlay_threshold=1.3,5:annot=lh.gender.glmdir/group.diff/cache.th30.abs.sig.ocn.annot -viewport 3d -layout 1 -hide-3d-slices -hide-3d-frames -cam azimuth 180 -ss ${script_dir}/results_summary/results-${parent_folder}_${iv}_${crnt_combo}_med.jpg

Error when run via sbatch:
could not connect to display :1.0
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Thanks,
Jenna

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer