Unix Tutorial for FreeSurfer Users

Slides:



Advertisements
Similar presentations
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Advertisements

Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.
Basic Unix Dr Tim Cutts Team Leader Systems Support Group Infrastructure Management Team.
Intro to FreeSurfer Jargon
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Introduction to Linux Workshop February Introduction Rob Lane & The HPC Support Team Research Computing Services CUIT.
Unix Tutorial for FreeSurfer Users Allison Stevens.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface (or Terminal) What is the filesystem tree.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Welcome to Linux & Shell Scripting Small Group How to learn how to Code Workshop small-group/
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
Unix Basics Chapter 4.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction Unix-like system is everywhere Linux Android for smartphones Google Chrome OS for Chromebook Web.
Unix Tutorial for FreeSurfer Users. Helpful To Know FreeSurfer Tutorial Wiki:
Unix Tutorial for FreeSurfer Users. Helpful To Know FreeSurfer Tutorial Wiki:
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
COMP1070/2002/lec4/H.Melikian COMP1070 Lecture #4  Unix software architecture  Correcting mistakes  System setups  Useful commands for the beginner.
1 Operating Systems Lecture 2 UNIX and Shell Scripts.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Reading None.
Processing Your Own Data With FreeSurfer, certain variables must be set in order to use it correctly: FREESURFER_HOME SUBJECTS_DIR tell Operating System.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
Unix and Samba By: IC Labs (Raj Kidambi). What is Unix?  Unix stands for UNiplexed Information and Computing System. (It was originally spelled "Unics.")
Intro to Programming Environment 1. Today You Will Learn how to connect to a machine remotely with “nomachine NX client” Learn how to create a new “source.
A Genomics View of Unix. General Unix Tips To use the command line start X11 and type commands into the “xterm” window A few things about unix commands:
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: whereis, which, whoami, finger, passwd, cal, date Working with Files: cat, more, less.
Linux and Java Basics. What is Linux? Operating system by Linus Torvalds that was a clone of Unix (thus Linux) Free and open source – this is the reason.
Linux Commands C151 Multi-User Operating Systems.
Linux A practical introduction. 1)Background and Getting Started Linux is an operating system with multiple providers Red Hat/CentOS (our version) Ubuntu.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
ICE UNIX TUTORIAL. File System Commands cd – change directory cd – change directory ls – list contents ls – list contents rm – remove/delete rm – remove/delete.
Intro to FreeSurfer Jargon voxel surface volume vertex surface-based recon cortical, subcortical parcellation/segmentation registration, morph, deform,
Intro to FreeSurfer Jargon. voxel surface volume vertex surface-based recon cortical, subcortical parcellation/segmentation registration, morph, deform,
CS 120 Extra: The CS1 Server Tarik Booker CS 120.
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
CMSC 104, Version 9/011 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Reading None.
UNIX Basics Matt Hayward October 18, 2016 LS560 – Information Technology for information professionals.
Introduction to Unix for FreeSurfer Users
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Tutorial of Unix Command & shell scriptS 5027
Commands Basic syntax of shell commands UNIX or shell commands have a basic structure command -options target command comes first (such as cd or ls) any.
Prepared by: Eng. Maryam Adel Abdel-Hady
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
Andy Wang Object Oriented Programming in C++ COP 3330
Some Linux Commands.
The Linux Operating System
Intro to FreeSurfer Jargon
Shell Environments.
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
WELCOME FREESURFER COURSE ATTENDEES!
WELCOME FREESURFER COURSE ATTENDEES!
LING 408/508: Computational Techniques for Linguists
Intro to FreeSurfer Jargon
Operating Systems and Using Linux
Tutorial of Unix Command & shell scriptS 5027
Intro to FreeSurfer Jargon
Intro to FreeSurfer Jargon
Andy Wang Object Oriented Programming in C++ COP 3330
CSE 303 Concepts and Tools for Software Development
Module 6 Working with Files and Directories
Lab 2: Terminal Basics.
Presentation transcript:

Unix Tutorial for FreeSurfer Users Allison Stevens -covers only basics: cd, copying files; no scripting -basic understanding of unix necessary to use FreeSurfer -not comprehensive, just to get you through course

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? Use the term Linux interchangeably with Unix sometimes. The data that comes off the scanner is lots of data – hundreds of slices and within each slice hundreds to thousands of voxels.

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 The data that comes off the scanner is lots of data – hundreds of slices and within each slice hundreds of voxels.

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 compare to Windows GUI  hit Start and see icons of programs to choose from. Similar to DOS. -to run programs, must type a command for what you want to do on the command line.

Warm Up Type: and hit enter. date Mouse needs to be in window to work Commands in boxes This is how you’ll interact with FreeSurfer

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

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

Warm Up Type: and hit enter. Should see date Mon Apr 6 8:05:24 EDT 2009 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 cal

