eXTReMe Tracker
Sep 122016

There is good news for those who use neuroimaging tools such as AFNI, FSL and FreeSurfer on their Windows machines. The limitation is that they can only be run on Windows 10 with anniversary update. Does it use a Virtual Machine? No. It runs “natively” on Windows 10, so you can save, print, resize or hide any interface just like a Windows program.

Freeview running in Windows 10

Freesurfer on Windows 10

Before I get into how to install FreeSurfer, I must thank the author at K-Lab for the post on “How to run FSL on Windows 10“. That post describes how to install BASH on Windows 10 in the first few steps. Sadly it is not available for Windows 7/8. It uses Ubuntu 14.04 LTS which will be supported by Canonical until 2019. We hope by then Windows would incorporate the Ubuntu 16.04 LTS as the default distribution.

I’ll repeat a few things (steps 1-5) that Lin4Neuro wrote on how to get BASH and X-server on Windows 10.

  1. Install Linux BASH shell on Windows 10:
    There is detailed tutorial with screenshots on how to do this at the following site.
    How to Install and Use the Linux Bash Shell on Windows 10
  2. Install the updates:
    Before adding any tools, you should first download and install the updates for Ubuntu. Run the following commands at the terminal

    sudo apt-get update
    sudo apt-get upgrade
  3. Install the X server:
    Installing BASH will allow you to run applications on a command line but in order to run any GUIs for neuroimaging tools you require a X-server for windows. The most popular software for this is Xming. You can download and install it with default settings.
    Xming X server for Windows
  4. Running X server:
    Run Xming by searching it from start menu. When it is loaded you should see this when you go to show hidden icons button at the bottom right corner of your desktop.
  5. In order for X server to work with BASH run the following command at the terminal
    echo "export DISPLAY=localhost:0.0" >> ~/.bashrc

    This will add the environment variable for display to the .bashrc file.

  6. Downloading Freesurfer:
    You can obtain your copy of Freesurfer from their web page. I would recommend getting the nightly build as I was having some trouble running the stable version v5.30, especially some of the graphical windows. If you want to try the stable version download the 64-bit centos6 stable v5.3.0 freesurfer. I would encourage getting the v6.0 nightly build even though it is not the official release. You can go back and reinstall the stable version 6.0 once it is released.To download your choice of FreeSurfer type this command at the terminal:
    For stable release v5.3.0


    For nightly build

    wget ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/dev/freesurfer-Linux-centos6_x86_64-dev.tar.gz

    Hint: You can copy the link with your mouse and when you right-click at the terminal, it will be automatically pasted so you don’t have to type it in manually.
    This is a large file (~4.6GB) so it may take some time to download it based on your network speed.

  7.  Extract the zipped file to install it. It is customary to install it at /usr/local/ so let’s extract it to that directory.
    sudo tar -xzf freesurfer-Linux-centos6_x86_64-dev.tar.gz -C /usr/local/

    You will require your admin password (for Linux) to extract it to /usr/local. Again this step can take few minutes since it is extracting a file that’s several gigabytes in size. Once extracted, we’ll have to change permissions on that folder.

    sudo chmod -R 755 /usr/local/freesurfer

    This allows you to make changes to files in that folder.

  8. Obtain the FreeSurfer license:
    In order to run the FreeSurfer applications you need to register and obtain a license from their website.
    FreeSurfer Registration
    Once you have the license emailed to you, copy the contents between the lines that read “cut here” and create a license.txt file.

    sudo nano /usr/local/freesurfer/license.txt

    Paste the contents with right-click
    Press ctrl+X to exit
    Press y to accept and save it as license.txt
    Hit Enter

  9. Add FreeSurfer path to .bashrc:
    echo "export FREESURFER_HOME=/usr/local/freesurfer" >> ~/.bashrc
    echo "source $FREESURFER_HOME/SetUpFreeSurfer.sh" >> ~/.bashrc
  10. Dependencies: libjpeg.so.62
    Generally there is a libjpeg dependency that is required by FreeSurfer graphics. It doesn’t come with the basic Ubuntu installation but it can be installed using:

    sudo apt-get install libjpeg62
  11. Final check:
    Check that the Xming server is running and it says Xming Server:0.0 when you hover the mouse on the icon in the lower right hand corner.Type bash at the terminal. You should see the following:

    -------- freesurfer-Linux-centos6_x86_6.0 --------
    Setting up environment for FreeSurfer/FS-FAST (and FSL)
    FREESURFER_HOME   /usr/local/freesurfer
    FSFAST_HOME       /usr/local/freesurfer/fsfast
    SUBJECTS_DIR      /usr/local/freesurfer/subjects
    MNI_DIR           /usr/local/freesurfer/mni
  12. Test your installation:
    Check if everything works by going through some of the examples listed on the FreeSurfer website.
    FreeSurfer examples
    If everything has been installed correctly you should be able to run command line functions and open GUIs just like on a Mac or Linux machine.
    tksurfer_win10If you have any questions about the installation, please post a comment. If you have questions about FreeSurfer please visit the FreeSurfer user community mail archives.
