FSLView is a simple viewer for 3D and 4D data. It does not perform any processing or analysis of images - that is done by separate tools. FSLView has the following features:
ortho view mode; if you
add image filenames on the command line (after typing
fslview) it will load them all automatically; however,
all images must have the same spatial matrix dimensions (numbers of
voxels in x, y and z) as each other. They don't have to have the same
number of timepoints.
Open a command terminal and type:
cd ~/fsl_course_data/intro
ls
The ls command gives you a list of the files in this
directory.
Start FSLView by typing
fslview &
The & means that the program you asked for
(fslview) runs in the background in the terminal (or shell), and you
can keep typing other commands while it is running. If you had not
done that then you would not be able to do anything else in the terminal
until you killed fslview.
Other useful Unix info:
control-c
jobs
fg if it is the last
job that was started.
bg (or add the & after the command
when you first run it). Note that control-z on its own will give you
the terminal prompt back but the job will be sleeping, not running in
the background.In FSLView, load in the image example_func.nii.gz, by pressing
File -> Open and selecting the image.
Hold the mouse button down in one of the view panels and move it around - see how various things update as you do so:

Now click several times on the small upwards arrow (on some computers the arrows are replaced with a small "+" and "-") that is part of the scale control [1] (currently showing "100%"). This is one way of controlling the zoom. If you click on the icon of a hand [3] you can drag a view around. You can reset the view settings by pressing on the button with the arrow on top of the magnifying glass [6]. You can also set the field-of-view of a panel (i.e., zoom in) by clicking on the button with the magnifying glass [5], and then click-and-dragging the mouse in a view panel. (If you have a 3-button mouse, you can also access "drag" and "field-of-view" modes by using middle and right mouse buttons, respectively.)
Return to "normal view mode" (as opposed to "move" or "zoom" mode) by
clicking on the button with the small cross [2].
You can control the brightness and contrast either by using the wheels/sliders [3] near the "brightness/contrast" button [2] (this button allows you to reset the brightness and contrast to their initial settings, although for some images these may be poor because some images specify this range in their header information, and can do it badly). You can also control the intensity display range explicitly by typing numbers into the Min and Max boxes [1]. Have a play with these controls.
Open a lightbox view using Tools ->
Lightbox. If you drag the mouse around in the viewer you can
see that the cursor position is linked in the two views of the
data. This is particularly useful when you have several images loaded
in at the same time (you can view each in a separate view window and
move around all of them simultaneously).
You can "unlink" the
cursor position between the two views (it is linked by default). Go
into one of the views, e.g., the lightbox view, and press the "tools"
icon
that enables various miscellaneous settings to be changed. Turn
off Globally -> Link -> Location and
press Ok. You will now find that this view (the
lightbox view) is no longer linked to the "Global" cursor position,
and you can move the cursor independently (in this view) from where
it is in the other views.
If you increase the % zoom in the lightbox view sufficiently, you
will get a scrollbar to let you control which slices you are
viewing. Kill the lightbox view now (click on the small red circle or
X at the very top of the view) and expand the ortho view back to full
size.

Now load in a second image (thresh_zstat1) using
File -> Add. This image (thresh_zstat1)
is a thresholded FMRI activation image. In the bottom-right panel is a list
of loaded images - the layer toolbar. Images can be turned on and off
by double-clicking in that list [7] (or by highlighting the
image in the list [8]and then clicking on the checkbox by the
small eye icon [1] at the bottom). Once highlighted in the
image list, an image's transparency can be changed with the slider
[3] (at the bottom of the box); reduce the "solidness" of the
stats overlay image.
Also, when an image in the image list is highlighted:
i button [6] and change the image's
colour display scheme (LUT - look-up-table), and see/change some other
basic image information.
Min
display intensity for any image other than the lowest in the list,
then any voxels with intensities lower than the Min will
be made invisible, so that you can see through to the image(s) lower
in the list. Try changing the Min to 4,
for thresh_zstat1, to see this effect.

Now kill the ortho viewer; all loaded images are deleted from
FSLView once the last view is closed. Now load in
filtered_func_data, a 4D FMRI time series. Watch this as
a movie by pressing the film-strip button [1] that becomes
clickable when a 4D file is highlighted in the overlay list. You will
see the time-counter ("Volume") scrolling through the different
time-point values. Note that whilst the movie is running you can still
change the cursor position. Stop the movie by pressing the movie
button again.
Press the switch layout button [3] several times to see how you can select different layouts for the ortho viewer.
Open a single-slice view with Tools -> Single to see
how you can get a larger view of a single slice. Now the switch
layout button [3] lets you select which orientation you want
the single slice view to be in. Turn on the Slice roll
mode [2] to auto-scroll through all slices. Kill the
single-slice view.

