'); document.write(''); function installJsMath() { jsMath.Process(document); } addInitEvent(installJsMath);

Computational Neuroimaging Laboratory Wiki

Trace: » top » surfrelax » cbi_recon » mralign » computing


|

Meta

Network overview

Disk mounting

Amongst other things, you'll likely need the following:

From a Finder window, click Go | Connect to server… (command-k). Then, with the server address as “larmor.cbi.fas.nyu.edu”, hit “connect” (the staff at CBI need to first set you up with a larmor account). A number of volumes will be listed. Start with CBIV2 or CBIV3. It's likely to one of these that your MR data is uploaded.

Other than that, automatic NFS mounts on your desktop machine should look something like the following (the output of entering “df -k” at the UNIX command line):

 hallum@bird:~ 81> df
 Filesystem                              512-blocks       Used      Avail Capacity  Mounted on
 /dev/disk0s2                             487725344   54007888  433205456    11%    /
 devfs                                          187        187          0   100%    /dev
 fdesc                                            2          2          0   100%    /dev
 <volfs>                                       1024       1024          0   100%    /.vol
 wotan:/i/1.3                              11147724   10957560      78688    99%    /private/var/automount/i/1.3
 erda:/e/1.4/p1                           199189886  123747122   73450866    63%    /private/var/automount/e/1.4/p1
 wotan:/i/5.5                              24670352   21381632    3042018    88%    /private/var/automount/i/5.5
 afp_2QDJHq00062o0000oM0000VU-1.2c00000b 4688199528 3589828936 1098370592    77%    /Volumes/CBIV3
 afp_2QDJHq00062o0000oM0000VU-2.2c00000c 8790523616 7968309568  822214048    91%    /Volumes/CBIV2
 automount -static [6364]                         0          0          0   100%    /automount/static
 automount -nsl [6369]                            0          0          0   100%    /Network/Servers/browse
 erda:/e/1.4/share                        199189886  123747122   73450866    63%    /private/var/automount/e/1.4/share
 wotan:/i/share                             3078746     211482    2744116     7%    /private/var/automount/i/share
 wotan:/i/9.5                              24670352   22576442    1847208    92%    /private/var/automount/i/9.5
 wotan:/i/10.3                             11147724   10606774     429474    96%    /private/var/automount/i/10.3
 erda:/e/1.4/users                        199189886  123747122   73450866    63%    /private/var/automount/e/1.4/users
 wotan:/i/1.5                              11147724    8714372    2321876    79%    /private/var/automount/i/1.5

Where is stuff located?

Scan Sessions Naming

It is NIH requirement to keep the identity of participants in each experiment confidential. To do so name the folder in which each session will be stored as follow:

<first 3 letters of the cbi Subject ID>+<YYYYMMDD>

Example folders are:

for subject ID ESOG2PHM scanned on April 2nd, 2008 use: esog20080402, 
for subject ID HJLF88AM scanned on April 3rd, 2008 use: hjl20080403

Please use only lower case characters because some of the scripts we use to do segmentation and preprocessing are case sensitive. This allows us to maintain short folder names with the same probability of having more than one participant with the same three letters as if we were using participant initials.

This naming convention is required by all new studies started after April 1st, 2008. If you have mostly completed a dataset then it is ok to leave it as is and complete the project using a different convention. But if you have only a partial dataset or are just beginning to collect data for a study, then please adopt this convention and convert (for consistency) the directory names of the existing sessions to this new convention.

Love and CRTs

