-
Introduction
-
Notes for interpreting these instructions:
-
Commands in the bold font denote computer commands, as they would appear
on UNIX machines
-
Commands preceded by % are UNIX shell commands
-
Commands preceded by >> are MATLAB commands
-
Bracketed text which is not in the bold font represents notes for the user,
NOT commands for the computer
-
Types of UNIX computers in the NMR lab
-
Sun Workstations - can run two types of window environments
-
Open Windows
-
CDE: Common Desktop Environment
-
Linux Boxes - can run two types of window environments
-
CDE: Common Desktop Environment
-
KDE: Kommon Desktop Environment
-
Silicon Graphics
-
Basic UNIX commands
-
Change directories: % cd [directory name]
-
Check your present working directory: % pwd
-
Copy a file: % cp [old filename] [new filename]
-
Copy a directory: % cp -r [old directory] [new directory]
-
Remove a file: % rm [filename]
-
Remove a directory: % rm -r [directory name]
-
Change a file name: % mv [old filename] [new filename]
-
Logon to another computer
-
% xhost + [computer name logging into]
-
% rlogin [computer name logging into]
-
% setenv DISPLAY [computer name logging in from]:0
-
steps a and b can be aliased to: % r[name of computer logging
into]
-
step c can be aliased to: % set[name of computer of origin]
-
Listing files and directories:
-
ls list all file and directory names
-
ls -l list all files and directories in
long format (includes owner, date, group, permissions and size)
-
ls -d *tag list only directory names ending
in tag
-
ls [directory name] | wc list the number of files in the
directory (word count)
-
Checking hard disk space: % df -k
-
Checking the size of a directory: % du -sk [directory name]
-
Check if certain commands are being executed: % ps -aux | grep [command
name]
-
Stop a command or process: % kill [PID #]
-
Check the CPU usage: % top
-
Printing files:
-
Black and white laser printer:
-
Printing: % lpr [filename]
-
Checking printer queue: % lpq
-
Color laser printer:
-
Printing: % lpr -Pscarface [filename]
-
Checking printer queue: % lpq -Pscarface
-
Getting online help:
-
In UNIX type: % man [command name]
-
In MATLAB type: >> help [command or program name]
-
Starting MATLAB
-
On any computer you can start MATLAB version 5 by typing matlab in a UNIX
command window. On the Sun workstations you can run MATLAB version 4 by
typing matlab4. On the Silicon Graphics computers you can run MATLAB version
4 by typing matlab -R4.
-
In your home directory you should have a directory called matlab and within
that directory you should have a file called startup.m (the .m tells the
computer that this is a MATLAB file). If you do not have this file you
can copy an example from /boreas1/fmri_data/templates/.
-
This file is read every time you start matlab and it tells MATLAB what
directories to search in for the programs used in this manual.
-
It also has the command fmri_initialization which initializes all the global
variables and save directories for the programs in this manual.
-
Finally, it has a variable called save_directory_tab which you can modify
to check only your result directories once they have been assigned
-
Transferring Data From Signa 3
- Anatomical Image Extraction
- Telnet to signa and execute listselect. This provides a menu
interface for extracting images from the signa database. Selecting images
via option C allows you to extract multiple images in one command.
Use listselect to extract all images in your anatomical series.
The extracted files are put in /usr/g/insite/tmp on signa. Logout of
signa when you are done.
- Anatomical and Functional Data Transfer
- Make a directory on your harddrive with the new study number
and change to that new directory.
- Ftp to signa.
- Change directory to /usr/g/insite/tmp and mget
your anatomical images by typing: mget eStudyNumber*. So if my study number was e4444
I would type: mget e4444*
- Change directory to /yale/reconned/.
Change directory to study#series#, so for example if I
wanted to transfer series4 from study e4444 I would type: cd e4444s4
- Now mget all files in your study directory by typing: mget *
-
Setup Files
-
Create a setup file for each subject
- Create a directory on your allocated harddrive or in your home directory
called setups_fmri. Copy a template setup file for your file format
(check below to determine your file format) from /boreas1/fmri_data/templates/setup_files/
into this directory for future reference. Example setup files are also
given at the end of this manual.
-
Resave the template setup file under a new name (or just copy a recently
used setup file), typing the study number and any applicable letters after
the period in the title
-
EX: setup_fmri.template would become setup_fmri.12345tag (tag being an
identifier for your study)
-
Open the new setup file and change the appropriate study number and
specifications. Make sure the number of slices, number of images per slice, set
information (including appropriate image/task mappings), and directories for
data and anatomicals (the latter located towards the end of the setup file)
are correct.
-
Line by Line description of setup file
-
The # signs in the setup file are used as markers for the program that is
reading it, so do not add or remove them.
-
Study Name - any name you wish to give to your study, subject name and date of
scan
-
Study Number - directory where raw data is stored - give the whole path of
access beginning from /.
-
Series Number - the series number containing your functional data.
(changes based on file format - check Image File Formats)
-
anmr directory name - the name of the directory in which the data where put
while scanning. (changes based on file format - check Image File Formats)
-
preprocessing command - this command will be executed before reading data, this option can help you change some
parameters before loading the data. You should use this to specify your result directory by typing
save_directory='/harddrive/personalfolder/fmri_data_yourstudyname/';
-
Number of slices
-
Number of different tasks - number of different activation tasks performed.
These tasks (not necessary real tasks) define the groups of images which will
be treated together in performing statistics. Each image should belong to at
most one task defined directly in the setup file. New tasks made from
combinations of 'basic' tasks can be added using the add_task postprocessing
function (see Postprocessing Commands). This number includes only tasks
defined directly in the setup file - not tasks created using add_task.
The number of groups of lines following must be equal to the number of
different tasks/sets defined here.
-
List of images for set - this is a list of trial numbers containing the data
belonging to this task (changes based on file format - check Image File Formats).
This must be followed by range lines, one for each trial.
-
ranges - the image numbers from the appropriate trial which belong to this
task. There must always be an even number of image numbers between the # signs
in each range line. Image numbers are read in groups of two, so in our first
setup file example (at the end of this manual) the images for the blink task
will be 4 through 20, then skip to 44 through 60, and skip again to 84 through
100 and finally 124 through 140.
-
Series/File for anatomical - the series number containing your anatomicals.
You may use anatomical images obtained using echoplaner (EPI), SIGNA or no
anatomical images at all. If you leave this space blank the fmri will use the
mean of the functional images as an anatomical image.
-
anatomical header size - 7168 for SIGNA and 40 for EPI image
-
anatomical image size - pixel number in X and Y direction (for SIGNA 256)
-
functional header size - header size for functional data (changes based on file
format - check Image File Formats)
-
functional image size (X/Y) - pixel size of the functional image (changes based
on file format - check Image File Formats)
-
coordinates of interesting Field of View (FOV) - Usually the image is much
bigger than the size of the brain. To speed the processing and save the memory
you should define a smaller rectangle containing only the important area. You
should use try_setup to fine tune the size of FOV.
-
shift_x, shift_y - if you use the SIGNA anatomical images and EPI functional
images they are sometimes shifted one with respect to another. After running
the try_setup program (see Using Try Setup) use the fix_pos button to overlay
those images. After finding the shift values that seem the best, enter them
to your setup file.
-
FOV factor (X and Y) - these define the ratio between the functional and
anatomical machine defined field of view. They should be set to 1 if
functional and anatomical are obtained with the same technique. In the typical
EPI-SIGNA setup with a 20x40 EPI FOV and a 40x40 SIGNA FOV, the FOV factor
in the phase direction should be put to 2 (the FOV factor is determined
by the equation anatFOV/EPIFOV). The FOV factor will change based on file
format - check Image File Formats.
-
marker position - you may define the position of external water markers to
load the data of their intensities (even if they are out of your chosen FOV).
If you will not use it is better to leave this space free (this will save
memory by not loading additional data). This is rarely used.
-
postprocessing commands - you may enter predefined postprocessing commands or
any MATLAB commands which will be executed just after loading the data file.
The most commonly used are the threshold and init_gaus_filter commands. (see
Postprocessing Commands for descriptions)
-
Image File Formats - what parameters to change in setup
file based on file format
-
RUN_export_all format - within your studynumber directory you would
have a series directory (003) which would include many image (image1, image2,
image3 ... etc) directories. Each of these image directories would represent
one trial and would contain the amount of images equal to the number of
images per slice multiplied by the number of slices.
-
Series Number: 003 (you need the 00 before the series number)
-
anmr directory name: TAG ([the tag on the beginning of each image - set
on signa)]
-
trial references: start with image0
-
functional header size: 40
-
function image size: 64x128
-
FOV factor - X: 1
-
FOV factor - Y: 2
-
APD2 format - within your studynumber directory you would have a
.img file and a .irp file for each trial. The .irp files are header files
and the .img files are your functional data files. The files will be denoted
with a word tag (PREMIE) at the beginning of the filename followed by the
study number (15720), series number (00003), trial number (00001), reconstruction
number (00002), and finally 001. An example would be: PREMIE_15720_00003_00001_00002_001.img
-
Series Number: 003 (you need the 00 before the series number)
-
anmr directory name: new_compact_format TAG (the tag on the beginning of
each image - set on signa3)
-
trial references: start with 1
-
functional header size: 8
-
function image size: 64x128
-
FOV factor - X: 1
-
FOV factor - Y: 2
-
Prism format - within your studynumber directory you would have
a .img file for each trial. The files will be denoted by the study number
(16167), series number (3) and trial number (1). An example would be: 16167_3_1.img
-
Series Number: 3 (you DO NOT need the 00 before the series number)
-
anmr directory name: compact_format
-
trial references: start with 1
-
functional header size: 16384
-
function image size: 64x64
-
FOV factor - X: 2
-
FOV factor - Y: 2
-
LX format - within your studynumber directory you would have
a K file, a P file, a .sdt file, a .log file and a .spr file for each trial. The Pfile is the
raw functional data. The .sdt file is the reconstructs functional data. The .spr file is a
header file. The .log file is a log of the reconstruction parameters. The Kfile is the kspace
data for the first image. The functional files will be denoted by the study number (e444),
series number (s3) and trial number (r1). An example would be: e444s3r1.sdt
-
Series Number: 3 (you DO NOT need the 00 before the series number)
-
anmr directory name:
- EPIrecon (for axial studies)
- EPIreconCoronal (for coronal studies)
-
trial references: start with 1
-
Series/File for anatomical: 2 (you DO NOT need the 00 before the series number)
-
anatomical header size: 4216
-
functional header size: 0
-
function image size: 64x64
-
FOV factor - X: 1
-
FOV factor - Y: 1
-
Postprocessing commands
-
threshold - the background is cleaned by zeroing each pixel with intensity
below a certain value of the maximum intensity (default value is 1/12). This helps to
remove outside noise and to calculate center of mass of the image intensity.
If you are interested in an area where signal may be surpressed by susceptibility
effect you should lower the threshold value.
-
Usage: # threshold(value) #
-
init_gaus_filt - spatial smoothing default value of 1 applies a gaussian
filter of half width at half maximum equal to pixel size
-
Usage: # init_guas_filt(value) #
-
chris_filt - high-pass filtering at 0.35 of the stimulus frequency (Chris
default value is 0.5), so you have to use it with increased number of OnOff
Blocks
-
Usage: # chris_filt(OnOffBlockNumber*1.4) #
-
add_task - You may create a new task by adding already defined tasks using
the add_task postprocessing command in your setup file. The following example
will define a new task called 'combined task' as the sum of tasks 1,3 and
4. The task, 'combined task', will be assigned the next available task
number.
-
Usage: # add_task([1 3 4],'combined task') #
-
add_task_part - You may create a new task containing a subset of images
present in an already defined task using the add_task_part postprocessing
command in your setup file. The following example will define a new task
called 'subset1' as the first image of every block in task 2. The task,
'subset1', will be assigned the next available task number.
-
Usage: # add_task_part(2,1,'subset1') #
-
Using try_setup to register the functional and anatomical data, and
to determine the field of view
-
Enter your directory on your allocated harddrive or your home directory.
You want to be in the directory just above your setups_fmri directory.
-
Start MATLAB by typing matlab at the Unix prompt
-
>> try_setup
-
>> Enter name of setup file: [enter study number with tag]
-
Ex: 12345tag
-
Then, the anatomical images should appear on screen, overlaid with red
lines denoting the borders of the first functional images for each slice
-
Click the fix_pos button
-
Lower the threshold of the functional image borders (red lines), if necessary,
by typing a lower number in the EPI threshold box
-
Select the slice of interest
-
Change the x and y shift values so that the red lines overlap structural
aspects/regularities in the anatomical images (shift values only increment
by 0.5)
-
Change the top/bottom/left/right FOV values so each of the slices fits
within the square box neatly for best viewing of t-maps (FOV values only
increment by 1)
-
Open the setup file for the subject and enter the above information in
the appropriate places (at the end of the file). Save and close the setup
file
-
Using read_fmri
-
While still in MATLAB start the read_fmri program
-
>> read_begin
-
prevents MATLAB from creating a pop-up window of functional images which
slows down the processing time
-
>> read_fmri
-
>>Enter setup file name: [enter study number with tag]
-
Ex: 12345tag
-
>> Select reference slice: [select top slice for determining motion]
-
Checking for motion
-
Once the read_fmri interactive window appears, click the check_pos button
in the lower right hand corner of the window.
-
A set of five graphs will appear in another window, the x axis for all
graphs is image number, from top to bottom the graphs will be
-
center of mass in the X direction (y-axis given in pixels)
-
green/dotted graph: center of mass of the brain shape (the image is binarially
transformed - anything outside the brain is set to zero, and anything inside
the brain is set to one)
-
center of mass in the Y direction given in (y-axis given in pixels)
-
green/dotted graph: center of mass of the brain shape as above
-
estimation of Z direction motion - Image Size (y-axis given in pixels)
-
image difference graphs (y-axis given as the difference divided by the
mean intensity)
-
blue/solid graph: difference between the current image and the first image
-
red/dotted graph: difference between the current image and the last image
-
green/dashdot graph: difference between the current image and the consecutive
image
-
mean image intensity (y-axis given in intensity)
-
Motion criteria: NOTE: The motion parameters given by the motion correction are much better estimations
of motion - use those for your criteria instead!!
-
For control subjects:
-
X or Y motion across whole study: max dev < 0.5
-
X or Y motion within one trial should be < 0.25
-
Z motion across whole study: max diff < 100
-
Z motion within one trial should be < 50
-
For patients or children:
-
X or Y motion across whole study: max dev < 1
-
X or Y motion within one trial should be < 0.5
-
Z motion across whole study: max diff < 100
-
Z motion within one trial should be < 50
-
If one or more trials do not meet this criteria then those trials should
be removed from the setup_file and the plots recalculated by rerunning
read_fmri.
-
If the whole study or the majority of the study does not meet the criteria
then that study should not be used at all.
-
If a few images are outliers you can pinpoint those images with specific
movement values using the following commands:
-
return to the MATLAB prompt
-
>> figure [opens new MATLAB figure window]
-
>> plot(desired direction of movement variable)
-
MassCenterX: center of mass in the X direction
-
MassCenterY: center of mass in the Y direction
-
ActiveNumber: center of mass in the Z direction
-
Ex: plot(MassCenterY)
-
>> grid [overlays a grid on the plot]
-
>> image_loc(find([direction]>[value]),:)
-
Returns image numbers with motion values greater than the given value in
the given center of mass direction
-
Ex: >> image_loc(find(MassCenterY>0.4),:)
-
Checking for ghosting
-
From the check position graph window, click the histogram plot button
-
Each graph in the histogram window is numbered 1-10 and represents a group
of intensities in the image. The y-axis of each plot is the number of pixels
in the image that correspond to that graph's group of intensities
-
If the first graph shows an abrupt, substantial and sustained decrease
in value and the second graph shows a similar increase in value, ghosting
has occurred and that data must be removed. To determine which images have
ghosting use the following commands:
-
return to the MATLAB prompt
-
>> figure [opens new MATLAB figure window]
-
>> plot(signal_hist(:,[bin number])
-
Ex: >> plot(signal_hist(:,2))
-
>> grid [overlays a grid on the plot]
-
>> image_loc(find(signal_hist(:,[bin number]>[value]),:)
-
Returns image numbers (and trial number they correspond to) with signal
intensities meeting mathematical criterion
-
Ex: >> image_loc(find(signal_hist(:,2)>200),:)
-
Batch Job Files
-
A batch job is an executable file which can be used to run the motion correction
and t-map generation programs at a later time (i.e. during the evenings).
An example batch job file is given at the end of this manual for each of
the file formats and templates can be copied from /boreas1/fmri_data/templates/batch_files/
-
To edit an executable batch file DO NOT double click on the icon
in the file manager!!! This will automatically run the program instead
of editing it. To edit an executable file:
-
Open Windows (Sun): In the file manager click the icon once, then
under File choose Open in Editor
-
CDE (Sun or Linux): In the file manager click the icon once, then
under Selected choose Open
-
Silicon Graphics: In the file manager click the icon once, then
under Selected choose Edit
-
KDE (Linux): In the file manager a single click with the left button
will execute the program - instead use the right button to select an icon
and then scroll down to text editor
-
Motion Correction portion of a batch job
-
File Formats and options
-
RUN_export_all format
-
APD1 program
-
usage: [run in MATLAB]
-
adp1_realign(`/harddrive/directory/setups_fmri/setup_fmri.12345tag','options',[slicethickness+gap])
-
Ex: adp1_realign(`spot3/CLS/setups_fmri/setup_fmri.12345cls','Qm',12.5)
-
options:
-
A - across trial correction - this will motion correct the whole study
to the middle image of the middle trial.
-
no A - within trial correction - this will motion correct each trial seperately
to the first image in that trial.
-
m - mask_all - any voxel that moves outside the imaging volume will be
set to zero for all timepoints.
-
q - 6 parameter decorrelation - (removal of motion related signal)
-
Q - 12 parameter decorrelation
-
neither q or Q - no decorrelation
-
paths needed in batch job
-
path(path,'/boreas0/gatenb/matlab/spm96');
-
path(path,'/boreas0/gatenb/matlab/apd1_format');
-
available spm96 programs
-
usage: [run in csh]
-
/boreas0/gatenb/bin/spm96_program /harddrive/directory/setups_fmri/setup_fmri.12345tag
[slicethickness+gap] [mask_all|no_mask]
-
Ex: /boreas0/gatenb/bin/spm96_reg /spot3/CLS/setups_fmri/setup_fmri.12345tag
12.5 mask_all
-
programs:
-
spm96_reg - within run correction, decorrelation in Z and Z^2
-
programs no longer needed due to APD1 program
-
spm96_snorARMA_reg - within run correction, NO decorrelation
-
spm96_regQ - within run correction, decorrelation in x,y,z, and 3 rotations
-
spm96_regQ2 - within run correction, decorrelation in x,y,z, 3 rotations
and all of their squares
-
APD2 format
-
usage: [run in MATLAB]
-
apd2_realign(list_of_apd2_files,'options',[number of slices],[images per
slice],[slice_thickness+gap])
-
Ex: apd2_realign(L,'Qm',10,100,8)
-
paths needed in batch job
-
path(path,'/boreas0/gatenb/matlab/spm96');
-
path(path,'/boreas0/gatenb/matlab/apd2_format');
-
L = list(`/harddrive/directory/12345/*.img');
-
options: see apd1 options
-
Prism format
-
usage: [run in MATLAB]
-
nf_realign(list_of_prism_files,'options')
-
Ex: nf_realign(L,'Qm')
-
paths needed in batch job
-
path(path,'/boreas0/gatenb/matlab/spm96');
-
path(path,'/boreas0/gatenb/matlab/new_format');
-
L = list(`/harddrive/directory/12345/12345*');
-
options: see apd1 options
-
LX format
-
usage: [run in MATLAB]
-
lx_realign(list_of_sdt_files,'options')
-
Ex: lx_realign(L,'Qm')
-
paths needed in batch job
-
path(path,'/boreas0/gatenb/matlab/LX_realign');
-
path(path,'/boreas0/spm99b');
-
L = list(`/harddrive/directory/e444/e444s3*');
-
options
-
Realign to the first image of the middle trial instead of the first image of the first trial
- mid=round(size(L,1)/2;L=[L(mid,:);L(1:mid-1,:);L(mid+1:end,:)];
-
n - for registration only
-
No n - for registration and decorrelation - (decorrelation is performed in the x, y and z directions
on a pixel by pixel basis instead of on a whole volume basis)
-
T-map generation portion of the batch job.
-
Important information included in a batch job
-
Study Name
-
Ex: Name = '12345tag';
-
Slices
-
Ex: Slices = [1:10];
-
Statistics
-
Ex: Stat = [26 22];
-
Common Statistics:
-
1 - T-statistic
-
5 - T-statistic combined: The combined performs statistics between images
that belong to the same trial. For each trial it checks if there are both
ON and OFF images. If it is true, it calculates a statistical map from
images in this trial. The maps calculated for each are later combined.
If there are less than four trials all have to be larger than the cutoff,
if there are between 4 and 7 trials all but one has to be larger (i.e.
Int(n/4) of maps are allowed to be smaller than cutoff).
-
6 - Percent Difference
-
22 - Skew Percent Difference
-
26 - Skew Tmean combined: The skewed t-statistics is similar to t-statistics,
but it takes into account the linear drift that may appear in the data.
This is due to a slow machine drift that shifts images over a fraction
of pixel during the trial. As the regular t-statistics approximates data
by a function f(t) = a*t(ON) + b*t(OFF), the skew statistics approximates
it as: f(t) = a*t(ON) + b*t(OFF) + c*t. The power of difference is calculated
as the difference a-b divided by the standard deviation of the data from
this fitting function.
-
77 - Oddball whole study correlation
-
81 - Oddball single event correlation
-
default t_tab1: correlation without delay
-
t_tab2: correlation with delay of 1 TR
-
t_tab3: correlation with delay of 2 TR
-
82 - Oddball single event correlation with amplitude
-
default t_tab1, t_tab2, t_tab3: same as statistics 81
-
t_tab4: amplitude without delay
-
t_tab5: amplitude with delay of 1 TR
-
t_tab6: amplitude with delay of 2 TR
-
Save Directory - where your result t-maps will be saved
-
Ex: save_directory = '/boreas1/fmri_data/';
-
Tasks - off/on subtractions for t-map generation
-
Ex: OffOn = [1 2 3 4]
-
In this instance, task one is subtracted from task 2 and task 3 is subtracted
from task 4. These t-maps will be saved as task 12 and task 34 respectively
-
Using motion corrected data
-
global motion corrected; motion corrected = 7;
-
Running a batch job
-
Login to the machine that will perform the batch job
-
% rlogin spot
-
Enter the directory containing the batch job file
-
cd /harddrive/directory
-
Set the time for the execution of the batch job in one of two ways:
-
% at -f batchfile.csh [time in 24 hour style]
-
% at -f batchfile.csh now + [any number] min
-
Using the find batch command - HIGHLY RECOMMENDED
-
Within your batch file the outfile must be denoted with the full-path-name
i.e. matlab > /hardrive/directory/batch.out << EOF
- usage:
/boreas0/gatenb/findbatch full-batchfile-name optional time
- If your setup files are not in your home directory you need to add a line in your batch file
that will change directory directly above where you store your setup files.
-
Checking batch job queue
-
% atq checks your batch job queue on Sun
or Linux computers and shows your job number
-
% at -l checks your batch job queue on Slicon Graphics computers
and shows your job number
-
% opcom show_all_jobs checks all users
batch job queue (on Sun machines only)
-
Removing a batch job from the queue
-
% atrm [Job Number] removes batch job from the queue on Sun
or Linux computers
-
% at -r [Job Number] removes batch job from the queue on Silicon
Graphics computers
-
Checking the output files
-
After the batch job is completed, an email will be sent to you to tell
you it has completed and an output log file will be generated. You should
examine this output log file for errors as well as any warnings.
-
Errors - you should troubleshoot any errors by checking to see if all the
information in the batch job and setup_file is correct. There may be a
spelling error, a directory error, a missing command, etc.
-
Warnings - the software will automatically check for certain image inconsistencies
called zebra artifacts. These will be alternating light and dark stripes
throughout an image. If the program senses these artifacts it will replace
that image with the previous image. The output file will report this if
it is happening. You can turn off this detection by adding the command
do_zebra = 0 to your batch job.
-
Checking motion correction results
-
Checking realign output parameters -
-
The realign output parameters are the estimates of the movement that the
motion correction program used to realign the image volumes. Two graphs
will appear- the top graph is the movement in the X, Y, and Z directions
and the bottom graph is the rotations pitch, roll, and yaw.
-
Single trial realign plot usage based on motion correction program:
-
LX: >> plot_realign('/harddrive/directory/e123/123_3_realign/REALIGN_1');
-
spm96: >> plot_realign('/harddrive/directory/12345/703/realign/REALIGN_1');
-
APD1: >> plot_realign('/harddrive/directory/12345/703/realign/REALIGN_image1'[);
-
APD2 or Prism >> plot_realign('/harddrive/directory/12345/12345_3_realign/REALIGN_1');
-
Whole study realign plot usage:
-
LX: >> plot_realign_all('/harddrive/directory/e123/123_3_realign');
-
spm96 or APD1: >> plot_realign_all('/harddrive/directory/12345/703/realign');
-
APD2 or Prism: >> plot_realign_all('/harddrive/directory/12345/12345_3_realign');
-
To plot the graphs in seconds (as opposed to images as above) give the
program the TR in seconds after the directory or filename.
-
LX: >> plot_realign_all('/harddrive/directory/e123/123_3_realign,1.5');
-
spm96 or APD1: >> plot_realign_all('/harddrive/directory/12345/703/realign,1.5');
-
APD2 or Prism: >> plot_realign_all('/harddrive/directory/12345/12345_3_realign,1.5');
-
To view the image numbers that exceed a given threshold (i.e.: 1 mm), rename
the variable used by the plot_realign program. This variable is an array
of the six motion parameters (x,y,x,pitch,roll and yaw)
-
>> new_name = ans;
-
>> find(new_name(:,[dimension of movement])>[value])
-
dimensions of movement:
-
x = 1, y = 2, z = 3, pitch = 4, roll = 5, yaw = 6 (Note: rotations are
given in degrees in the graph, but in radians in the variable)
-
Ex: >> find(new_name(:,3)>1) This will find all Z values greater
than 1
-
Motion Criteria
-
For control subjects (within a single trial)
-
X, Y, or Z direction - 1.5mm
-
pitch, yaw and roll rotations - 2 degrees
-
For patients or children (within a single trial)
-
X, Y, or Z direction - 2 mm
-
pitch, yaw and roll rotations - 3 degrees
-
Checking top and bottom slices for out of volume motion
-
The program is called showendslices and it will display the top and bottom
slices of each trial
-
Usage - only works on RUN_export_all or APD1 file formats:
-
first >> cd /boreas0/gatenb/matlab
-
>> showendslices('/harddrive/directory/study_number/703',number of slices,images
per slice)
-
Ex: >> showendslices('/spot3/attention/11009/703',7,146)
-
Using tal_define and zScale to transform images
-
Talairach space is used to orient all subjects into a uniform space. The
first program (tal_define) is used to determine anatomical landmarks in
the in-plane slices (usually axial or coronal). The second program (zScale)
is used to determine anatomical landmarks in the through-plane slices (sagitall).
-
At the MATLAB prompt just type tal_define and then the program will
prompt you for a subject number. The program will load all the anatomicals
for the subject from your results folder. (If you have not yet successfully
completed a batch job, then MATLAB anatomicals have to be created before
tal_define can be run.) The tal_define program will prompt you with instructions
in the top figure bar or in pop up windows.
-
Choose the orientation: coronal, axial or autism
-
Set the brightness and contrast with the slide bars at the bottom of the
figure.
-
Place a midline direction parallel to the midline by clicking once then
dragging the line to where you think it should go then clicking again and
pressing return. This determines the angle of rotation not the actual midline
of each image.
-
Define the brain landmarks
-
Define the anterior commisure (AC) by clicking the crosshair just above
the AC and in the midline. Both vertical and horizontal values are taken
at this point. (Using a Talairach atlas at this point might be helpful)
-
Define the posterior commisure (PC) by clicking the crosshair just below
the PC. The horizontal value does not matter at this point - it will be
automatically placed directly below the AC.
-
Define the Upper Edge (for coronal slices the most superior part of the
brain, for axial slices the most anterior part of the brain)
-
Define the Lower Edge (for coronal slices the most inferior part of the
brain, for axial slices the most posterior part of the brain)
-
Define Left and Right Edges (the lateral sides of the brain)
-
Define Interslice Shift (This is used if the brain was slightly tilted
inside the magnet)
-
Horizontal: if the midline is centered in one slice, but not in the others
-
Click in the midline of the properly centered slice
-
Click in the midline of the improperly centered slice
-
The red crosshair will be where the midline used to be and the blue crosshair
will be the new midline for each slice
-
Vertical: if the AC and PC are correct in one slice, but not the others
(this is very difficult to determine since the AC and PC are only easy
to distinguish on a few slices)
-
Click on the AC or PC of the properly positioned slice
-
Click on the AC or PC of the improperly positioned slice
-
The red crosshair will be where the AC or PC used to be and the blue crosshair
will be the new AC or PC for each slice
-
When prompted to view the tal_define text file click yes. You will be adding
some numbers from the following program (zScale) to this text file. An
example talairach file is given at the end of this manual.
-
To define brain landmarks in the z-direction we use a program called zScale.
-
To run the program type these three commands in MATLAB:
-
>> startup_anders5
-
>> zScale7Lx (This will run the current version of zScale for the Lx format.
If you want to run zScale for a previous file format just type zScale7)
-
The program will prompt you for the setup_file directory (full path of
your setups_fmri directory), the study name, and the directory containing
the sagittal images. Then a single sagittal image will appear with which
you are to change the brightness (level) and contrast (width). Move the
sliding bars, then press return in the MATLAB window. Continue until you
are satisfied, then press `a' to accept and then return in the MATLAB window.
The program will now load all the sagittal images.
-
Defining the brain landmarks:
-
Define the internal anterior landmark (AC) by clicking the crosshair so
the AC falls in the lower left quadrant of the crosshair
-
Define the internal posterior landmark (PC) by clicking the crosshair so
the PC falls in the upper right quadrant of the crosshair
-
Define the superior landmark (for coronal slice locations choose the most
anterior part of the sagittal brain image; for axial slice locations choose
the most superior part of the sagittal brain image)
-
Define the inferior landmark (for coronal slice locations choose the most
posterior part of the sagittal brain image; for axial slice locations choose
the most inferior part of the sagittal brain image)
-
The program will finish and produce four numbers in the MATLAB window.
You need to transfer these numbers as well as the number of slices to the
tal_define text file and then save it.
-
Check individual subject Talairach transformation by using TalTest3D
-
>> TalTest3D(`[study number with tag]')
-
>> TalTest3D(`12345tag')
-
Creating group composite contrasts
-
Create a contrast program similar to the example at the end of this manual
or copy a template from /boreas1/fmri_data/templates/contrast_programs/.
It should include the following information:
-
save_directory- where your result t-maps will be saved
-
Ex: save_directory = '/boreas1/fmri_data/';
-
OnList - list of subjects to be included in the composite contrast
-
Ex: OnList = [`12345tag'; `67890tag';];
-
OffList - second list of subjects if (for example) you want to compare
controls to patients. If only one list of subjects is needed then set OffList
= [ ];
-
stat_nr - statistic to be used for the composite contrast
-
stat_nr = 726;
-
pair_list - tasks to be used for the composite contrast
-
PairListOn = [12 34]; - tasks associated with the OnList
-
PairListOff = [12 34]; - tasks associated with the OffList
-
Contrasts - list of binary contrasts in an array format
-
ContrastOn - contrasts associated with the OnList
-
ContrastOff - contrasts associated with the OffList
-
For one list of subjects, two tasks:
-
ContrastOn = [1 0; 0 1; 1 -1;];
-
ContrastOff = [ ];
-
In this case the contrast numbers are separated by semicolons and would
be
-
Contrast 1 - a composite of all subjects for task 12
-
Contrast 2 - a composite of all subjects for task 34
-
Contrast 3 - a contrast (difference) between task 12 and 34 for all subjects
-
For two lists of subjects, two tasks:
-
ContrastOn = [1 0; 0 1; 0 0; 0 0; 1 0; 0 1; 1 -1;];
-
ContrastOff = [0 0; 0 0; 1 0; 0 1; -1 0; 0 -1; -1 1;];
-
In this case the contrast numbers are separated by semicolons and would
be
-
Contrast 1 - a composite of subjects in the OnList for task 12
-
Contrast 2 - a composite of subjects in the OnList for task 34
-
Contrast 3 - a composite of subjects in the OffList for task 12
-
Contrast 4 - a composite of subjects in the OffList for task 34
-
Contrast 5 - a contrast (difference) between the subjects in the OnList
vs. the subjects in the OffList for task 12
-
Contrast 6 - a contrast (difference) between the subjects in the OnList
vs. the subjects in the OffList for task 34
-
Contrast 7 - an interaction of group by task
-
comp_name - name for composite contrast maps
-
Ex: comp_name = `Contrast';
-
Randomize - number of randomizations the program will generate
-
Ex: randomize = 500;
-
if you do not have enough subjects for the number of randomizations you
choose, the program will automatically lower the number of randomizations
to the maximum number possible
-
if you want the program to run faster and do not want randomization at
all then set randomize = [];
-
To create anatomical composites include the following command in your contrast
program:
-
TalComposeAnat3D(comp_name,OnList) or
-
TalComposeAnat3D(comp_name,[OnList; OffList])
-
Viewing output t-maps in MATLAB
-
Usage for viewing t-maps for individual subjects
-
ViewRes(`[studyname]', [task numbers],
[threshold], [cluster number], [list of slices],
[motion correction label and statistic number], [option])
-
Ex: ViewRes(`12345tag', [12], 1.5, -3, [1:10], 726)
-
task numbers: those tasks you created results for using the batch job
-
threshold: can be a t-value, p-value, or correlation value. Each pixel
which have the current statistics value bigger than the threshold will
be displayed in hot (red or yellow) color, pixels below negative threshold
will be displayed in cold (blue or violet) color.
-
cluster number: The spatial size of activations are is usually larger than
one pixel. In other words the spatial correlation of activation map is
much larger than the spatial correlation of noise. This can be used to
increase power of our statistical analysis by accepting as real activations
only pixels that belong to the larger activated area.
-
negative number: cluster filter: For each pixel the size of cluster
that it belongs to decides whether it is treated as activated. Only pixels
belonging to clusters greater than -cluster_number are presented as activated.
Unfortunately this filter cannot be applied if the threshold is too low
(i.e. if substantial part of the whole image is above threshold).The advantage
of this filter is that it does not take out pixels that belong to extremities
of large clusters. It also makes clearer images because it does not leave
small cluster or isolated pixels.
-
positive number: neighborhood filter: For each activated pixel this
filter counts the number if activated neighbors (wall neighbor counts as
2, corner neighbor as 1). The pixel is presented as activated only if the
sum of neighbors is larger or equal cluster_number. This filter can still
leave isolated pixels (when pixel had many neighbors, but those pixels
did not have enough). Basically it strips the outside pixels from each
activated cluster. After applying this filter even a single surviving pixel
can represent a larger activation.
-
list of slices: only those slices you wish to view
-
motion correction label and statistic number: usually the motion correction
label is 7 and the most common statistic is 26 so the whole thing would
be 726.
-
option - a list of options can be generated by typing help ViewRes
in the MATLAB window
-
If you have an error that says the program cannot find your images, try
typing the following two commands:
-
>> clear all
-
>> fmri_initialization
-
Usage for viewing t-maps for a list of subjects:
-
Set a variable equal to the list of subjects you would like to view
-
>> List = ['12345tag'; '67890tag'; '56434tag'; '43215tag';];
-
Use the ViewRes command inserting this variable name instead of the individual
study number
-
>> ViewRes(List, [12], 1.5, -3, [1:10], 726)
-
Usage for viewing t-maps from contrasts
-
The ViewRes command is the same as above except:
-
the number of the contrast (as specified in the contrast program) is included
in place of the [task numbers]
-
the t-value can be replaced with a p-value, depending on the type of map
used
-
the slices will now be in Talairach space - 12 slices for axial studies
and 19 slices for coronal slices.
-
the option value can be used to view the different contrasts variables
discussed below
-
average t-value across all subjects
-
option = '0'
-
threshold parameter takes t-value
-
Randomization
-
option = '1' (default value if no number is specified for contrast option)
-
threshold parameter takes (1-p-value) for positive p-values and (p-value-1)
for negative p-values
-
If randomization is set to an empty string in ContrastTool, then this comparison
will become the same as `3'
-
'T-statistic compared to zero
-
option = '2'
-
threshold parameter takes t-value
-
To determine the p-value from a t-value: (1-tcdf(threshold,n-1))*2
-
'T-statistic compared to zero
-
option = '3'
-
threshold parameter takes (1-p-value) for positive p-values and (p-value-1)
for negative p-values
-
Ex: >> ViewRes(`comp_program', [1], 1.5, -3, [1:12], 726, '0')
-
Setting the maximum and minium t or p values for all tasks and slices in
a ViewRes image
-
>> global tmax_replacement tmin_replacement
-
>> tmax_replacement = [value]
-
>> tmin_replacement = [-value]
-
Rerun your ViewRes command
-
Setting pictures so they appear in their appropriate dimensions
-
>> path(`/boreas0/gatenb/matlab/',path)
-
>> setallims
-
Viewing individual subjects in 3D Talairach space
-
Usage:
-
ViewResTal(setup_name1,pair_nr1,t_cutoff1,cluster_number1,stat_nr1,slice_list)
-
Ex: ViewResTal(`12345tag',12,1.5,-3,726,[2:10])
-
Getting Talairach Coordinates from ViewRes images
-
Usage:
-
ViewResCoord(slice number,'orientation of slices')
-
Ex: ViewResCoord(4,'axial')
-
The program will give you a crosshair which you can click on the ViewRes
image in the slice you chose. When finished choosing points of interest
press return and then look back at the MATLAB command window. It will list
your selections with Talairach coordinates.
-
Creating TIFF images from ViewRes images
-
The program ViewResMakeTiff will create TIFF images analogous to those
obtained by ViewRes with the same parameters.
-
Usage:
-
ViewResMakeTiff(`[studyname]', [task numbers], [threshold], [cluster number],
[list of slices], [motion correction label and statistic number], [option])
-
option - all ViewRes options are valid with ViewResMakeTiff as well as
two additional options
-
F - creates TIFF image containing all images in one big file
-
no F - creates individual TIFF images for each slice and task
-
w - creates TIFF image with black and white colormap
-
Ex: ViewResMakeTiff(`12345tag', [12], 1.5, -3, [1:10], 726)
-
Printing t-maps
-
On the HP Laser jet black-and-white printer
-
>> print_image('orientation')
-
orientations: tall, landscape, portrait
-
On the HP LaserJet color printer
-
>> orient orientation
-
>> print_color
-
Running Statistical Analyses
-
The "single subject" approach: tracing regions of interest on individual
subjects using ADOBE Photoshop
-
Make tiff files of all the anatomical images for a given study
-
In MATLAB, type >> MakeTiffFolder('[study number with tag')
-
This will create a folder on /oursun3/images that contains all the
anatomical images for that study
-
Transfer the anatomical tiff files to a Macintosh using the program Fetch
-
Open Adobe PhotoShop, and open the first image that needs to be traced
-
Load the MATLAB colortable called colortab
-
Trace your regions onto the slice
-
Save the individual slice as roi[study number and tag]_[slice number].tiff
-
Ex: roi12345tag_1.tiff
-
Repeat steps 1-6 for each slice for every subject
-
Transfer the roi tiff files back to a UNIX machine with Fetch
-
The "group composite" approach: tracing regions of interest on group composite
anatomicals using ADOBE Photoshop
-
Make tiff files of all the compostie anatomical images
-
In MATLAB, type >> MakeTiffFolder('[composite_name')
-
This will create a folder on /oursun3/images that contains all the
anatomical images for that study
-
Transfer the anatomical tiff files to a Macintosh using the program Fetch
-
Open Adobe PhotoShop, and open the first slice that needs to be traced
-
Load the MATLAB colortable called colortab
-
Trace your regions onto the slice
-
Save the individual slice as roi[study number and tag]_[slice number].tiff
-
Ex: roi12345tag_1.tiff
-
Repeat steps 1-6 for each slice
-
Transfer the roi tiff files back to a UNIX machine with Fetch
-
The "group composite" approach: defining regions of interest using Talairach
boxes:
-
Use the program ROI3Ddef to define Talairach boxes of brain tissue
for each region
-
DoRegions program - creates individual ASCII files for each task, threshold,
and measure of activation. Within each ASCII file are the calculated measure
of activation for individual subjects. An example ASCII file is given at
the end of this manual and a template can be copied from /boreas1/fmri_data/templates/do_region_programs/.
-
Create a do-regions program which includes the following information
-
save_directory: directory where result t-maps are located
-
setup_list: list of subjects
-
make_str: a string of letters denoting which measures of activation to
calculate
-
Ex: make_str = `nps';
-
Measures of activation available:
-
n - number of active pixels (defined as pixels above certain threshold
and satisfying certain cluster filter)
-
p - mean value of statistics for the whole region - mainly to use with
percent difference
-
s - sum of intensities of active voxels (intensity is defined by variable
main_stat while active status by tcut_stat)
-
x,y,z - coordinates of the center of intensity for activated pixels
-
r - s/n
-
R - dispersion of intensity for activated pixels (mean distance from the
center of mass)
-
q - n normalized by the region size
-
Q - n normalized by the region size and total number of activation's in
the whole brain
-
1:6 - a variation of Q using either n or s and varying normalization parameters.
-
Q1 - n normalized by total number of activations in the whole brain
-
Q2 - s normalized by region size and total number of activations in the
whole brain
-
Q3 - s normalized by region size and total number of activations in the
whole brain
-
Q4 - s normalized by region size
-
Q5 - n normalized by region size and total number of activations in the
whole brain where region size is replaced by number of voxels in the region
that actually carry signal (i.e. only those voxels which are not equal
to zero)
-
Q6 - s normalized by region size and total number of activations in the
whole brain where region size is replaced by number of voxels in the region
that actually carry signal (i.e. only those voxels which are not equal
to zero)
-
pair_list: list of tasks
-
main_stat: statistic number to be used in averaging
-
tcut_stat: statistic number to be used to define active points
-
slice_nr or slice_list: number of slices or a list of desired slices
-
ROIeach_setup: choose one of the following values to define how ROI's are
defined
-
0: reads ROI file once for all subjects using the ROIdefinition program
-
1: reads ROI files separately for each subject using the ROIdefinition
program
-
ROIdefinition : choose one of the following programs defining the regions
of interest
-
ROI3Dtal - if you define your regions with Talairach boxes once for all
studies
-
ROIdefADOBE - if you define your regions with ADOBE Photoshop once for
all studies
-
ROIdef ADOBEtal - if you define your regions with ADOBE Photoshop individually
for each subject
-
ROIfile_name or ROIfileName
-
ROIfile_name: Talairach box filename created with ROI3Ddef
-
ROIfileName: core name for ROIdefADOBEtal tiff files given in the following
format
-
[ROIfileName]_sl [slice_number] [file_name_extention].tiff
-
Ex: Birdz_experts_1_sl1.tiff or Ex: Birdz_experts_1_sl1extend.tiff
-
Nothing needed for ROIdefADOBE tiff files - the following filename is assumed
-
roi_ [study_number] _ [slice_number] [file_name_extention] .tif
-
Ex: roi_12345_1.tif or Ex: roi_12345_1extend.tif
-
Extra information needed ONLY for ADOBE Photoshop DoRegions programs
-
file_name_extension: additional core name for ADOBE Photoshop tiff files
-
ROIdirName: directory name where ROIdefADOBEtal tiff files are stored
-
ROIval_list: color number values from ADOBE Photoshop colormap
-
ROIlist: ROI names in the same order as the above color values
-
make_display: display ADOBE ROI's interactively to the screen
-
NoOutlines - defined as 1 when green outlines for talairach slices should
not be used
-
do_talairach: choose one of the following values for the number of planes
of Talairach transformation
-
0: no Talairach transformation
-
1: in plane Talairach transformation
-
3: 3D Talairach transformation
-
orientation: orientation of slices
-
cluster_number: size of cluster filter to be applied after thresholding
-
print_dir: directory to print the result ASCII files
-
print_name: core name of result ASCII files
-
t_cut: threshold for activation
-
Advice for ROI analysis based on the following paper
-
Constable RT, Skudlarski P, Mencl E, et al. Quantifying and comparing region-of-interest
activation patterns in functional brain MR imaging: Methodology considerations
MAGN RESON IMAGING 16: (3) 289-300 APR 1998
-
for maximum power ROI should match the size of activated region
-
none of the above measures can be used to compare activation between ROIs
of various sizes
-
s - measure used with very low threshold (even as low as 0) is most powerful
-
ROI analysis is reliable for comparing the same ROI between various tasks
and subject groups, it is much more prone to false activations in comparisons
between different ROIs, even of similar size.
-
Using Optical Disks and Burning CDRs
-
Optical drives are only located on wallace and iguana
-
To format an optical disk: % opcom format_2.3bigopt (you must format
each side separately)
-
To mount on optical disk: % opcom 2.3mbigopt
-
To unmount an optical disk: % opcom ubigopt (Note: you cannot unmount
the disk if you are in the /usr/bigopt directory)
-
While your optical disk is mounted it is located in the directory /usr/bigopt:
-
Ex: cp /boreas1/fmri_data /usr/bigopt
-
CDR burning is available on shaun and feathers. Read the file CDR-howto
in /boreas0/gatenb/adm for more detailed information.
-
Organize your data - place the data to be archived in a directory all their
own. At this time the CD can be written to only once, so the optimal use
of the CDR is to place no more than 650 MB of data into this directory
-
Use the du command on the machine your directory resides to determine directory
sizes
-
Ex: du -sk /gromit1/chris/taste/*
-
The first column is the size in kilobytes
-
Create a subdirectory called burn: % mkdir /gromit1/chris/taste/burn
-
Move your directories to archive to the new burn directory
-
Place a blank CDR into the burner (the uppermost slot on feathers or shaun)
-
On feathers or shaun type the following command:
-
sudo /usr/local/CDR/scripts/burn_cd /gromit1/chris/taste/burn
-
20 minutes or so later the CD will pop out, freshly burned, and ready for
reading
-
Move your directories back from the burn directory to your working directory
-
If you make a error burning a cd you can reset the cd burner
- sudo /usr/local/CDR/scripts/reset_cd
-
Reading a CD
-
Insert the CD in any of the CDROM players
-
To mount the CD: % mount /mnt/cdrom
-
To unmount the CD: % umount /mnt/cdrom (Note: you cannot unmount the CD
if you are in the /mnt/cdrom directory)
-
While your CD is mounted it is located in the directory /mnt/cdrom