Re-load the thresh_zstat1 stats overlay image back in.
Open a timeseries graph view with Tools -> Timeseries
(you will need to have the 4D dataset highlighted in the image list
for this option to be active). Move around with the mouse button held
down until you are on a "highly activated" voxel. Press the +
button [1] in the timeseries view and that voxel's timeseries
gets saved in the display. You can add more timeseries by moving to
new voxels and pressing + again.
If you have used "+" to add several timeseries to the display they
may all have quite different mean values, making comparison difficult
- press the "-μ" button [3] to demean all viewed
timeseries. You can highlight individual timeseries by
clicking on them (a highlighted timeseries changes colour). Once you have turned on
demeaning you can also choose to turn on the "%" button [4],
which shows the y-axis as a % of the mean level (i.e. in this case
you're now seeing the BOLD % signal change values).

Highlight filtered_func_data and press Tools
-> Image histogram to view a basic histogram. A histogram
plots the distribution of intensities in the image; image intensity is
on the x axis and the number of voxels with that intensity is on the y
axis. You can click in the histogram to view exact values. To get an
expanded view, click on the button with the magnifying glass
[1] and then click-and-drag in the histogram (click again on
the button [1] to un-expand). Click on the toolbox button
[3] to get more histogram options.
Finally, we'll look at some more advanced FMRI analysis features in
FSLView. Kill FSLView and in the terminal type:
cd ~/fsl_course_data/fmri/ptt/at/at_left.feat
fslview filtered_func_data thresh_zstat1 thresh_zstat2
You are now in an example FMRI analysis FEAT output directory. The
image names on the fslview command line tell FSLView to
load in each of these images, to save you having to load them in by
hand in the GUI. Because FSLView detects that you are in a FEAT
directory it automatically turns on timeseries viewing. You might want
to resize the outer FSLView window (make it wider - for example, on a
Mac by dragging on the bottom-right corner) and then auto-resize the
inner windows with Window -> Tile.
One of the nice features when in FSLView's "FEAT mode" is that you can see a
plot of the fitted timeseries model versus the data. In the
timeseries view change No model to Full model
only (if it isn't already showing this). Now when you click around
in the image you can see not just the data timeseries but also the
fitted model (if this doesn't mean anything to you yet, it will do
after the first FEAT lecture!)
This FEAT output directory already contains versions of some of the
images upsampled to "standard space" - the common image space that
multisubject analyses are carried out in, which allows us to interact
with the FSL atlases. Kill fslview and run: fslview
reg_standard/reg/highres.nii.gz reg_standard/stats/cope1 -l Red-Yellow
-b 100,400
The options tell FSLView what colourmap to use
for the FMRI activation BOLD effect image cope1, and what
intensity display range.
Because these images are in standard space we can turn on the atlas
tools with Tools -> Toolbars -> Atlas Tools. Now as
you click around in the image you can see reporting of the probability
of being in different brain structures. The atlases that are turned on
by default are the Harvard-Oxford cortical and subcortical
atlases. These are formed by averaging careful hand segmentations of
structural images of many separate individuals. Find the thalamus (left
or right); you can see that there is activation here.
Try the other atlases (press the Atlases... button and
turn on other atlases). In particular, the Juelich atlas is very
complementary to the Harvard-Oxford atlases (being derived from
post-mortem histological segmentations), as are the JHU atlases (being
derived from diffusion MRI data). You might want to resize the
different FSLView sub-panels to increase the size of the Atlas reporting
space (in general you do this by dragging around the edges of the
different FSLView sub-panels).
You can turn on summary images of atlases by double-clicking on the
name inside the Atlases... popup window and then pressing
OK; have a play with that.
Finally, bring up the Structures... window, select an
atlas (such as the Juelich atlas), turn on the two tickboxes, and then
click around in the list of structures....for those atlases which are
probabilistic, this shows a single structure at a time, with the full
probability information shown as a gradation of colour.
cd ~/fsl_course_data/intro
Type fslinfo highres and fslinfo
thresh_zstat1 and note their different image matrix dimensions
(dim1-3) and voxel sizes, in mm (pixdim1-3).
Note that some images (highres) are of integer
datatype, while others (thresh_zstat1) are of floating
point datatype. Integer means that the intensity values can only
take on whole numbers - no fractions - raw image data is normally of
this type. Floating point means that intensity values can be
fractional - the result of applying most statistical processing
algorithms to image data results in images of floating point type.
Also try running fslhd on these files. This
provides more detailed information about the images.
Check how many timepoints there are in egfmri
using fslinfo and then run
fslsplit egfmri
to split up the 4D input image into its individual 3D images, or volumes,
(vol0000, vol0001, vol0002, etc.). To list these new files do
ls vol*
(note that the
* is expanded by the terminal to fit any characters in
all possible filenames present, and so can be used in any commands,
not just ls, as we will see below). You'll see that the
counting of the images starts with 0, and that the number of them
should match the number of timepoints in the original 4D image.
As a (rather silly!) example, let us remove the 3rd and 6th images from this sequence and then remerge the remaining ones. Remove the images by doing
rm vol0002* vol0005*
Check that these files have been deleted using looking at the directory contents using ls
Now remerge the remaining 3D images into a new 4D image
with
fslmerge -t newfmri vol*
The
"-t" tells fslmerge to merge the images in
time (you could also do other merges, such as stacking them on top of each other in
space!) After "newfmri" (the name of the output image),
fslmerge expects a list of images to be merged. For all FSL commands the image names
can be used with or without including the filetype extension
(extensions are .hdr .img .nii.gz etc.).
View the resulting image in fslview and check that
there are only 8 volumes in the timeseries. You can also check the
size of the timeseries with fslinfo. Also try
concatenating (merging) in z instead of t and view in fslview; why does
nothing happen when you try to turn on the movie loop?
We will now fix an image that has somehow gotten "wrapped", with the nose sitting behind the back of the head...
fslview wrapped &
You will use fslroi to split this image into two (front
and back parts) and fslmerge to remerge them back
together in the right order. In FSLView, look at an inferior (bottom)
axial slice so that you can work out the y coordinate (in the anterior-posterior direction) where you want to make
the split. Record the y-coordinate (in voxels, not mm).
Now use fslinfo to find out what the image matrix
dimensions are (dim1,2,3). You're now ready to extract the back part
of the head into a temporary file. If your y-coordinate was 76 you would do:
fslroi wrapped back 0 256 76 180 0 128
Now just type fslroi to see the usage. There are
several ways to run fslroi: You can specify just a 3D ROI, as we have
done here - this is the first of the usage possibilities. The second
option is to extract a temporal ROI from a 4D dataset (one or more
full 3D volumes). The final option extracts a 4D ROI from a 4D dataset,
controlling the region to be extracted in space and time. The
program knows which option you want from the number of "arguments"
that you type. Note that if you use the first option (3D ROI) on a 4D
input file, the output will still be 4D, with the number of timepoints
unchanged, and each volume cut down in 3D in the same way, as
specified by the arguments.
Make sure that you understand the exact numbers used in the above
command, that created back; note in particular that the
second number in each pair is the length of the ROI in the
relevant dimension, not the end point - the
<ysize> was 180 (256-76) not 256.
Now work out how to run a similar command to create
"front", from the back part of wrapped.
Finally, use fslmerge to merge front and
back together correctly, and verify with fslview. You
could also do a similar thing with the slight wraparound at the top of
the image.
fslstats is a general tool for calculating various
values/statistics from the image intensities. It is quite flexible
but we will just illustrate some basic uses
here. Type fslstats to see the full list of possible
options. Any combination and order of options is possible.
Run fslstats highres -R -r
The first pair of
numbers (specified by -R) is the absolute range of the
data - i.e., the min and max intensities. The second pair
(-r) is the "robust range" - i.e. the min and max if the
outer tails of the intensity distribution are ignored (this is useful
if the data contains outliers). View the image histogram in FSLView to
see how all these numbers relate to the histogram. Slightly
confusingly, the robust range doesn't seem to be doing the same thing
for the left and right tails. This is because there are lots
of empty voxels in the image (because the data has been
brain-extracted) that are affecting the calculation. Click on the
histogram toolbox button [3] and turn off the ignore
zeros and press OK. Now turn this back on. You can
tell fslstats to ignore the zeros by setting a lower limit to the
intensity values that it considers; run fslstats highres -l
1 -R -r
Now it is clear that the robust range limits make
more sense.
See what the results are like for egepi which is more
like an initial scanner image immediately after reconstruction. Have a
look at the histogram - now there are few voxels with exactly 0
intensity, but there is a large tail of very low background
voxels. Tell the histogram to use log scale (on the
y-axis), in order to more clearly see the shape of the histogram.
Run fslstats highres -m -M
The first number is
the mean intensity of all voxels in image, whilst the second is the
mean of only the non-zero voxels. The first is much lower because of
all the zero background voxels dragging down the mean. The second
number is a more meaningful mean of the actual within-brain
intensities - view the image and click around inside the brain to see
this.
Finally, we will use fslstats to determine an ROI to
use with fslroi. To do this run fslstats
highres -w
which will generate a set of numbers suitable
for fslroi. This ROI is the smallest ROI possible that
fully contains all non-zero voxels. We could now
run fslroi using these numbers, but instead we'll combine
the two commands into one, using the unix trick of putting a command
within ` quote marks (this is the backquote, not the
usual forward quote!). When you put a command within these quote marks
then this part of a larger command will get replaced by the text
output of the command within quotes. We will cut
down highres so that the image
just about contains the brain, and the end slices that only
contain zeros are thrown away. Run the following, and then try to
understand how it works. fslroi highres highres_roi
`fslstats highres -w`
fslmaths is a very general image calculator and can be
used to perform a great variety of manipulations of images. See the
(long) usage by just typing fslmaths. Don't worry about
understanding it all at this point, we will illustrate some basic uses
here, but be aware that it is a very general and powerful tool that is
worth getting to know.
As an example, we will find the difference between two consecutive
timepoint images (derived from running fslsplit
previously on egfmri). Do this by running
fslmaths vol0000 -sub vol0001 voldiff
and view
the output (the final argument in that command). You might need to
adjust the brightness/contrast intensity display range to see anything
(e.g. a display range of -100 to 400). Now calculate this as a percent
difference image by running fslmaths voldiff -div vol0000
-mul 100 voldiffpercent
This means: "take the difference image, divide by the first of the
original images (voxelwise), multiply by 100, and output". View the output, and
run fslstats - see that the robust range is quite small, with most
change showing up as motion effects round the edge of the brain.
You may have noticed that all the values in
voldiffpercent were integers (whole numbers). This is
because by default fslmaths outputs the same datatype as the input,
which in this case was integer. However, we probably don't want that
here, when converting to percent values that are mostly close to
zero. Re-run the above command, this time adding at the end
-odt float
This tells fslmaths to create the output image in
floating point format. View in fslview to confirm that this has
worked.
Make sure that you understand the fslmaths commands above; and
note that in general an "input" can be a number instead of an image
(the "100" could have been an image name instead). This
does not apply to the first input in the command!
Becoming familiar with fslmaths and fslstats can save you a huge amount of time when you want to carry out simple image manipulations quickly. Also, if you want to carry out simple things many times, you can easily put these commands into small scripts (text files that contain the same commands that you might type in the terminal). We cannot emphasise strongly enough how useful it can be to learn these basic command-line programs, and also basic scripting. (Unfortunately you will probably not have time during the course to go through the scripting practical - there's just too much stuff to fit in! - but we do recommend that you have a look at it after the course, at least the first few basic sections.)
Most FSL programs can be run from the command-line without using a
GUI, by typing fully lowercase names (e.g. bet). Most
programs also have a GUI, which can be started via the
fsl mini-GUI (type fsl) or by typing a
capitalised version of the command name (e.g. Bet).
(Note that on Mac, the command line call to the GUI has "_gui"
appended (e.g. Bet_gui), because Macs can't distinguish
between lower-case and upper-case...)
Start the fsl GUI and click on BET, to
see how this all works. Now exit both of these GUIs and start the
Bet GUI directly from the terminal.
Using the Bet GUI, set the input file to structural;
use the right-hand file selector rather than typing this in by
hand. Turn on various optional outputs (brain extracted image, binary
brain mask and skull surface image - see Advanced Options tab) but
leave the other settings as they are. Note that the GUI suggests the
default output name structural_brain.
When done click on Go to run BET and then exit the GUI once it's
done. You will see that when you pressed Go the actual
command carried out was printed in the terminal; many of the FSL GUIs
will do this, in order to help you see what's actually going on. Also
in the terminal you will see Finished appear once BET has
finished running.
Use ls to see what files got created and view the
various outputs. Hint: if you type ls -lrt
then
the listing is sorted according to file creation date, hence it's very
easy to see what the most recently created files in a directory are.
View the brain mask overlaid onto the original image by first
loading the original image into fslview and then adding the mask
image. You may need to change the Min
and Max to 0 and 1 (for the mask image), as this is an example of an image
where the header doesn't contain sensible dispay information. Change
the transparency of the overlay so that you can get a better view of
the success of the brain extraction.
Type bet to get the usage description and make sure
you understand the command that the GUI printed in the terminal when
you pressed OK. Try setting the Fractional
intensity threshold (the -f option on the command
line) to 0.2 and 0.8 in turn to see the effect it has (save to
different output image names and load both into FSLView). This option
controls the threshold that distinguishes brain from non-brain; if you
reduce it from the default value of 0.5 then the brain estimate gets
larger, and vice versa.
Run BET on sub3m0. Note that the cerebellum is
underestimated. We can improve this by changing the gradient threshold
-g (from its default of 0) to 0.5. This option causes the
overall fractional threshold (controlled globally by -f)
to vary linearly with slice number - to get smaller at the bottom and
bigger at the top, or vice versa. Run this and note that we have now
underestimated the top slices! However by combining the gradient
option with the main (-f) option we can get a good
overall result: try -f 0.3 -g 0.2 (or maybe you can
do even better!)
The final example is of a head image with a large amount of neck
present - run BET on bighead to see a problem. Because of
the neck, the initial brain surface is initialised too low in the
image. There is an option on the command line to set the initial
centre by hand; use fslview to get a rough guess (in voxels) of where
the centre of the brain is in the image and see the improvement when
you call bet with the -c option.
In some cases you can get BET to achieve the same improvement automatically by using the -R option; this re-runs BET several times, each starting its brain centre at the centre of the previously-estimated brain. Try the -R option instead of -c.
cd ~/fsl_course_data/intro
Start FSLview and load in the brain-extracted MNI152 2mm standard image: click on
the menu item File->Open Standard, select
MNI152_T1_2mm_brain and click on Open. Next open
the cortico-spinal tract image: File->Add..., select
cst2standard_73_46_26 and click Open.
Select cst2standard_73_46_26 in the Overlay settings panel
(layer toolbar) and click on the (i) button (layer toolbar [6])
to bring up the Overlay Information Dialog. Change Image Type to
Statistic and select the Blue-Lightblue lookup table then click on
Close.
The cst2standard_73_46_26 image shows the course of a tract up from
the spine through the brain-stem to the cortext. Explore the image by
moving the cursor around trying to trace the path of the tract.
Now switch to 3D mode: select the Tools->3D Viewer menu item.
Improve the segmentation of the "pial" (outer-brain) surface by changing the threshold control (1). Edit the value until you get a good representation of the surface Hint: try 5500.
Turn on clipping by checking the Clipping
checkbox (2). Part of the volume should now
be cut away to reveal the structural image's internal detail along with
some blue areas which show the location of the tract.
In 3D mode the bricon control effectively selects the
threshold value for segmentation of the surface of a statistic image,
so select the cst2standard_73_46_26 image and change the low
threshold(3) to 1. You should now be able to
see the tract.
Using the left mouse button rotate the image around. The right and
middle mouse buttons can also be used to scale and translate the
image. Pressing r at any time will rescale and translate the scene
back into the viewport.
Press b. A box will appear which can be modified to
change the extent of the clipping volume. Use the mouse to grab the
control points and resize, translate (middle control) and, in the case
of dragging the sides, rotate the box. Press b again to
turn off the box.
Open the on-line manual (/usr/local/fsl/src/fslview/doc/fslview/index.html) to find out more about the various keyboard controls.
Currently not all FSLview controls behave consistently in 3D mode, e.g., the lookuptables and image types for a given layer can't be modified after the start of a 3D viewer (as a work-around close the current 3D view, make your changes, then start a fresh 3D view).
You can save full-resolution screenshots by pressing the
camera(4) icon. Compose the view you'd like
to record then click on the camera. Type in a name and click
Save.