Be nice to CRT displays. This means ensuring that screen savers are activated, and actually kick in when the screen's not in use (that may mean mglClose()ing in Matlab). See below explanatory note from Mike.

 Date: Mon, 10 Sep 2007 09:34:16 -0400 (EDT)
 From: "msl@cns.nyu.edu" <msl@cns.nyu.edu>
 To: visionpeople
 Subject: LCD problems
 Folks,
   This isn't something I would typically email "visionpeople@cns" about,
 but the news is more appalling than I expected, so I thought I should share it.
   As you know, most of us run our experiments using CRTs as visual displays
 (except in the fMRI suite), and CRTs are becoming more and more scarce. And,
 most of us continue to use CRT's because of strong reason to believe that the
 temporal characteristics of LCD monitors are poor (not to mention the change
 in brightness as a function of viewing angle, etc.). Anyway, I have a copy of
 a poster from ECVP (Elze, Lochmann & Tanner) in which the authors collected
 temporal data on a bunch of LCD monitor models (Dell, Eizo, Siemens, NEC,
 etc.). They measured luminance as a function of time as a patch covering 20%
 of the monitor's width was switched from one gray level to another. They
 found:
   * The backlight itself flickers, often at rates you'd expect (e.g., 100 Hz in
 Europe, so presumably 120 Hz here). This would presumably be intolerable for
 physiological measurements.
   * The response time to change from one gray level to another varies hugely
 between models (not unexpected), but also depends on the pair of levels
 itself. The dependence on the gray level pair (they tested all pairs of
 changes from pixel values 0, 63, 127, 191 and 255 to other levels in that set)
 can be enormous, and response times can be as slow as 70 msec, and often is
 more than one "frame" time.
   I'll hold on to my copy of the poster if anyone wants to see it. The bottom
 line is that if you care about the temporal response of your LCD for an
 experiment, you'll need to measure it carefully for your particular stimuli.
   Caveat emptor,
   m

Matlab

The Heeger Lab is a Matlab-intensive operation – Matlab is used for both the generation and presentation of stimuli (usually via MGL), and the analysis of fMRI data (see mrAlign and mrLoadRet).

startup.m

The file 'startup.m' is a Matlab script (or 'M file') that's automatically executed when Matlab is started. Actually, it's executed if Matlab can find the file; Matlab will look in your current directory when Matlab is executed. Therefore, 'startup.m' is a good place to set up a few things that you'll always need – e.g., Matlab's search path, which is where it looks for scripts/programs, like 'mrLoadRet', that you ask it to execute. (For more information, see 'startup' and 'path' in the Matlab help pages – press open-apple and shift and '/' at the Matlab prompt.)

This is an example 'startup.m' file.

 addpath(genpath('/share/wotan/heegerlab/mgl'));
 addpath(genpath('/share/wotan/heegerlab/mrTools-4.5'));
 addpath(genpath('/share/wotan/heegerlab/heegerTools/filters'));
 addpath(genpath('/share/wotan/heegerlab/matlabPyrTools'));
 disp('Ran your startup.')

Here's an example for getting started with Matlab.

1. Open an xterm. (In a Finder window, click Applications → Utilities → X11. Then hit open-apple and 'N'.)

