61. Google server for neuroimagng analysis - fahsuanlin/labmanual GitHub Wiki

🧠 Neuroimaging Server Setup on Google Cloud (Ubuntu 22.04)

This guide summarizes the steps to set up a Google Cloud persistent VM for hosting and processing neuroimaging data with FreeSurfer, FSL, and MATLAB.


1. Create and Configure Google Cloud VM

Step 1.1 — Create VM

gcloud compute instances create neuro-vm   --zone=asia-east1-b   --machine-type=n1-standard-1   --image-family=ubuntu-2204-lts   --image-project=ubuntu-os-cloud   --boot-disk-size=100GB   --scopes=default,storage-full

Step 1.2 — SSH to VM

gcloud compute ssh neuro-vm --zone=asia-east1-b

2. Install System Dependencies

sudo apt update && sudo apt upgrade -y
sudo apt install -y build-essential git wget curl unzip tcsh bc xterm x11-apps     libglu1-mesa libxt6 libxmu6 libxext6 libjpeg62 libxrender1 libxtst6 libxi6     ca-certificates
sudo update-ca-certificates

3. Install FreeSurfer 7.4.1 (Ubuntu 22)

Step 3.1 — Download

If HTTPS works:

cd /usr/local
sudo wget https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer_ubuntu22-7.4.1_amd64.deb

If SSL fails:

sudo wget --no-check-certificate https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer_ubuntu22-7.4.1_amd64.deb

(Ensure file size ≈ 2.5 GB)

Step 3.2 — Install

sudo apt install -y ./freesurfer_ubuntu22-7.4.1_amd64.deb
sudo apt --fix-broken install -y

Step 3.3 — Environment Variables

echo "export FREESURFER_HOME=/usr/local/freesurfer/7.4.1" >> ~/.bashrc
echo "source \$FREESURFER_HOME/SetUpFreeSurfer.sh" >> ~/.bashrc
source ~/.bashrc

Step 3.4 — License

mkdir -p ~/.freesurfer
nano ~/.freesurfer/license.txt

(Paste your FreeSurfer license text.)

Step 3.5 — Verify

recon-all --version

4. Optional: Upload File from Mac if SSL Fails

gcloud compute scp ~/Downloads/freesurfer_ubuntu22-7.4.1_amd64.deb neuro-vm:/usr/local/
sudo apt install -y ./freesurfer_ubuntu22-7.4.1_amd64.deb

5. Enable X11 Forwarding (for MATLAB/Freeview)

On Mac

  1. Install XQuartz
  2. Enable “Allow connections from network clients”

On VM

sudo apt install -y xauth x11-apps libxrender1 libxtst6 libxi6

Connect with:

gcloud compute ssh neuro-vm -- -Y

Test:

xclock

6. Next Steps

  • Install FSL and MATLAB Runtime.
  • Mount Google Drive or Cloud Storage (GCS) for data.
  • Save VM image after setup for persistent use.

Platform: Google Cloud (Ubuntu 22.04)
Date: November 2025