Unix Tutorial for Free Surfer Users Helpful To

  • Slides: 57
Download presentation
Unix Tutorial for Free. Surfer Users

Unix Tutorial for Free. Surfer Users

Helpful To Know • Free. Surfer Tutorial Wiki: https: //surfer. nmr. mgh. harvard. edu/fswiki/Fs.

Helpful To Know • Free. Surfer Tutorial Wiki: https: //surfer. nmr. mgh. harvard. edu/fswiki/Fs. Tutorial • Questions? • Answers: https: //surfer. nmr. mgh. harvard. edu/fswiki/Fs. Tutorial/Que stion. Answers

What is Unix/Linux? • An operating system (like Windows and OS X) • Linux

What is Unix/Linux? • An operating system (like Windows and OS X) • Linux is the free, modifiable, and redistributable version of Unix • Why use it?

What is Unix/Linux? • An operating system (like Windows and OS X) • Linux

What is Unix/Linux? • An operating system (like Windows and OS X) • Linux is the free, modifiable, and redistributable version of Unix • Why use it? – freedom to modify and customize – power to write many scripts with multiple commands to manage data – to use computer resources on the network efficiently, such as clusters

Getting Started Communicate with operating system through a “shell” or terminal window. For course-provided

Getting Started Communicate with operating system through a “shell” or terminal window. For course-provided Linux computers: Double click Terminal icon on Desktop For Macs: Applications > Utilities > XQuartz (double click) Applications > Utilities > Terminal

Warm Up Type: date and hit enter.

Warm Up Type: date and hit enter.

Warm Up Type: date and hit enter. Should see. Mon Apr 2009 6 8:

Warm Up Type: date and hit enter. Should see. Mon Apr 2009 6 8: 05: 24 EDT

Warm Up Type: date and hit enter. Should see. Mon Apr 2009 Type: cal

Warm Up Type: date and hit enter. Should see. Mon Apr 2009 Type: cal and hit enter. 6 8: 05: 24 EDT

Warm Up Type: date and hit enter. Should see. Mon Apr 6 8: 05:

Warm Up Type: date and hit enter. Should see. Mon Apr 6 8: 05: 24 EDT 2009 Type: cal and hit enter. Should see April 2009 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Directories • Unix uses a hierarchical file system (think folders in Windows)

Directories • Unix uses a hierarchical file system (think folders in Windows)

Directories • Unix uses a hierarchical file system (think folders in Windows) Home is

Directories • Unix uses a hierarchical file system (think folders in Windows) Home is like “My Computer”

Directories • Unix uses a hierarchical file system (think folders in Windows) Home is

Directories • Unix uses a hierarchical file system (think folders in Windows) Home is like “My Computer” Like “My Documents ”

Directories • Unix uses a hierarchical file system (think folders in Windows) Home is

Directories • Unix uses a hierarchical file system (think folders in Windows) Home is like “My Computer” Like “My Documents ” Like “My Photos”

Directories • Unix uses a hierarchical file system (think folders in Windows) Home is

Directories • Unix uses a hierarchical file system (think folders in Windows) Home is like “My Computer” Like “My Documents ” Like “My Photos” picture. jpg

Location path: /My. Computer/My. Documents/My. Photos Type: pwd /home/nmrclass and hit enter. Should see

Location path: /My. Computer/My. Documents/My. Photos Type: pwd /home/nmrclass and hit enter. Should see OR /Users/Your. Name shows “present working directory” or current location as a path

Opening a Directory • Not double clicking • Type command to “open” • Commands

Opening a Directory • Not double clicking • Type command to “open” • Commands to open files will differ

Navigating Directories cd __ “change directory”: move into a folder ls ls __ “list”:

Navigating Directories cd __ “change directory”: move into a folder ls ls __ “list”: see contents of directory

Navigating Directories cd __ “change directory”: move into a folder ls ls __ “list”:

Navigating Directories cd __ “change directory”: move into a folder ls ls __ “list”: see contents of directory Desktop matlab tmp TUTORIAL_DATA

Anatomy of a Command command -option 1 –option 2 command - -help For Mac:

Anatomy of a Command command -option 1 –option 2 command - -help For Mac: man __ file

Anatomy of a Command command -option 1 –option 2 command file - -help Try:

Anatomy of a Command command -option 1 –option 2 command file - -help Try: ls --help or man ls

Directory Contents • List contents of directory you are in ls ls -a ls

Directory Contents • List contents of directory you are in ls ls -a ls -lrt lists names of directories/files

Directory Contents • List contents of directory you are in ls ls -a lists

Directory Contents • List contents of directory you are in ls ls -a lists names of directories/files lists hidden files too ls -lrt . cshrc. bashrc. alias

Directory Contents • List contents of directory you are in ls ls -a ls

Directory Contents • List contents of directory you are in ls ls -a ls -l lists names of directories/files lists hidden files too lists file details ls -lrt drwxrwx--user group others

