Unix Tutorial for FreeSurfer Users
description
Transcript of Unix Tutorial for FreeSurfer Users
![Page 1: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/1.jpg)
Unix Tutorial for
FreeSurfer Users
Allison Stevens
![Page 2: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/2.jpg)
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?
![Page 3: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/3.jpg)
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?– power to write many scripts with many
commands to work with lots of data– to use computer resources on the
network efficiently, such as clusters
![Page 4: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/4.jpg)
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:Double click on hard driveApplications > Utilities > XQuartz (double click)Applications > Utilities > Terminal
![Page 5: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/5.jpg)
Warm Up
Type: and hit enter.
date
![Page 6: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/6.jpg)
Warm Up
Type: and hit enter. Should see
date Mon Apr 6 8:05:24 EDT 2009
![Page 7: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/7.jpg)
Warm Up
Type: and hit enter. Should see
Type: and hit enter.
date Mon Apr 6 8:05:24 EDT 2009
cal
![Page 8: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/8.jpg)
Warm Up
Type: and hit enter. Should see
Type: and hit enter. Should see
date Mon Apr 6 8:05:24 EDT 2009
cal April 2009Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 1112 13 14 15 16 17 1819 20 21 22 23 24 2526 27 28 29 30
![Page 9: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/9.jpg)
Directories
• Unix uses a hierarchical file system (think folders in Windows)
![Page 10: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/10.jpg)
Directories
• Unix uses a hierarchical file system (think folders in Windows)
Home is like “My Computer”
![Page 11: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/11.jpg)
Directories
• Unix uses a hierarchical file system(think folders in Windows)
Home is like “My Computer”
Like “My Documents”
![Page 12: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/12.jpg)
Directories
• Unix uses a hierarchical file system (think folders in Windows) Home is like
“My Computer”
Like “My Documents”
Like “My Photos”
![Page 13: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/13.jpg)
Directories
• Unix uses a hierarchical file system (think folders in Windows) Home is like
“My Computer”
Like “My Documents”
Like “My Photos”
picture.jpg
![Page 14: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/14.jpg)
Location
Type: and hit enter. Should see
shows “present working directory” or current location as a path
similar to:/MyComputer/MyDocuments/MyPhotos
pwd
/home/nmrclass
/Users/YourName
OR
![Page 15: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/15.jpg)
Opening a Directory
• Not double clicking • Type command to “open”
• Commands to open files will differ
![Page 16: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/16.jpg)
Navigating Directories
“change directory”: move into a folder
“list”: see contents of directory
ls
cd __
ls __
![Page 17: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/17.jpg)
Navigating Directories
“change directory”: move into a folder
“list”: see contents of directory
ls
cd __
ls __
Desktop matlab tmp TUTORIAL_DATA
![Page 18: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/18.jpg)
Anatomy of a Command
command -option1 –option2 file
command - -help
![Page 19: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/19.jpg)
Anatomy of a Command
command -option1 –option2 file
command - -help
ls --help
Try:
![Page 20: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/20.jpg)
Directory Contents
• List contents of directory you are in lists names of directories/filesls
ls -lrt
ls -l
ls -a
![Page 21: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/21.jpg)
Directory Contents
• List contents of directory you are in lists names of directories/files lists hidden files too
.cshrc
.bashrc
.alias
ls
ls -lrt
ls -l
ls -a
![Page 22: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/22.jpg)
Directory Contents
• List contents of directory you are in lists names of directories/files lists hidden files too lists file details
drwxrwx---
user groupothers
ls
ls -lrt
ls -l
ls -a
![Page 23: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/23.jpg)
Directory Contents
• List contents of directory you are in lists names of directories/files lists hidden files too lists file details lists recent files last
ls
ls -lrt
ls -l
ls -a
![Page 24: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/24.jpg)
Save Some Time
Filename Completion
hit Tab key should see hit
enter
History
hit key should see
ls Des
ls Desktop
ls Desktop
![Page 25: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/25.jpg)
Changing Directories
makes a new directory “practice”
changes to directory “practice”
mkdir practice
cd practice
ls -lrt
pwd
ls
pwd
/home/nmrclass
/home/nmrclass/practice
should see
should see
should see Nothing!
![Page 26: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/26.jpg)
Changing Directories
![Page 27: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/27.jpg)
Changing Directoriesmkdir stuff
ls
makes folder “stuff” inside practiceshould see “stuff”
![Page 28: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/28.jpg)
Using an Editor
If using a Mac:
Type: I could write a script.File > Save (Buffer)
File > Exit emacs
should see “mynotes.txt”
emacs mynotes.txt open -e mynotes.txt
ls
Format > Make plain textFile > Save
![Page 29: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/29.jpg)
Using an Editor
If using a Mac:
Type: I could write a script.File > Save (Buffer)
File > Exit emacs
should see “mynotes.txt”
gedit mynotes.txt open -e mynotes.txt
ls
Format > Make plain textFile > Save
![Page 30: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/30.jpg)
Using an Editor
![Page 31: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/31.jpg)
Copying files
ls
cp --help
cp mynotes.txt stuff
cd stuff
more mynotes.txt
learn all the options or “arguments”
is the copy command
cp
![Page 32: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/32.jpg)
Copying files
ls
cp --help
cp mynotes.txt stuff
cd stuff
less mynotes.txt
learn all the options or “arguments”
is the copy command
cp
![Page 33: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/33.jpg)
Changing Directories
shows one directory up
ls ..
pwd /home/nmrclass/practice/stuff
ls ../.. goes up two!cd ..
should see
cd ../..
can also do (but don’t right now):on
![Page 34: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/34.jpg)
Copying / Moving files
cp mynotes.txt myothernotes.txt
Could also use do:
mv myothernotes.txt hernotes.txt
mv hernotes.txt ..
![Page 35: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/35.jpg)
Removing Files
rm mynotes.txt
ls
pwd should be in “stuff”
ls
![Page 36: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/36.jpg)
Review
• no double clicking• mkdir• ls• cd• pwd• emacs, gedit, vi, pico• cp• rm
![Page 37: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/37.jpg)
Using FreeSurfer
With FreeSurfer, certain variables must be set in order to use it correctly:
FREESURFER_HOME
SUBJECTS_DIR
tell Operating System where FreeSurfer is
tell FreeSurfer where data is
![Page 38: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/38.jpg)
Required Variables
• To use FreeSurfer you’ll have to do:
setenv FREESURFER_HOME /home/apps/freesurfer
source $FREESURFER_HOME/SetUpFreeSurfer.csh
tell Operating System where FreeSurfer is
source this script to get your computer ready to use FreeSurfer (sources other scripts & sets other variables)
setenv SUBJECTS_DIR /path/to/data
![Page 39: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/39.jpg)
Required Variables
To go to location of your data:
$ means take the value of the variable
cd $SUBJECTS_DIR
setenv SUBJECTS_DIR /path/to/data
![Page 40: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/40.jpg)
Required Variables
To go to location of your data:
$ means take the value of the variable
cd $SUBJECTS_DIRaka
cd /path/to/data
setenv SUBJECTS_DIR /path/to/data
![Page 41: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/41.jpg)
$
How ‘echo’ works:
To set a variable:
To check what a variable is set to:echo $TEST_VARIABLE
setenv TEST_VARIABLE yourfirstname
echo I am not scared of unix.
![Page 42: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/42.jpg)
Required Variables
With FreeSurfer, certain variables must be set in order to use it correctly:
FREESURFER_HOME
SUBJECTS_DIR
tell Operating System where FreeSurfer is
tell FreeSurfer where data is
echo $FREESURFER_HOME
echo $SUBJECTS_DIR
To check variables
![Page 43: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/43.jpg)
Visualization Tools
• For FreeSurfer visualization tools:
tkmedit subj001 T1.mgz -aux wm.mgz
tksurfer subj001 lh inflated
VisualizationTool subject data_file -aux other_data_file
VisualizationTool subject hemisphere data_file
freeview volume1 volume2 -f surface1 surface2
![Page 44: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/44.jpg)
More Help
http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/CommandLineNavigation
Links on Wiki under “Unix Tutorial”
Glossary of Unix commands
![Page 45: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/45.jpg)
The End
Good Luck!
![Page 46: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/46.jpg)
Intro to FreeSurfer Jargon
voxelsurfacevolumevertexsurface-basedreconcortical, subcorticalparcellation/segmentationregistration, morph, deform, transforms
(computing vs. resampling)
![Page 47: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/47.jpg)
Cortical vs. Subcortical GM
coronal
sagittal
subcortical gm
cortical gm
![Page 48: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/48.jpg)
Cortical vs. Subcortical GM
coronal
sagittal
subcortical gm
![Page 49: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/49.jpg)
Parcellation vs. Segmentation
(subcortical) segmentation
(cortical) parcellation
![Page 50: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/50.jpg)
Registration
-align subjects-common space-reference points b/w subjects will be
sametransforms
template
deform
morph
warp
compute
resample
![Page 51: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/51.jpg)
FreeSurfer Questions
Search for terms and answers to all your questions in the Glossary,
FAQ, orFreeSurfer Mailing List Archives
![Page 52: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/52.jpg)
![Page 53: Unix Tutorial for FreeSurfer Users](https://reader033.fdocuments.net/reader033/viewer/2022061518/56813a27550346895da20969/html5/thumbnails/53.jpg)
More Help
alias e emacsman alias
ls file* lists file1, file2, file3ls file[12] lists file1 and file2 but not file3
command >>& file.txt save output to screen and errors in text file