{"id":743,"date":"2026-07-29T15:20:01","date_gmt":"2026-07-29T15:20:01","guid":{"rendered":"https:\/\/ni.cmu.edu\/computing\/?post_type=ht_kb&#038;p=743"},"modified":"2026-07-29T15:29:18","modified_gmt":"2026-07-29T15:29:18","slug":"quickstart-matlab-afni-interactive-gui-session","status":"publish","type":"ht_kb","link":"https:\/\/ni.cmu.edu\/computing\/knowledge-base\/quickstart-matlab-afni-interactive-gui-session\/","title":{"rendered":"Quickstart: MATLAB &#038; AFNI Interactive GUI Session"},"content":{"rendered":"<p data-path-to-node=\"7\">This guide walks you through connecting to the MIND cluster (<code data-path-to-node=\"7\" data-index-in-node=\"61\">mind.cs.cmu.edu<\/code>) from Windows or macOS, reserving resources on a CPU compute node via Slurm, and launching MATLAB with full X11 graphics and AFNI integration enabled.<\/p>\n<blockquote data-path-to-node=\"8\">\n<p data-path-to-node=\"8,0\"><b data-path-to-node=\"8,0\" data-index-in-node=\"0\">Note: <\/b>Do not run heavy processing scripts or graphical GUIs directly on the SSH login node. Always request an interactive compute node using <code data-path-to-node=\"8,0\" data-index-in-node=\"162\">srun<\/code> first.<\/p>\n<\/blockquote>\n<h2 data-path-to-node=\"10\">Step 1: Set Up Your Local X11 Client<\/h2>\n<p data-path-to-node=\"11\">Graphical applications like MATLAB and AFNI require an <b data-path-to-node=\"11\" data-index-in-node=\"55\">X11 display server<\/b> running on your local machine to display GUI windows forwarded from the cluster.<\/p>\n<h3 data-path-to-node=\"12\">Option A: Windows Users (MobaXterm)<\/h3>\n<ol start=\"1\" data-path-to-node=\"13\">\n<li>\n<p data-path-to-node=\"13,0,0\">Download the <b data-path-to-node=\"13,0,0\" data-index-in-node=\"13\">Home Edition (Portable)<\/b> from the official <a class=\"ng-star-inserted\" href=\"https:\/\/mobaxterm.mobatek.net\/download-home-edition.html\" target=\"_blank\" rel=\"noopener\">MobaXterm Download Page<\/a>.<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"13,1,0\">Extract the downloaded <code data-path-to-node=\"13,1,0\" data-index-in-node=\"23\">.zip<\/code> file into a directory on your computer (e.g., Desktop or Documents).<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"13,2,0\">Double-click <code data-path-to-node=\"13,2,0\" data-index-in-node=\"13\">MobaXterm_Personal_X.X.exe<\/code> to launch the application. <i data-path-to-node=\"13,2,0\" data-index-in-node=\"67\">(No administrator rights required. X11 forwarding is enabled automatically).<\/i><\/p>\n<\/li>\n<\/ol>\n<h3 data-path-to-node=\"14\">Option B: macOS Users (XQuartz)<\/h3>\n<ol start=\"1\" data-path-to-node=\"15\">\n<li>\n<p data-path-to-node=\"15,0,0\">Download and install <b data-path-to-node=\"15,0,0\" data-index-in-node=\"21\">XQuartz<\/b> from <a class=\"ng-star-inserted\" href=\"https:\/\/www.xquartz.org\/\" target=\"_blank\" rel=\"noopener\">xquartz.org<\/a>.<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"15,1,0\"><b data-path-to-node=\"15,1,0\" data-index-in-node=\"0\">Log out of your Mac and log back in<\/b> (or restart your Mac). This is a required one-time setup step so macOS registers XQuartz as your default X11 display server.<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"15,2,0\">Open your Mac&#8217;s native <b data-path-to-node=\"15,2,0\" data-index-in-node=\"23\">Terminal<\/b> app (press <code data-path-to-node=\"15,2,0\" data-index-in-node=\"43\">Cmd + Space<\/code>, type <code data-path-to-node=\"15,2,0\" data-index-in-node=\"61\">Terminal<\/code>, and press <code data-path-to-node=\"15,2,0\" data-index-in-node=\"81\">Enter<\/code>).<\/p>\n<\/li>\n<\/ol>\n<h2 data-path-to-node=\"17\">Step 2: SSH into <code data-path-to-node=\"17\" data-index-in-node=\"17\">mind.cs.cmu.edu<\/code><\/h2>\n<h3 data-path-to-node=\"18\">Windows (via MobaXterm)<\/h3>\n<ol start=\"1\" data-path-to-node=\"19\">\n<li>\n<p data-path-to-node=\"19,0,0\">Click the <b data-path-to-node=\"19,0,0\" data-index-in-node=\"10\">Session<\/b> button in the top-left corner <span class=\"math-inline\" data-math=\"\\rightarrow\" data-index-in-node=\"48\">$\\rightarrow$<\/span> select <b data-path-to-node=\"19,0,0\" data-index-in-node=\"67\">SSH<\/b>.<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"19,1,0\">Configure parameters:<\/p>\n<ul data-path-to-node=\"19,1,1\">\n<li>\n<p data-path-to-node=\"19,1,1,0,0\"><b data-path-to-node=\"19,1,1,0,0\" data-index-in-node=\"0\">Remote host:<\/b> <code data-path-to-node=\"19,1,1,0,0\" data-index-in-node=\"13\">mind.cs.cmu.edu<\/code><\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"19,1,1,1,0\"><b data-path-to-node=\"19,1,1,1,0\" data-index-in-node=\"0\">Specify username:<\/b> Check the box and enter your cluster username.<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"19,1,1,2,0\"><b data-path-to-node=\"19,1,1,2,0\" data-index-in-node=\"0\">Port:<\/b> <code data-path-to-node=\"19,1,1,2,0\" data-index-in-node=\"6\">22<\/code><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p data-path-to-node=\"19,2,0\">Click <b data-path-to-node=\"19,2,0\" data-index-in-node=\"6\">OK<\/b>, then enter your password and complete 2FA when prompted.<\/p>\n<\/li>\n<\/ol>\n<h3 data-path-to-node=\"20\">macOS (via Native Terminal)<\/h3>\n<p data-path-to-node=\"21\">In your Mac Terminal window, run the following command (note the <code data-path-to-node=\"21\" data-index-in-node=\"65\">-Y<\/code> flag, which enables trusted X11 graphics forwarding):<\/p>\n<div class=\"code-block ng-tns-c4093682955-731 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"formatted-code-block-internal-container ng-tns-c4093682955-731\">\n<div class=\"animated-opacity ng-tns-c4093682955-731\">\n<div class=\"code-block-decoration header-formatted gds-emphasized-body-m ng-tns-c4093682955-731 ng-star-inserted\">\n<p><span class=\"ng-tns-c4093682955-731\">Bash<\/span><\/p>\n<div class=\"buttons ng-tns-c4093682955-731 ng-star-inserted\"><\/div>\n<\/div>\n<pre class=\"ng-tns-c4093682955-731\"><code class=\"code-container formatted ng-tns-c4093682955-731\" role=\"text\" data-test-id=\"code-content\">ssh -Y username@mind.cs.cmu.edu\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p data-path-to-node=\"23\"><i data-path-to-node=\"23\" data-index-in-node=\"0\">(Replace <code data-path-to-node=\"23\" data-index-in-node=\"9\">username<\/code> with your cluster ID, then enter your password and complete 2FA).<\/i><\/p>\n<h2 data-path-to-node=\"25\">Step 3: Request a CPU Compute Node with Slurm<\/h2>\n<p data-path-to-node=\"26\">Once connected to the login node, request an interactive compute node session on the <code data-path-to-node=\"26\" data-index-in-node=\"85\">cpu<\/code> partition with X11 graphics enabled:<\/p>\n<div class=\"code-block ng-tns-c4093682955-732 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"formatted-code-block-internal-container ng-tns-c4093682955-732\">\n<div class=\"animated-opacity ng-tns-c4093682955-732\">\n<pre class=\"ng-tns-c4093682955-732\"><code class=\"code-container formatted ng-tns-c4093682955-732\" role=\"text\" data-test-id=\"code-content\">srun --pty --x11 -p cpu --cpus-per-task=4 --mem=16G --time=02:00:00 bash\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<blockquote data-path-to-node=\"28\">\n<p data-path-to-node=\"28,0\"><b data-path-to-node=\"28,0\" data-index-in-node=\"0\">Tip: <\/b>You can adjust <code data-path-to-node=\"28,0\" data-index-in-node=\"40\">--cpus-per-task=4<\/code>, <code data-path-to-node=\"28,0\" data-index-in-node=\"59\">--mem=16G<\/code>, or <code data-path-to-node=\"28,0\" data-index-in-node=\"73\">--time=02:00:00<\/code> depending on the resource requirements of your specific workload.<\/p>\n<\/blockquote>\n<p data-path-to-node=\"29\">Wait until your terminal prompt updates to show a compute node hostname (e.g., <code data-path-to-node=\"29\" data-index-in-node=\"79\">username@mind-0-15<\/code>).<\/p>\n<h2 data-path-to-node=\"31\">Step 4: Configure Linux Path and Start MATLAB<\/h2>\n<ol start=\"1\" data-path-to-node=\"32\">\n<li>\n<p data-path-to-node=\"32,0,0\">Export the AFNI binary path into your Linux environment:<\/p>\n<div class=\"code-block ng-tns-c4093682955-733 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"formatted-code-block-internal-container ng-tns-c4093682955-733\">\n<div class=\"animated-opacity ng-tns-c4093682955-733\">\n<pre class=\"ng-tns-c4093682955-733\"><code class=\"code-container formatted ng-tns-c4093682955-733\" role=\"text\" data-test-id=\"code-content\"><span class=\"hljs-built_in\">export<\/span> PATH=\/lab_data\/hawk\/afni-25-0-09:<span class=\"hljs-variable\">$PATH<\/span>\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<li>\n<p data-path-to-node=\"32,1,0\">Confirm Linux can locate the AFNI binaries:<\/p>\n<div class=\"code-block ng-tns-c4093682955-734 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"formatted-code-block-internal-container ng-tns-c4093682955-734\">\n<div class=\"animated-opacity ng-tns-c4093682955-734\">\n<pre class=\"ng-tns-c4093682955-734\"><code class=\"code-container formatted ng-tns-c4093682955-734\" role=\"text\" data-test-id=\"code-content\"><span class=\"hljs-built_in\">which<\/span> 3dinfo\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<p data-path-to-node=\"32,1,2\"><i data-path-to-node=\"32,1,2\" data-index-in-node=\"0\">Expected output:<\/i> <code data-path-to-node=\"32,1,2\" data-index-in-node=\"17\">\/lab_data\/hawk\/afni-25-0-09\/3dinfo<\/code><\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"32,2,0\">Load the MATLAB module (if required) and launch the MATLAB GUI in the background:<\/p>\n<div class=\"code-block ng-tns-c4093682955-735 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"formatted-code-block-internal-container ng-tns-c4093682955-735\">\n<div class=\"animated-opacity ng-tns-c4093682955-735\">\n<pre class=\"ng-tns-c4093682955-735\"><code class=\"code-container formatted ng-tns-c4093682955-735\" role=\"text\" data-test-id=\"code-content\">module load matlab\r\nmatlab &amp;\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/li>\n<\/ol>\n<h2 data-path-to-node=\"34\">Step 5: Configure AFNI inside MATLAB &amp; Verify Setup<\/h2>\n<p data-path-to-node=\"35\">In the MATLAB command prompt (<code data-path-to-node=\"35\" data-index-in-node=\"30\">&gt;&gt;<\/code>), add the AFNI MATLAB helper folder and run the quick diagnostic script below to verify environment compatibility:<\/p>\n<div class=\"code-block ng-tns-c4093682955-736 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation\">\n<div class=\"formatted-code-block-internal-container ng-tns-c4093682955-736\">\n<div class=\"animated-opacity ng-tns-c4093682955-736\">\n<pre class=\"ng-tns-c4093682955-736\"><code class=\"code-container formatted ng-tns-c4093682955-736\" role=\"text\" data-test-id=\"code-content\"><span class=\"hljs-comment\">% 1. Add AFNI MATLAB helper functions (Note the \/matlab subfolder)<\/span>\r\naddpath(<span class=\"hljs-string\">'\/lab_data\/hawk\/afni_matlab\/matlab'<\/span>);\r\n\r\n<span class=\"hljs-comment\">% 2. Verify MATLAB sees functions and system tools<\/span>\r\nwhich BrikInfo\r\nwhich BrikLoad\r\nsystem(<span class=\"hljs-string\">'which 3dinfo'<\/span>)\r\n\r\n<span class=\"hljs-comment\">% 3. Run Self-Test Verification<\/span>\r\nsystem(<span class=\"hljs-string\">'echo \"1 1 1 1\" | 3dUndump -dimen 10 10 10 -prefix \/tmp\/test_afni -overwrite -'<\/span>);\r\n[err, Info] = BrikInfo(<span class=\"hljs-string\">'\/tmp\/test_afni+orig.HEAD'<\/span>);\r\n\r\n<span class=\"hljs-keyword\">if<\/span> err == <span class=\"hljs-number\">0<\/span> &amp;&amp; isfield(Info, <span class=\"hljs-string\">'IJK_TO_DICOM_REAL'<\/span>)\r\n    <span class=\"hljs-built_in\">disp<\/span>(<span class=\"hljs-string\">'----------------------------------------------------'<\/span>)\r\n    <span class=\"hljs-built_in\">disp<\/span>(<span class=\"hljs-string\">'SUCCESS: AFNI MATLAB setup is working correctly!'<\/span>)\r\n    <span class=\"hljs-built_in\">disp<\/span>(<span class=\"hljs-string\">'Loaded IJK_TO_DICOM_REAL matrix:'<\/span>)\r\n    <span class=\"hljs-built_in\">disp<\/span>(Info.IJK_TO_DICOM_REAL)\r\n    <span class=\"hljs-built_in\">disp<\/span>(<span class=\"hljs-string\">'----------------------------------------------------'<\/span>)\r\n<span class=\"hljs-keyword\">else<\/span>\r\n    <span class=\"hljs-built_in\">disp<\/span>(<span class=\"hljs-string\">'ERROR: AFNI MATLAB setup failed. Please contact support.'<\/span>)\r\n<span class=\"hljs-keyword\">end<\/span>\r\n<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<h2 data-path-to-node=\"38\">Troubleshooting &amp; Common Issues<\/h2>\n<blockquote data-path-to-node=\"39\">\n<p data-path-to-node=\"39,0\"><b data-path-to-node=\"39,0\" data-index-in-node=\"0\">Warning:<\/b><\/p>\n<ul data-path-to-node=\"39,1\">\n<li>\n<p data-path-to-node=\"39,1,0,0\"><b data-path-to-node=\"39,1,0,0\" data-index-in-node=\"0\">Mac Users \u2014 GUI window doesn&#8217;t open \/ &#8220;Display error&#8221;:<\/b> Ensure you restarted your Mac after installing XQuartz, and make sure you included the <code data-path-to-node=\"39,1,0,0\" data-index-in-node=\"142\">-Y<\/code> flag in your SSH command (<code data-path-to-node=\"39,1,0,0\" data-index-in-node=\"171\">ssh -Y ...<\/code>).<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"39,1,1,0\"><b data-path-to-node=\"39,1,1,0\" data-index-in-node=\"0\">Unrecognized function &#8216;BrikInfo&#8217;:<\/b> Ensure you added <code data-path-to-node=\"39,1,1,0\" data-index-in-node=\"51\">\/lab_data\/hawk\/afni_matlab\/matlab<\/code> to <code data-path-to-node=\"39,1,1,0\" data-index-in-node=\"88\">addpath()<\/code>. Missing the <code data-path-to-node=\"39,1,1,0\" data-index-in-node=\"111\">\/matlab<\/code> subfolder will prevent MATLAB from indexing the <code data-path-to-node=\"39,1,1,0\" data-index-in-node=\"167\">.m<\/code> files.<\/p>\n<\/li>\n<li>\n<p data-path-to-node=\"39,1,2,0\"><b data-path-to-node=\"39,1,2,0\" data-index-in-node=\"0\">Windows \u2014 X11 Display Errors:<\/b> If the MATLAB GUI fails to open on Windows, verify that MobaXterm&#8217;s X server icon (in the system tray) is active and that you included the <code data-path-to-node=\"39,1,2,0\" data-index-in-node=\"169\">--x11<\/code> flag in your <code data-path-to-node=\"39,1,2,0\" data-index-in-node=\"188\">srun<\/code> command.<\/p>\n<\/li>\n<\/ul>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>This guide walks you through connecting to the MIND cluster (mind.cs.cmu.edu) from Windows or macOS, reserving resources on a CPU compute node via Slurm, and launching MATLAB with full X11 graphics and AFNI integration enabled. Note: Do not run heavy processing scripts or graphical GUIs directly on the SSH login&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[11],"ht-kb-tag":[],"class_list":["post-743","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-software"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb\/743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/comments?post=743"}],"version-history":[{"count":8,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb\/743\/revisions"}],"predecessor-version":[{"id":751,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb\/743\/revisions\/751"}],"wp:attachment":[{"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/media?parent=743"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb-category?post=743"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/ni.cmu.edu\/computing\/wp-json\/wp\/v2\/ht-kb-tag?post=743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}