Sep 252013

Before making any modification to any files, first create a backup of smb.conf file

sudo cp /etc/samba/smb.conf  /etc/samba/smb.conf.bak

The open the configuration file for editing:

sudo gedit /etc/samba/smb.conf

In the section identified as Share Definitions, insert this piece of code. The path string should be the path for folder you will be sharing. If you want others to have the ability to write to that directory –

sudo mkdir -p /path/to/shared/folder
sudo chown nobody.nogroup /path/to/shared/folder
    comment = Ubuntu File Server Share
    path = /path/to/shared/folder
    browsable = yes
    guest ok = no
    read only = no
    create mask = 0755

Once the configuration file has been saved, its time to restart the samba daemon

sudo restart smbd
sudo restart nmbd

Once the samba daemon has restarted, you need to add a list of users who can access samba folder.

sudo smbpasswd -a username

To access this directory from windows, open My Computer -> Tools -> Map Network Drive

Folder address for this share would be:


NOTE: The folder is called share in the share definition. You can call it something else and edit the parameters based on the chosen share name.If you want to have access to this folder each time, make sure to save the password and check that option to reconnect at login.



Jan 112013

To get the stock quotes for NYSE listings create some file named stockval and add it to your PATH.

Then gedit the file with the text:


p=`printf "curl -s 'http://download.finance.yahoo.com/d/quotes.csv?s=$1&f=l1'"`
price=`eval $p`;
echo $price












Make that file executable

chmod +x stockval

Close out, and open a terminal. If you have the path correctly configured, execute the stockval command using the company symbol as an argument and it returns the stock price on the line below.

stockval goog

732.15 << output
Sep 302012

There is a compose functionality out there:

Linux umlaut typing

For the Gnome Desktop:

  • go to System -> Preferences -> Hardware -> Keyboard on the Gnome menu
  • select the Layouts tab
  • click the Options… button
  • expand Compose key position
  • check the box Right Ctrl is Compose or Right Win-key is Compose

The Right Ctrl or the Right Win key are now a “compose key”. With it you can compose symbols by combining two characters. The double-quote then the letter “a” equals an umlaut-a (ä). Tap the compose key, then tap shift+quote for a double-quote, then tap the a-key.

  • ä is compose, then “, then a
  • ö is compose, then “, then o
  • ü is compose, then “, then u
  • ß is compose, then s, then s

The list of compose key sequences can be found at:

Compose key sequences

Content found at blog: http://idolinux.blogspot.com/



Aug 082012

Here’s a nifty little script I found.

You need to run it within the directory containing the wma files:


current_directory=$( pwd )

#remove spaces
for i in *.wma; do mv "$i" `echo $i | tr ' ' '_'`; done

