Using the imaging servers

From SBIwiki

Jump to: navigation, search


The imaging servers

SBI/MR centrum owns three imaging servers:

For security reasons, the IP adresses of the servers is not written down in this wiki.

Connecting to the servers

It is possible to connect to RETZ server from outside using VPN client or from inside KI network.

You can run imaging programs through two different protocols: SSH (X11) or VNC.

Running RDP NEW (14 August 2012)

RDP is not new per say, but I haven't been able to make it work on RETZ. It much simpler than anything else and it seems to be more efficient than VNC. It can also be tunnelled in SSH.

Running X11

Running X11 is recommended unless you want to run a batch that will take several hours. If you run a long batch using X-server you will have to keep your computer running. Otherwise the process will be stopped.

Running VNC

Running VNC has the advantage of giving you the whole desktop of RETZ and to allow you to shut down your computer while keeping your batch running on RETZ.

Small UNIX tutorial

Where am I in RETZ/BERZ/BOLD ?

  • when opening a terminal window

In order to start programs or more generally interact with the LINUX kernel, you need a shell that you can obtain by opening a terminal window on your desktop, or putty. A terminal window is a window on which you write command lines (e.g. matlab, fsl, cd, pwd, cp, mv, etc) that will be interpreted by the kernel. You can write a command line after the prompt that will generally look like (for user kajsa):


By default, opening a terminal window redirect the command line into the user's home catalogue. Hence Kajsa opens a terminal window, the prompt reads commands lines in /home/kajsa.

  • pwd command line

Indeed, if Kajsa enters the command line pwd:

kajsa@retz:~$ pwd

the command line interpreter returns the entire path to Kajsa's home catalogue ( /home/kajsa ).

  • cd comand line

User kajsa now wants to change directory in order to work locally in her fMRI study directory. She needs to change directory to /home/kajsa/myfMRIstudy (see above for scheme). She can use the cd (change directory) command line:

kajsa@retz:~$ cd /home/kajsa/myfMRIstudy

She can already see her location in the prompt. the symbol ~ refers to her home catalogue /home/kajsa and she is now in ~/myfMRIstudy. Just to be sure, she can check her location by again using the command line pwd:

kajsa@retz:~/myfMRIstudy$ pwd

  • ~ and . directories

There are some directory symbols that any user can use in order to avoid typing a whole path.

The symbol ~ designs the home directory. Hence, is starting from a position in /home/kajsa/myFMRIstudy, Typing cd ~ is equivalent to typing cd /home/kajsa.

kajsa@retz:~/myfMRIstudy$ pwd
kajsa@retz:~$ cd ~

As a prefix, it can be used for pointing at the home directory of other users:

kajsa@retz:~/myfMRIstudy$ cd ~adam
kajsa@retz:~$ pwd

copy and/or move and delete files inside RETZ

copy files

The command line cp allows you to copy files from one directory to another. The syntax is the following:

cp SourceFile TargetFile

For instance, if Kajsa wants to copy the (source) file fctses1_001.nii that lies under /home/kajsa/myfMRIstudi/preproc/subject1/session1/ into another directory named myDiffusion. Let's give three examples of how she could do:

  • if being in /home/kajsa.
kajsa@retz:~$ cp myfMRIstudy/preproc/subject1/session1/fctses1_001.nii myDiffusion/
kajsa@retz:~$ ls myDiffusion/

The command line ls lists the directory. Among other files and directories we find the file fctses1_001.nii in the home directory. The copying process worked! Note that the paths for source and target files are relative the current directory (i.e. the directory obtained by typing pwd). She could have (useless) typed cp /home/kajsa/myfMRIstudy/preproc/subject1/session1/fctses1_001.nii /home/kajsa/myDiffusion/ instead. Since the current directory was /home/kajsa, she could also have typed cp ~/myfMRIstudy/preproc/subject1/session1/fctses1_001.nii ~/myDiffusion/. But again, unless you are dealing with specific programing there is no need for that.

  • if being in ~/myDiffusion

The prompt indicates that we are in ~/myDiffusion, but let us check it with pwd before copying.

kajsa@retz:~/myDiffusion$ pwd  
kajsa@retz:~/myDiffusion$ cp ~/myfMRIstudy/preproc/subject1/session1/fctses1_001.nii .
kajsa@retz:~/myDiffusion$ ls

Since we are in the directory ~/myDiffusion and that we want the target to be in that directory, we can just use . for the target.

  • if being in ~/myfMRIstudy/preproc/
kajsa@retz:~/myfMRIstudy/preproc$ cp ./subject1/session1/fctses1_001.nii ~/myDiffusion/
kajsa@retz:~/myfMRIstudy/preproc$ ls ~/myDiffusion/

Note that if fctses1_001.nii is already present in ~/myDiffusion (previous copying) it will overwritten each time you invoke cp if the target file is not changed. If you would like to change the name to something like mycopiedfile then the syntax will simply be:

kajsa@retz:~/myfMRIstudy/preproc$ cp ./subject1/session1/fctses1_001.nii ~/myDiffusion/mycopiedfile.nii
kajsa@retz:~/myfMRIstudy/preproc$ ls ~/myDiffusion/
fctses1_001.nii  mycopiedfile.nii

moving files

