fMRI Primer

10.1 Optimal Directory Structure

Section IV: Housekeeping 101: directory structure and file naming

Directory Structure:
THE DIRECTORY STRUCTURE OF EACH INDIVIDUAL SUBJECT MUST BE IDENTICAL, WITH ALL FILES HAVING IDENTICAL NAMES. That is, if subject 101 has a file called emotionalstroop.feat, then subject 102 should have the same file name exactly – the files should NOT be distinguished by subject number (eg, should NOT be 101emotionalstroop.feat and 102emotionalstroop.feat). The only place you EVER want to distinguish subjects is at the level of their master folder.

The same idea applies to directory structure.
Thus in the figure below, notice that each STUDY has two subfolders – models, group – and then n number of subject folders. Within each subject folder, there will ALWAYS and ONLY be four subfolder types: highres, models, scan folders (eg scan1, scan2, scan3) and group, which will be explained below. Importantly, each subfolder has an identical name within each subject.  Finally, each scan folder has either subfolders or simply files that are named by run (eg run1, run2, rune, etc.)

subject  (eg s101, s102, s103)
scan (eg s1, s2, s3)

Four key housekeeping concepts should be kept in mind:
1.    avoid capital letters and spaces
2.    Keep all names as short as possible. EG, call scan1 s1.
3.    Avoid proliferation of folders. There will likely come a time when you have so many files in a given directory, most of which are old data-analyses that are irrelevant for your current purposes, that you have an impulse to create a new directory – eg, from s101 to s101B, or something like that. RESIST THIS IMPULSE!!! Instead, a good solution is to create a folder called ‘oldrunsB4june2006’ or something descriptive to store everything you no longer need, leaving the folder essentially empty, upon visual inspection, to make finding current files easy.
4.    You WILL forget, eventually, what a given set of prior analyses was doing. It is prudent to create small text files within folders such as ‘oldrunsB4june2006’ that explain, to your future self, what these analyses were all about.
It is important to rigorously name files during data analysis, as they proliferate rapidly.

Item    Example    Explanation
.fsf    +r4ANANANAN2EV3C20060124A.fsf    files are program files that you can ‘load’ in the fsl FEAT GUI; you should always check that these do what you think they do.  PLEASE NOTE that you can discard any other extension attached to the same master name. EG, keep peter.fsf but discard peter.con, peter.gif, peter.gif as  well as .grp, in
mat., .ppm
no extension files    x201LMHhappyratings    You will also notice that there are a large number of files that do NOT have an extension.  These are invariably three-column text files that you have used to specify regressors in the .fsf programs mentioned above. For example, a LMHhappyratings thing rates a person’s happiness scores.
+         this is an artifact of the saving process. When you save a program it saves not only the .fsf, which is all you need, but the .con and the .grp etc etc.   To eliminate these, you resave the .fsf with a + in front of it and then throw out everything else. eg mv gols +gols [enter] rm gols [enter].   It does NOT mean that it is a group run. That’s what g means.
x        the symbol that denotes a single subject, and
g        means this is a group analysis. This is in contrast to the absence of a g, which means it is an individual analysis eg “x”
ws          standing for ‘within subject’ it is when you do a group analysis within a subject, eg run3 compared to run1 in a single person
wsgFE         — means within subjects group fixed effects test. Obviously within subjects should always be fixed, just liked between subjects is mixed, but this helps hammer home that you checked fixed effects on the stats tab

gOLS        which gives you a quick and dirty ordinary least squares test of the data

gFLAME         is just the full monty version of a run, takes hours and hours
xGEN         the GEN stands for ‘generic’ and is meant to be a TEMPLATE that can be adapted to a specific subject by opening, entering the correct data, and then saving as x@201 etc
x_____    xgoodbyememories     if what follows the x is NEITHER a number, as in 201, or a GEN, then what you have is a 3-column regressor that applies equally to all subjects, being ‘objective’ rather than ‘subjective.’  Example: xgoodbyememories refers just to the period in which the person was thinking of their pet dying.
syntax primer
+gr25EV7C20060129.fsf     means it is a group (the + and the g mean the same thing) analysis of run 2 (r2) using 5 EVs (must load the .fsf to check which particular EVs they are) 7 contrasts (again, must view the .fsf to be sure what they are) and finally the date 2006, january, 29th.
+r4NANANANA2EV3C20060124A.fsf     okay, this is an analysis of all the run 4’s (r4) that had the neutral-affect order; it contrasts with the ANAN order that is the other option. Again this is dones with 2EVs and 3 contrasts.  Then comes the date, and the A means you probably had two different 2EV3C versions or anticipated them, so named one A

UNIX  Commands

Command    Function
tab    fills in everything that is unique after you’ve started. EG, you have a file called supercalifragilistic – type su [tab] and it will just fill in the rest of the name
Up arrow    fills in the line you typed one earlier; keep hitting to keep seeing your previous entries. You can then edit these. A real time saver.
Right click and drag    Highlights text
Middle click    Inserts highlighted text. Very convenient
rm    Removes a file; cannot remove a directory
rm –r    To remove a file
mkdir    make a new directory
mv X Y    renames X as Y
mv X ../Y    moves X up a level to directory Y
cd ../    changes directory by going up a level
> ls -d peter?/freed*    You are in a folder named peter.  Inside there are three directories, peter1 peter2 peter3.  Each is supposed to have two programs in it called freed.fsf and freed.feat.  How can you easily make sure they are there?

Here the -d means ‘all the directories below this one’, the ? means ‘there is an alphanumberic number here, I don’t care what it is’ and the * means ‘anything of any length can be written here eg .fsf .feat georgebushwashere etc.
This should yield

peter1/freed.fsf peter1/freed.feat peter2/freed.fsf peter2/freed.feat peter3/freed.fsf peter3/freed.feat

FSL &    opens FSL but also keeps the terminal running; without the & the terminal is useless until you close FSL
Pico (filename)    Creates a text viewing environment within a terminal. Of course you could open text editor in mac or in sun also. Instructions how to close it are given on the bottom. Remember that ^ means ‘hit the control key’
Netscape &    Opens netscape – good for viewing feat reports to make sure the thing ran right
To see what date a file was run    Open netscape, go to file, and search your directory, it will tell you dates.

top i    to see what processes are running on the server
q    quits top i

Killing a job:

Unix terminal:
1.    top i
2.    kill (enter #)
3.    q to quit


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: