What mkmgh Does

This information is very old...most machines where this stuff were installed are gone...still, it is a lot of information, so I'd hate to just delete it when it might be useful to someone, somewhere.  Dianne Patterson 10/25/2006

The mkmgh script (available in Local Resources) creates all of the directory structure and files that the mgh (and freesurfer) expect. Below is a usage message, sample command and list of what mkmgh creates. Make sure you run mkmgh from inside your parent subject directory (e.g., /data/video). See the main mgh page for more information.


Purpose: Utility to setup MGH directories
Run this script from inside your parent subject directory.

Usage: mkmgh args subjectdirs...

Args:
-nr num =number of runs
-ns num =number of slices
-ntr num =number of TRs
-tr num =length of TRs
-z num =slice thickness
-p path =path to the talairach directory (optional)
-v =set verbose mode (optional)

Example: mkmgh -nr 3 -ns 17 -ntr 250 -tr 2.5 -z 5 -v e22000 e23456


  • sessidfile: In your parent subject directory (e.g., /data/video), the script creates a file called "sessidfile". The sessidfile includes the name of each primary subject directory, e.g.,
    e22000
    e23456

    The mgh programs use the sessidfile to determine what data they should operate on, so you need only list the directories you want preprocessed and analyzed, not necessarily all the directories you have in the parent area.

  • Talairach Link: The mkmgh script creates a link from your parent subject directory (e.g., /data/video) to the main freesurfer talairach directory. You only have to set up a link once when you set up your parent subject directory. cd to your parent subjects directory and type the following on charlie (substitute the correct path if you are on a different machine):
    ->ln -s /data/freesurfer_alpha/subjects/talairach talairach
    -A link "talairach" will appear in your parent subject directory.


  • Subject directories: Under the parent subject directory, you will have 2 main directories for each subject:
    -a primary one for raw and functional files (e.g., /data/video/e25996) and
    -a secondary one for anatomical (COR) files, (e.g., /data/video/e25996_anat)
    . This contains a huge number of subdirectories that freesurfer expects. We create those directories (following the mksubjdirs script distributed with the mgh tools) in case users might later use to manipulate their brains in freesurfer.

  • subjectname file: In the primary subject directory, you need a file called "subjectname" that contains one line naming the directory where the COR files will be stored. e.g., In /data/video/e25996 create the file subjectname which contains one line, e.g., e25996_anat
    You will need one such subjectname file for each primary subject directory. Modify the line in the subjectname file appropriately.

  • bold directory: In addition to the subjectname file, you should have a bold directory in each primary subject directory (e.g., /data/video/e25996/bold). You are free to have other directories as well.

  • seq.info file: Create seq.info in each bold directory (mkmgh will set ntrs, TR and nslcs based on the input you provide at the command line) e.g.:
    sequencename unknown
    nrows 64
    ncols 64
    nslcs 25
    rowpixelsize 3.44
    colpixelsize 3.44
    slcpixelsize 4.5
    ntrs 349
    TR 2.5

  • register.dat file also in the bold directory with appropriate header info and unity matrix

(Slice thickness, 4.5 in the example below, is set to the value you provide mkmgh at the command line):
e26069_anat
3.44
4.5
0.000000
1.000000 0.000000 0.000000 0.000000
0.000000 1.000000 0.000000 0.000000
0.000000 0.000000 1.000000 0.000000
0.000000 0.000000 0.000000 1.000000

  • Run directories: In each bold directory, create numbered directories for each run (e.g., 001, 002, 003 etc.) for that subject (mkmgh will create as many of these as you tell it to (nr, number of runs).

  • f.bhdr file: Within each run directory (e.g., 001, 002) of the bold directory you need to create f.bhdr file, which should look like this
    (mkmgh will set nslices, and slice_thick to the values you provide at the command line):
    cols: 64
    rows: 64
    nslices: 25
    slice_thick: 4.5
    top_left_r: 31.5
    top_left_a: -12
    top_left_s: 31.5
    top_right_r: 31.5
    top_right_a: -12
    top_right_s: -32.5
    bottom_right_r: 31.5
    bottom_right_a: 13
    bottom_right_s: -32.5
    normal_r: -1
    normal_a: 0
    normal_s: 0
    image_te: 0
    image_tr: 0
    image_ti: 0