#Rip with Mplayer / encode with LAME
for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm -ao pcm:waveheader $i && lame -m s audiodump.wav -o $i; done

#convert file names
for i in *.wma; do mv "$i" "`basename "$i" .wma`.mp3"; done

rm audiodump.wav

If you aren’t happy with underscores and want your spaces back, run this on the command line:

for i in `ls *.mp3`; do p=`echo $i | tr '_'  ' '`; mv $i "$p"; done

They will be in the proper format now, and google music compatible.

Jul 202012

In the newer versions of Linux, an open source driver is usually installed by default to run the graphic cards. However this driver can sometimes be absolutely messy, and it is essential to remove the Nouveau driver and install the binary driver from Nvidia.

However, if after you reboot into the service mode from grub menu, and try to install the NVIDIA-Linux-x86_64-xxx.run driver in the init 3 level, the program will kick you out saying that the Nouveau driver is still in use.

The way to disable the Nouveau drivers from kernel is to boot in the service mode and run the following commands:

echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
 update-initramfs -u

Once its done reconfiguring the kernel, you will need to reboot, and again get to service mode.

After that, get into init 3 mode, and install the NVIDIA-Linux-x86-64.xxx.run script. The installation should be successful at this point.

May 292012

Replace your ~/.vnc/xstartup file with the following content:

exec /etc/X11/xinit/xinitrc[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
May 092012

If you are going for a complete reinstall of OS and you need to get a list of packages you have at present, so that you can reinstall them after you have installed Linux from scratch, run the following:

sudo dpkg --get-selections | awk '{ ORS=" "; print $1; }' > packagelist.txt

This saves the everything to packagelist.txt. Mind blown!


Dec 282011

To monitor the instantaneous network usage, execute the ifstat command in bash. You may need to acquire it from a repository if you don’t have it already.

sudo apt-get install ifstat

To display usage on eth0, with a 5 second delay, just once:

ifstat -i eth0 5 1

You can change the number of seconds, and the number of times you want the output displayed. If you don’t specify the count, it will go on forever until you ctrl-c out of it.

So here is a script that displays the download rates in MB/s and upload rates in KB/s every 5 seconds until you hit ctrl-c.

while :
# Press ctrl-c to exit
x=`ifstat -i eth0 5 1 | tail -1 | tr '\t' ' '`;  #tail -1 takes the DL and UL speeds in KB/S
x1=`echo $x | cut -d ' ' -f1`; x2=`echo $x | cut -d ' ' -f2`;
x1=$(echo "scale=3; $x1/1024" | bc); # Convert DL rate to MB/S
printf "D: %0.3f MB/s\t U: %0.3f KB/s\n" "$x1" "$x2"
Dec 062011

The newer releases of Ubuntu and Linux Mint have started getting stuck during LiveCD installation or after distribution/kernel upgrade.  Usually the point where it gets stagnant is when it reaches this line:


Nothing happens past that point. A solution or a workaround to this is to insert the nolapic acpi=off switch in the grub boot line. There are 3 ways to do this:

1: If you are starting a fresh install from a CD and the installation pauses at the kernel_thread_helper line, you need to restart your computer.

When you boot from your installation CD, choose F6 before you continue trying out the LiveCD. This give you boot option at the bottom of your screen.

At the very end of the line add nolapic acpi=off and hit enter to continue booting from LiveCD. In most cases this should work.

2. The same problem may arise when you do a distribution upgrade or even a kernel upgrade. In that case you need to change your grub.cfg file. Follow these steps:

sudo nano /boot/grub/grub.cfg

Enter your sudo password and it will bring you to your grub menu configuration.

Look for the section that read similar to this:

menuentry 'Ubuntu, with Linux 2.6.38-11-generic' --class ubuntu --class gnu-linux --class gnu --class os {
 set gfxpayload=$linux_gfx_mode
 insmod part_msdos
 insmod ext2
 set root='(hd0,msdos6)'
 search --no-floppy --fs-uuid --set=root 337e2841-fc82-61b3-84be-5a9c71ae43b8
  linux   /boot/vmlinuz-2.6.38-11-generic root=UUID=337e2841-fc82-61b3-84be-5a9c71ae43b8 ro quiet splash vt.handoff=7
 initrd  /boot/initrd.img-2.6.38-11-generic

You want to change the line that I have identified above to read:

linux   /boot/vmlinuz-2.6.38-11-generic root=UUID=337e2841-fc82-61b3-84be-5a9c71ae43b8 ro quiet splash vt.handoff=7 nolapic acpi=off

After adding these switches to the boot menu option, press ctrl-X, then save and exit.

This is for a permanent change if you can boot using an older kernel.

3: If you cannot login to an older kernel or recovery mode because of the kernel_thread_helper error,  you have to press “e” (without the quotation marks)  to edit the boot options when you get the grub menu.

For the kernel you want to use, edit the end of the line that reads

linux   /boot/vmlinuz-2.6.38-11-generic root=UUID=337e2841-fc82-61b3-84be-5a9c71ae43b8 ro quiet splash vt.handoff=7


linux   /boot/vmlinuz-2.6.38-11-generic root=UUID=337e2841-fc82-61b3-84be-5a9c71ae43b8 ro quiet splash vt.handoff=7 nolapic acpi=off

Press Enter and you should be able to boot.

Nov 092011

Some .avi files tend to have an out of sync audio track, some can’t be scrolled through (forward/reverse), while others might show an message that says the index file needs to be recreated.

Solution is to create a copy of that file that has an index recreated and remove the original and save the copy and all the usual replacement methods.

mencoder -idx files1.avi -ovc copy -oac copy -o file2.avi

Here file1.avi is the input file, and file2 is the output file with corrected index.

May 112011

For the first time I was able to get VNC to work with Ubuntu with Gnome session instead of a xterm on gray background. The steps involved were exactly the same as I was following earlier, with one exception: the setup of xstartup in the ~/.vnc folder.

For your xstartup file in ~/.vnc (the “.vnc” folder in

your home directory), you need the following:



# Uncomment the following two lines for normal desktop:


# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic &

xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &

gnome-session &

# twm &


instead of uncommenting the lines as the script suggests, you change the window manager to gnome-session

make sure restart vnc4server

The line which got Gnome working was “gnome-session &”


Now for all the steps involved (works in Karmic Koala Alpha 2, Ubuntu 9.10, kernel 2.6.30-10)

1. Install ssh server, ssh client, VNC viewer, VNC server, and xinetd

sudo apt-get install openssh-server openssh-client vnc4server xinetd vncviewer

2. Setup the ssh password for your login


3. Test out the ssh server by typing in

ssh localhost or ssh your_login@your_ip_address

4. Then create a vnc password

sudo vncpasswd ~/.vncpasswd

5. Edit the xstartup file in ~/.vnc directory

For your xstartup file in ~/.vnc (the “.vnc” folder in

your home directory), you need the following:



# Uncomment the following two lines for normal desktop:


# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic &

xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &

gnome-session &

# twm &


instead of uncommenting the lines as the script suggests, you change the window manager to gnome-session

6. Create a VNC desktop

vnc4server :1 -geometry 1024×768

7. Then to tunnel into your VNC desktop, first create a SSH tunnel by logging into SSH with the comand:

ssh -L 5901:your_ip_address:5901 your_username@your_ipaddress

8. Finally, load up your VNC desktop

vncviewer localhost:1

And now you are ready to use connect to your machine remotely and use administer the computer remotely.

P.S: If you are using a firewall (hardware or software, you need to get enable port forwarding and unblock ports 22 and 5900-5999 on the Ubuntu machine to allow SSH and VNC to be accessed.