Directories Unix uses a hierarchical file system (think folders in Windows) Even though you see just a blinking cursor, you now have access to all your directories and files just at that one line.

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

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 like “My Computer” Like “My Documents” Like “My Photos”

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: /MyComputer/MyDocuments/MyPhotos Type: and hit enter. Should see shows “present working directory” or current location as a path /home/nmrclass OR pwd /Users/YourName -notice there are no spaces in between the names. Unix does not like spaces so please avoid them -the path shows, at the end, the current directory you are in and all the directories you need to go through to get to it. -in tutorials, will need to go into directory where data is stored -check on your current location using pwd whenever you encounter an error to make sure you’re in the right place

Opening a Directory Not double clicking Type command to “open” -will show commands for opening directories but different for files and programs -may see gnumeric or ooffice in tutorials Commands to open files will differ

Navigating Directories “change directory”: move into a folder “list”: see contents of directory cd __ ls ls __ cd *space* and then the name of the directory you want to change into

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

command -option1 –option2 file Anatomy of a Command command -option1 –option2 file command - -help -option often called flag -this format is true for Unix and FreeSurfer commands -two dashes before the word “help”

command -option1 –option2 file Anatomy of a Command command -option1 –option2 file command - -help -two dashes before help -argument could be a file or volume Try: ls --help

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

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

Directory Contents List contents of directory you are in drwxrwx--- lists names of directories/files lists hidden files too lists file details drwxrwx--- ls ls -a ls -l ls -lrt -ownership of file as well as date it was created and size user group others

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 -a ls -l ls -lrt r could mean recursive or reverse

Save Some Time Filename Completion hit Tab key should see hit enter History hit key should see ls Des ls Desktop -case sensitive -keep hitting up arrow key to see other commands you typed in the past Ctrl+a on mac goes to home; ctrl+e goes to end Option + left right arrows jumps to spaces ls Desktop

/home/nmrclass/practice Changing Directories makes a new directory “practice” changes to directory “practice” mkdir practice ls -lrt /home/nmrclass pwd should see cd practice Always do ls and pwd afterwards to see what changed. pwd /home/nmrclass/practice should see ls should see Nothing!

Changing Directories

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

Format > Make plain text 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 Format > Make plain text File > Save Ctrl+x, Ctrl+c to exit and save in emacs when opened within a terminal ls

Format > Make plain text 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 Format > Make plain text File > Save Ctrl+x, Ctrl+c to exit and save in emacs when opened within a terminal ls

Using an Editor

Copying files is the copy command learn all the options or “arguments” cp cp --help learn all the options or “arguments” cp mynotes.txt stuff -can use tab with mynotes.txt “less” is similar to more, however it lets you scroll up and down pages. Must enter ‘q’ to get out of less command. cd stuff ls more mynotes.txt

Copying files is the copy command learn all the options or “arguments” cp cp --help learn all the options or “arguments” cp mynotes.txt stuff “less” is similar to more, however it lets you scroll up and down pages. Must enter ‘q’ to get out of less command. cd stuff ls less mynotes.txt

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

Copying / Moving files Could also use do: cp mynotes.txt myothernotes.txt mv myothernotes.txt hernotes.txt mv is like cut and paste mv hernotes.txt ..

Removing Files should be in “stuff” pwd ls rm mynotes.txt ls Gone forever; no trash can

Things to know 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 2nd program if do not have a command prompt

Review no double clicking mkdir ls cd pwd emacs, gedit, vi, pico cp rm more commands in reference sheet hand out

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 -for the tutorials today, FREESURFER_HOME will already be set for you. But when you go home and use FreeSurfer on your own machine, you will need to make sure you have these variables set before you can begin working with FreeSurfer. -during the course SUBJECTS_DIR will change often, so pay attention to instructions at top of tutorial and change it accordingly tell FreeSurfer where data is

Required Variables To use FreeSurfer you’ll have to do: setenv FREESURFER_HOME /home/apps/freesurfer tell Operating System where FreeSurfer is source $FREESURFER_HOME/SetUpFreeSurfer.csh -Set up environment or initialize freesurfer (see setenv a lot) Can set up .profile or .cshrc to always run these commands for you for every terminal window opened source this script to get your computer ready to use FreeSurfer (sources other scripts & sets other variables) setenv SUBJECTS_DIR /path/to/data

Required Variables To use FreeSurfer you’ll have to do: export FREESURFER_HOME=/home/apps/freesurfer tell Operating System where FreeSurfer is source $FREESURFER_HOME/SetUpFreeSurfer.csh -use ‘export’ for bash Can set up .profile or .cshrc to always run these commands for you for every terminal window opened source this script to get your computer ready to use FreeSurfer (sources other scripts & sets other variables) export SUBJECTS_DIR=/path/to/data

setenv SUBJECTS_DIR /path/to/data Required Variables To go to location of your data: $ means take the value of the variable setenv SUBJECTS_DIR /path/to/data cd $SUBJECTS_DIR -Set up environment or initialize freesurfer (see setenv a lot) -cd SUJBECTS_DIR is shortcut to cd /path/to/data -in tutorial will often have to cd $SUBJECTS_DIR