Directory Contents • List contents of directory you are in ls ls -a ls

Directory Contents • List contents of directory you are in ls ls -a ls -lrt lists names of directories/files lists hidden files too lists file details lists recent files last

Save Some Time Filename Completion hit Tab key should see ls Desktop History hit

Save Some Time Filename Completion hit Tab key should see ls Desktop History hit key should see ls Desktop hit enter

Changing Directories mkdir practice makes a new directory “practice” ls -lrt pwd should see

Changing Directories mkdir practice makes a new directory “practice” ls -lrt pwd should see cd practice pwd should see ls should see /home/nmrclass changes to directory “practice” /home/nmrclass/practice Nothing!

Changing Directories

Changing Directories

Changing Directories mkdir stuff makes folder “stuff” inside practice ls should see “stuff”

Changing Directories mkdir stuff makes folder “stuff” inside practice ls should see “stuff”

Using an Editor emacs mynotes. txt If using a Mac: open -e Type: I

Using an Editor emacs mynotes. txt If using a Mac: open -e Type: I could write a script. File > Save (Buffer) File > Exit emacs ls should see “mynotes. txt” Format > Make plain text File > Save

Using an Editor gedit mynotes. txt If using a Mac: open -e Type: I

Using an Editor gedit mynotes. txt If using a Mac: open -e Type: I could write a script. File > Save (Buffer) File > Exit gedit ls should see “mynotes. txt” Other Editors: pico Format > Make plain text File > Save

Using an Editor Ctrl+C & Returns prompt Runs program in background gedit error. log

Using an Editor Ctrl+C & Returns prompt Runs program in background gedit error. log &

Copying Files cp cp --help is the copy command learn all the options or

Copying Files cp cp --help is the copy command learn all the options or “arguments” cp mynotes. txt stuff cd stuff ls more mynotes. txt

Copying Files cp cp --help is the copy command learn all the options or

Copying Files cp cp --help is the copy command learn all the options or “arguments” cp mynotes. txt stuff cd stuff ls less mynotes. txt

Changing Directories ls. . /. . shows one directory up goes up two! can

Changing Directories ls. . /. . shows one directory up goes up two! can also do (but don’t right now) cd. . /. . pwd should see /home/nmrclass/practice/stuff

Copying / Moving Files Could also use/do: cp mynotes. txt myothernotes. txt mv hernotes.

Copying / Moving Files Could also use/do: cp mynotes. txt myothernotes. txt mv hernotes. txt . .

Removing Files pwd ls should be in “stuff” rm mynotes. txt ls

Removing Files pwd ls should be in “stuff” rm mynotes. txt ls

Using Free. Surfer With Free. Surfer, certain variables must be set in order to

Using Free. Surfer With Free. Surfer, certain variables must be set in order to use it correctly: FREESURFER_HOME tell Operating System where Free. Surfer is SUBJECTS_DIR tell Free. Surfer where data is

What is a Variable? • Character string that is assigned a value • Way

What is a Variable? • Character string that is assigned a value • Way of passing information from the shell to programs • Assign a value to a variable • Programs look “in the environment” for variables • Easy to change values/manipulate

What is a Variable? How ‘echo’ works: echo Freesurfer Rocks! To set a variable:

What is a Variable? How ‘echo’ works: echo Freesurfer Rocks! To set a variable: setenv TEST_VARIABLE yourfirstname To check what a variable is set to: echo $TEST_VARIABLE

Using Free. Surfer With Free. Surfer, certain variables must be set in order to

Using Free. Surfer With Free. Surfer, certain variables must be set in order to use it correctly: FREESURFER_HOME tell Operating System where Free. Surfer is SUBJECTS_DIR tell Free. Surfer where data is

Required Variables • To use Free. Surfer you’ll have to do: setenv FREESURFER_HOME /home/apps/freesurfer

Required Variables • To use Free. Surfer you’ll have to do: setenv FREESURFER_HOME /home/apps/freesurfer tell Operating System where Free. Surfer is source $FREESURFER_HOME/Set. Up. Free. Surfer. csh source this script to get your computer ready to use Free. Surfer (sources other scripts & sets other variables) setenv SUBJECTS_DIR /path/to/data

Required Variables • To use Free. Surfer you’ll have to do: setenv FREESURFER_HOME /home/apps/freesurfer

Required Variables • To use Free. Surfer you’ll have to do: setenv FREESURFER_HOME /home/apps/freesurfer tell Operating System where Free. Surfer is source $FREESURFER_HOME/Set. Up. Free. Surfer. csh aka /home/apps/freesurfer/Set. Up. Free. Surfer. csh source this script to get your computer ready to use Free. Surfer (sources other scripts & sets other variables) setenv SUBJECTS_DIR /path/to/data

Required Variables • To use Free. Surfer you’ll have to do: export FREESURFER_HOME=/home/apps/freesurfer tell