2. At the command prompt (NB: you're in your home directory), type 'matlab -nodesktop'. If you created a 'startup.m' file in your home directory, you should get the 'Ran your startup' message. The package 'MGL' (for stimulus generation and presentation) is stable if Matlab is run in the 'no desktop' mode. Since you're here, test MGL by typing 'mglTestDots' at the Matlab prompt.

3. Quit Matlab. Re-open Matlab with the command 'matlab'. This is the (graphical) interface with which you may already be familiar, and which you might prefer to use for non-MGL-related things.

Mailing list

There is a Matlab mailing list at CNS – 'matlab@cns.nyu.edu'. It doesn't see much traffic, but might be helpful.

Applications

Backing up your work and your data

Your CNS home directory (e.g., /users/hallum), which is mounted over the network (meaning the physical disk in question isn't on, or under, your desk, but instead down the hall somewhere) is backed up. This backup runs nightly between 3am and 7am. This is the official word from Paul Fan as of 10/31/2007. You should keep your text files and matlab code in your home directory so that it is backed up nightly. But you cannot put fMRI data in your CNS home directory because CNS does not have the capacity to backup large datasets.

Instead, what we typically do is keep a working copy of your data on your desktop machine and mirror it regularly onto Larmor. This can be set up to be done either every night (or once/week) automatically. Add details. In addition, you should make periodic backups onto tape. See the CBI web site for details on how to make tapes (add link). When a project is done and published you should make two tapes (one for you and one for David) of the full data set with all of the analyses.

Backup with rsynch in Xterm

daily backup

rsynch –a (source directory) (destination directory)

adds new files

rsynch –av (source directory) (destination directory)

adds new files and displays a list of files added

weekly backup

rsynch –a  --delete (source directory) (destination directory)

deletes multiple existing or slightly modified versions and keeps only the last version

you can find more informations on the website: http://www.samba.org/rsync/

Mailing lists

The website

Via your browser, it's here: http://www.cns.nyu.edu/heegerlab. The content is served from here: /share/wotan/heegerlab/website/content. To add your own mug, plus a link to your personal website (if you have one), follow these instructions:

1. Edit /share/wotan/heegerlab/website/content/profile.php, updating the information contained in the 'people' array (you should find an entry for yourself, wherein all fields are set to 'null'). Follow the format of an existing entry (note where to use single quotes), e.g.:

 "uhasson" => array ('name' => 'Uri Hasson', 
                                 'photo' => './content/images/people/uhasson.jpg',
                                 'title' => null,
                                 'email' => null,
                                 'website' => null),

2. Add a mugshot of yourself to the directory /share/wotan/heegerlab/website/content/images/people. The convention for naming these files is 'first initial last name dot jpg' (e.g., 'uhasson.jpg'). The image should be a JPEG, with resolution (height by width) of 188 by 145 pixels.

MR Images: Getting started with anatomy

The following Matlab code shows how to average three high-res anatomy scans. It may also serve as an intro to MR anatomy images – their viewing and manipulation in Matlab.

 %%%
 % Load (Nifti) images in Matlab.
 %%%%%%%%%%
 dirAnatomy = '/Volumes/CBIV3/Heegerlab/luke/anatomy';
 [imageAnat1,hdr1]=cbiReadNifti([dirAnatomy '/03+t1mprage/anatomy+03+t1mprage.img'],{[],[],[],[]},'native',1);
 [imageAnat2,hdr2]=cbiReadNifti([dirAnatomy '/04+t1mprage/anatomy+04+t1mprage.img'],{[],[],[],[]},'native',1);
 [imageAnat3,hdr3]=cbiReadNifti([dirAnatomy '/05+t1mprage/anatomy+05+t1mprage.img'],{[],[],[],[]},'native',1);
 %
 %
 %%%
 % Manually define a crop region. You don't have to do this, but
 % it likely makes for better image registration in that region
 % that's of interest to us (occipital lobes). Check out your
 % images with commands like these:
 figure; imagesc(squeeze(imageAnat1(:,:,ceil(size(imageAnat1,3)/2)))); colormap('gray'); axis image off; truesize
 figure; imagesc(squeeze(imageAnat1(ceil(size(imageAnat1,1)/2),:,:))); colormap('gray'); axis image off; truesize
 figure; imagesc(squeeze(imageAnat1(:,ceil(size(imageAnat1,2)/2),:))); colormap('gray'); axis image off; truesize
 % Find a rectangular volume that encompases the visual areas of
 % interest.
 %%%%%%%%%%
 xCrop = 101:200;
 yCrop = 151:250;
 zCrop = 40:(176 - 40);
 %
 %
 %%%
 % Call estMotionIter3() to estimate motion between the first and
 % second anatomical scans. See 'help estMotionIter3'.
 %%%%%%%%%%
 M=estMotionIter3(double(imageAnat1(yCrop,xCrop,zCrop)),double(imageAnat2(yCrop,xCrop,zCrop)),3); 
 % NB: Unless estMotionIter3() is called with volumes cast to
 % doubles (as opposed, say, to int16s), the call will cause a
 % segmentation fault without further explanation.
 %%%
 % Using the above computed estimate, correct the second
 % anatomical image.
 %%%%%%%%%%
 imageAnat2Warped = warpAffine3(double(imageAnat2),M); 
 % NB: Unless warpAffine3() is called with the volume cast
 % to double, it'll behave in an unexpected fashion, but
 % without providing any warning message.
 %%%
 % Repeat for all images, including image one (which ensures the
 % integrity of the mean).
 %%%%%%%%%%
 M=estMotionIter3(double(imageAnat1(yCrop,xCrop,zCrop)),double(imageAnat3(yCrop,xCrop,zCrop)),3);
 imageAnat3Warped = warpAffine3(double(imageAnat3),M);
 imageAnat1Warped = warpAffine3(double(imageAnat1),eye(4));
 %
 %
 %%%
 % Compute the mean that we're interested in.
 %%%%%%%%%%
 imageAnatMean = (imageAnat1Warped + imageAnat2Warped + imageAnat3Warped) / 3.0;
 %
 %
 %%%
 % Write the mean anatomy volume in Nifti format.
 %%%%%%%%%%
 imageAnatMean = int16(imageAnatMean);
 filenameImageMean = 'meanAnatomy.img';
 [numBytesWrote,hdr] = cbiWriteNifti([dirAnatomy '/' filenameImageMean],imageAnatMean,hdr1,'int16',{[],[],[],[]},1);
 %
 %
 %%%
 % What'd it get you?
 %%%%%%%%%%
 figure;
 subplot(2,4,1); imagesc(imageAnat1(yCrop,xCrop,ceil(mean(zCrop)))); colormap('gray'); axis image off; title('Anatomy 1 (detail)')
 subplot(2,4,2); imagesc(imageAnat2(yCrop,xCrop,ceil(mean(zCrop)))); colormap('gray'); axis image off; title('Anatomy 2')
 subplot(2,4,3); imagesc(imageAnat3(yCrop,xCrop,ceil(mean(zCrop)))); colormap('gray'); axis image off; title('Anatomy 3')
 subplot(2,4,4); imagesc(imageAnatMean(yCrop,xCrop,ceil(mean(zCrop)))); colormap('gray'); axis image off; title('Anatomy mean')
 subplot(2,4,5); imagesc(imageAnatMean(yCrop,xCrop,ceil(mean(zCrop))) - double(imageAnat1(yCrop,xCrop,ceil(mean(zCrop))))); ... 
   colormap('gray'); axis image off; title('mean - 1')
 subplot(2,4,6); imagesc(imageAnatMean(yCrop,xCrop,ceil(mean(zCrop))) - double(imageAnat2(yCrop,xCrop,ceil(mean(zCrop))))); ...
   colormap('gray'); axis image off; title('mean - 2')
 subplot(2,4,7); imagesc(imageAnatMean(yCrop,xCrop,ceil(mean(zCrop))) - double(imageAnat3(yCrop,xCrop,ceil(mean(zCrop))))); ...
   colormap('gray'); axis image off; title('mean - 3')

The steps that follow averaging the anatomy data (esp. SurfRelax'ing) are very much dependent on pixel intensities. It's therefore perhaps a good idea to re-read your mean anatomy image (in Matlab) and check that the pixel intensities are on a similar range to that of, say, the first high-res anatomy scan.

Averaging high-res anatomical scans is a step that you'll likely use prior to SurfRelax'ing, amongst other things. Providing an (averaged) anatomy to SurfRelax requires that that anatomy have a particular orientation. You can re-orient using 'imageconv', which is part of the TFI distribution, but this seems to clobber Nifti headers. Rather, try using cbiSwapNiftiDimensions() from within Matlab. The following three transformations should do the trick:

 [d,h] = cbiReadNifti('meanAnatomy.img');
 [d_,h_,v] = cbiSwapNiftiDimensions(d,h,[-1 -2 3]);
 [d__,h__,v] = cbiSwapNiftiDimensions(d_,h_,[1 3 2]);
 [d___,h___,v] = cbiSwapNiftiDimensions(d__,h__,[2 1 3]);
 d___ = int16(d___);
 [bytecount,header] = cbiWriteNifti('meanAnatomyReoriented.img',d___,h___,'int16',{[],[],[],[]},1);