setenv SUBJECTS_DIR /path/to/data Required Variables To go to location of your data: $ means take the value of the variable setenv SUBJECTS_DIR /path/to/data cd $SUBJECTS_DIR aka cd /path/to/data -Set up environment or initialize freesurfer (see setenv a lot)

setenv TEST_VARIABLE yourfirstname $ How ‘echo’ works: To set a variable: To check what a variable is set to: echo Allison is cool. setenv TEST_VARIABLE yourfirstname echo prints to the screen whatever you type after it echo $TEST_VARIABLE

echo $FREESURFER_HOME 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 To check variables echo $FREESURFER_HOME echo $SUBJECTS_DIR

More Help http://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/CommandLineNavigation Links on Wiki under “Unix Tutorial” Glossary of Unix commands

The End Good Luck!

Intro to FreeSurfer Jargon voxel surface volume vertex surface-based recon cortical, subcortical parcellation/segmentation registration, morph, deform, transforms (computing vs. resampling)

What FreeSurfer Does… FreeSurfer creates computerized models of the brain from MRI data. -"IR prepped SPGR" (inversion recovery prepared SPGR) is GE version of MPRAGE -if did this manually, would take a long time Input: T1-weighted (MPRAGE) 1mm3 resolution (.dcm) Output: Segmented & parcellated conformed volume (.mgz)

Intro to FreeSurfer Jargon voxel voxel like pixel -tons of pixels make up this image, but with scan data we call them voxels (because they have a volume – and that’s how we can already get some meaningful info from this image: volume of brain)

Intro to FreeSurfer Jargon -got all this data, want to divide it up to have some meaningful info about this subject -surface is a cortical boundary (gm or wm) surface

Intro to FreeSurfer Jargon -think of surfaces not only in terms of this 2D slice but also in terms of how they would look over the entire 3D structure of a brain -what boundary over all the wm in brain looks like; what boundary over all the gm in brain looks like surface

Intro to FreeSurfer Jargon vertex -surfaces are made up of many tiny points which are the vertices of the surface. -it is here we store information about surface (the point that we sample measures at) -surface-based analysis involves any value you can sample onto the surface

Recon “recon your data” …short for reconstruction …cortical surface reconstruction …shows up in command recon-all reconstruction of surfaces (creation of those boundaries of gm and wm) recon-all is how you process data in freesurfer “check your recons” refers to output

Recon

Volumes orig.mgz T1.mgz brainmask.mgz wm.mgz filled.mgz (Subcortical Mass) -usually referring to mri data; also referring to mgz files created by freesurfer -volume of subcortical regions – actual measurement

Cortical vs. Subcortical GM -surfaces not used to get measurements on subcortical so it’s okay that they are wonky there sagittal coronal

Cortical vs. Subcortical GM -subcortical masked out sagittal coronal

Parcellation vs. Segmentation (cortical) parcellation (subcortical) segmentation -parcellation refers to division of cortical areas; segmentation refers to division of subcortical areas, sometimes also segmentation of wm and gm

Intro to FreeSurfer Jargon voxel surface volume vertex surface-based recon cortical, subcortical parcellation/segmentation registration, morph, deform, transforms (computing vs. resampling)

FreeSurfer Questions Search for terms and answers to all your questions in the Glossary, FAQ, or FreeSurfer Mailing List Archives -lectures followed by hands on tutorials -firefox opens to the schedule page. from there links to lecture slides and tutorials. follow along

Registration Goal: to find a common coordinate system for the input data sets Examples: comparing different MRI images of the same individual (longitudinal scans, diffusion vs functional scans) comparing MRI images of different individuals

Inter-subject, uni-modal example Flirt 9 DOF target subject Flirt 6 DOF Flirt 12 DOF 12/13/2011 62

Linear registration: 6, 9, 12 DOF subject target Flirt 12 DOF Flirt 9 DOF Flirt 6 DOF 63

Linear registration: 6, 9, 12 DOF Flirt 12 DOF Flirt 9dof subject target Flirt 6dof

Linear registration: 6, 9, 12 DOF Flirt 12 DOF Flirt 9 DOF subject target Flirt 6 DOF

Intra-subject, multi-modal example before spatial alignment after spatial alignment

before spatial alignment after spatial alignment

before spatial alignment after spatial alignment

Inter-subject non-linear example target CVS reg

Some registration vocabulary Input datasets: Fixed / template / target Moving / subject Transformation models rigid affine nonlinear Objective / similarity functions Applying the results deform, morph, resample, transform Interpolation types (tri)linear nearest neighbor

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 FreeSurfer 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 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 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 FreeSurfer you’ll have to do: setenv FREESURFER_HOME /home/apps/freesurfer tell Operating System where FreeSurfer is source $FREESURFER_HOME/SetUpFreeSurfer.csh -Set up environment or initialize freesurfer (see setenv a lot) source this script to get your computer ready to use FreeSurfer (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 deform morph warp compute resample computing vs. resampling ie we compute talairach but we don't resample deform, morph (why it isn't really changing your data)

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