Required Variables • To use Free. Surfer you’ll have to do: export FREESURFER_HOME=/home/apps/freesurfer tell Operating System where Free. Surfer is source $FREESURFER_HOME/Set. Up. Free. Surfer. sh source this script to get your computer ready to use Free. Surfer (sources other scripts & sets other variables) export SUBJECTS_DIR=/path/to/data

Required Variables • To use Free. Surfer you’ll have to do: export FREESURFER_HOME=/home/apps/freesurfer tell

Required Variables • To use Free. Surfer you’ll have to do: export FREESURFER_HOME=/home/apps/freesurfer tell Operating System where Free. Surfer is source $FREESURFER_HOME/Set. Up. Free. Surfer. sh source aka /home/apps/freesurfer/Set. Up. Free. Surfer. sh source this script to get your computer ready to use Free. Surfer (sources other scripts & sets other variables) export SUBJECTS_DIR=/path/to/data

Required Variables With Free. Surfer, certain variables must be set in order to use

Required Variables With Free. Surfer, certain variables must be set in order to use it correctly: FREESURFER_HOME tell Operating System where Free. Surfer is SUBJECTS_DIR echo tell Free. Surfer where data is To check variables $FREESURFER_HOME echo $SUBJECTS_DIR

Required Variables setenv SUBJECTS_DIR /path/to/data To go to location of your data: cd $SUBJECTS_DIR

Required Variables setenv SUBJECTS_DIR /path/to/data To go to location of your data: cd $SUBJECTS_DIR $ means take the value of the variable

Required Variables setenv SUBJECTS_DIR /path/to/data To go to location of your data: cd $SUBJECTS_DIR

Required Variables setenv SUBJECTS_DIR /path/to/data To go to location of your data: cd $SUBJECTS_DIR aka cd /path/to/data $ means take the value of the variable

Review • Case sensitive • Does not like spaces in file names (e. g.

Review • Case sensitive • Does not like spaces in file names (e. g. filename. txt vs. file name. txt) • • Ctrl+c kills a process & brings back command prompt Type ‘q’ to quit the program ‘less’ Highlight & middle click to copy & paste Use ‘&’ to open a program in the background Cannot open a 2 nd program if do not have a command prompt

Review • • no double clicking mkdir ls cd pwd emacs, gedit, pico cp

Review • • no double clicking mkdir ls cd pwd emacs, gedit, pico cp rm

More Help • UNIX Tutorial For Beginners: http: //www. ee. surrey. ac. uk/Teaching/Unix/ •

More Help • UNIX Tutorial For Beginners: http: //www. ee. surrey. ac. uk/Teaching/Unix/ • Linux in a Nutshell: http: //docstore. mik. ua/orelly/linux/lnut/ch 01_01. htm • UNIX Cheat Sheet: http: //tux. cs. unlv. edu/refs/linux_commands. html • Command Line Tutorial: http: //surfer. nmr. mgh. harvard. edu/fswiki/Fs. Tutorial/Command. Line. Na vigation

The End Good Luck!

The End Good Luck!

Writing Scripts • Putting multiple commands together. • Automatically running a sequence of commands

Writing Scripts • Putting multiple commands together. • Automatically running a sequence of commands • Example: create a file named my_first_script. csh with the contents: #!/bin/csh setenv name Free. Surfer echo I love $name ! % chmod u+x my_first_script. csh %. /my_first_script. csh

Loops in Scripts • You can create loops, if statements, … • Example: create

Loops in Scripts • You can create loops, if statements, … • Example: create a file named my_first_loop. csh with the contents: #!/bin/csh foreach name (‘Bill Murray’ ‘Wes Anderson’) echo I love $name ! end

Inputs to Scripts • You can create take inputs from the command line •

Inputs to Scripts • You can create take inputs from the command line • Example: create a file named my_first_IO. csh with the contents: #!/bin/csh echo The $0 command is called with $#argv parameters echo parameter 1 is $1 echo parameter 2 is $2

Required Variables • To use Free. Surfer you’ll have to do: setenv FREESURFER_HOME /home/apps/freesurfer

Required Variables • To use Free. Surfer you’ll have to do: setenv FREESURFER_HOME /home/apps/freesurfer tell Operating System where Free. Surfer is source $FREESURFER_HOME/Set. Up. Free. Surfer. csh source this script to get your computer ready to use Free. Surfer (sources other scripts & sets other variables) setenv SUBJECTS_DIR /path/to/data

Registration -align subjects -common space -reference points b/w subjects will be same transforms template

Registration -align subjects -common space -reference points b/w subjects will be same transforms template deform morph warp compute resample

More Help alias e emacs man alias ls file* lists file 1, file 2,

More Help alias e emacs man alias ls file* lists file 1, file 2, file 3 ls file[12] lists file 1 and file 2 but not file 3 command >>& file. txt save output to screen and errors in text file