The mv command can be used instead of cp if you just want to move the file to another location or rename it without keeping the original file. It is recommended to be sure of what you are doing when moving files or directories. A safer procedure is to first copy (using cp) and then remove the original (using rm).

deleting files

The rm command helps you removing files or directories.

To remove the file fctses1_001.nii, you can alternatively remove it localy from its directory:

kajsa@retz:~$ cd myfMRIstudy/preproc/subject1/session1/
kajsa@retz:~/myfMRIstudy/preproc/subject1/session1$ rm fctses1_001.nii

or you can remove the file directly from your home directory (or anywhere else).

kajsa@retz:~$ rm myfMRIstudy/preproc/subject1/session1/fctses1_001.nii

copy files from/to RETZ to/from another computer

The transfer protocol for copying files to RETZ is sftp. Simple ftp is not allowed. The program used for copying will depend of the Operating System on the other computer.


If you run windows on your own computer and need to copy to or from RETZ some files or directories, the simplest is to use WinSCP. How to use WinSCP.

Linux and MAC OS X

Open a terminal window and use the command line scp as follow:

  • copy from your linux or Mac computer to RETZ:

Kajsa wants to copy the file my_file.txt that lies on her Linux or Mac computer under the directory mydirectory to her RETZ home directory under the directory myDiffusion.

scp ~/mydirectory/my_file.txt

Kajsa wants to copy the directory mydirectory that lies on her Linux or Mac computer to her RETZ home directory under the directory myfMRIstudy.

scp -r ~/mydirectory

  • copy from RETZ to your computer

Kajsa wants to copy the nifti file that lies in RETZ under ~/myfMRIstudy/preproc/subject1/session1/ into her Mac or Linux computer.

scp .

Kajsa wants to copy the directory myfMRIstudy that lies in her home directory on RETZ into her current directory ..

scp -r  .

Common project folder: Difficult, but useful

It is sometimes useful to have a folder common to all users involved in a project. It allows the different users to have the desired rights over the folder. Let's say that a group composed of Kajsa and Judit (usernames kajsa and judit) asks the administrator to create a common project folder named "ourproject". It would be possible to add Judit in Kajsa's group, but let's say instead that we create a new user for the group called "mylab". Let's add users kajsa and judit to the group mylab:

sudo usermod -aG mylab kajsa
sudo usermod -aG mylab judit

Now we can adopt two strategies: either we want any user of the group to be able to edit and modify files. Or we want the users to be able to read and modify other's files but without overwriting other's file. Let's for themoment focus on the first strategy:

Read,Write and modify other's files

If the fictive user mylab creates a directory called "ourproject"

mylab@berz:~$ mkdir ourproject

we can look at the rights of the different users on that directory:

mylab@berz:~$ ls -l
total 4
drwxrwxr-x 2 mylab mylab 4096 Jun 12 11:17 ourproject

The UNIX command ls with option -l lists the files and directories. We can see some useful information about ourproject. mylab's username mylab is listed twice. the first time is to state that mylab is the owner of the folder. The second time is to state that the folder's group is mylab. The series of letters drwxr-xr-x tells us about the type (file or folder) of ourproject (d=directory), about the owner's (mylab) rights on it (rwx = read,write, execute), about the rights of users belonging to the group mylab (rwx = read, no right at all, execute, i.e. these users can read and run the files, but not modify them.), and about other users's rights on it (r-x = read, no right at all, execute). But what about new files created in the directory ourproject? Will they keep the same rights? The answer is no unless you add a "sticky-bit".

mylab@berz:~$ chmod -R g+s ourproject/
mylab@berz:~$ ls -ld ourproject/
drwxrwsr-x 2 mylab mylab 4096 Jun 12 11:21 ourproject/

Now you can see the "s" instead for the "x" for the group. Let's look at some examples:

User Kasja creates the files kajsasfile in the directory "ourproject".

kajsa@berz:~$ touch /data/mylab/ourproject/kajsasfile.m
kajsa@berz:~$ ls -l /data/mylab/ourproject/kajsasfile.m
-rw-rw-r-- 1 kajsa mylab 18 Jun 12 11:19 /data/mylab/ourproject/kajsasfile.m

Now let's see if user judit can modify the file:

judit@berz:~$ cat >> /data/mylab/ourproject/kajsasfile.m
Hi, this is Judit

Yes, she can!

Another example: Kajsa creates a file in her home directory and copies it into ourproject:

kajsa@berz:~$ touch copyfile.m
kajsa@berz:~$ ls -l copyfile.m 
-rw-rw-r-- 1 kajsa kajsa 0 Jun 12 11:20 copyfile.m

Apparently, as long as the file stays in her home directory the file copyfile.m will be owned by kajsa as a user and as a group.

But what happens if she moves it into ourproject?

kajsa@berz:~$ cp copyfile.m /data/mylab/ourproject/
kajsa@berz:~$ ls -l /data/mylab/ourproject/
total 4
-rw-rw-r-- 1 kajsa mylab  0 Jun 12 11:21 copyfile.m
-rw-rw-r-- 1 kajsa mylab 18 Jun 12 11:19 kajsasfile.m

Ah, now the group becomes suddenly "mylab".

judit@berz:~$ cat >> /data/mylab/ourproject/copyfile.m 
I can write here too

And user judit can modify it!

Personal tools