User:M1ss1ontomars2k4/permute

The permutation tester is written and maintained by [mailto:tandiono@radmail.ucsf.edu Chris].

How to use
There are several steps which must be followed.

General setup

 * First, ensure that there is a folder on chef.compbio.radiology.ucsf.edu (in /netapp/home/yourusername/) where the permutation tester can save your data.

localhost:~ matt$ ssh groening@chef.compbio groening@chef.compbio's password: Last login: Mon Aug 3 16:42:00 2009 from 128.218.60.109 Please remember that the /panfs/ and /netapp/ storage is for short term high performance use ONLY, and is not backed up. Move longer term data to your own systems and backups.

Also note that chef is to be used only for submitting jobs to SGE. The sysadmin reserves the right to kill without warning any simulations or similar programs running on chef.

For more information, see the QB3 Cluster Wiki. See /usr/share/doc/WIKI-ACCESS for access information.

[groening@chef ~]$ mkdir FryPhilip [groening@chef ~]$ ls | grep FryPhilip FryPhilip [groening@chef ~]$ cd FryPhilip [groening@chef FryPhilip]$ ls -a . .. [groening@chef FryPhilip]$


 * Make sure you have installed a copy of the MCR (MATLAB Compiler Runtime) that comes with MATLAB 7.4 R2007a (MCR version 7.6). The appropriate paths must be included using Matlabsetup.csh. Refer to the MATLAB documentation for help.


 * Make sure you have a copy of the scripts necessary to run the permutation tester.


 * Compile the code in MATLAB 7.4 (if you don't have a compiled copy) with permute_build, and copy it to chef.
 * Make sure you are in an empty directory before running permute_build, or you won't be able to tell which files are those you should copy to chef.


 * Make sure the permissions are correctly set on permute_random with chmod +x ${pathtopermute_random}/permute_random.


 * In your home folder on <tt>chef</tt>, create an <tt>error</tt> and <tt>output</tt> folders, and in those folders make a folder for each of the algorithms you intend to use. (If you don't want any debugging output, you can turn this off by editing <tt>callpermute_random.csh</tt>.
 * If you are using an algorithm that is not one of the 5 (champagne, dSPM, sLORETA, default eigenspace beamformer, non-eigenspace beamformer), you must edit a certain file to make sure the compiler knows to include that file.

Setting up for a specific permutation test

 * Create a new sessionfile in NUTMEG. For the MEG data, use the averaged data. Save the session as <tt>nuts_permute.mat</tt>.


 * Do a <tt>ctf_read</tt> operation on the unaveraged data and save it to <tt>permute_data.mat</tt>, like so:

>>> data=ctf_read('${path_to_dataset}/dataset-unaveraged.ds','meg','all','all') >>> save permute_data.mat data >>>


 * These files must be copied to chef as well.

mimamsa> ls | grep permute nuts_permute.mat permute_data.mat mimamsa> scp ./*permute* groening@chef.compbio:~/FryPhilip/. groening@chef.compbio's password: nuts_permute.mat                             100%   12MB  12.4MB/s   00:00 permute_data.mat                             100%  160MB  22.8MB/s   00:07 mimamsa>


 * You can then run the appropriate script to run as many or as few algorithms as you would like. You may have to modify <tt>qsub_callpermute_random</tt> and <tt>callpermute_random.csh</tt> to point to your copy/copies of the files (including the MCR) rather than someone else's. You may also need to modify <tt>callpermute_random.csh</tt> to set the time limit to an appropriately high value, or some instances won't complete by the time limit and will die without producing any data.


 * <tt>cd</tt> to the correct directory with the qb3 scripts (wherever you've placed them), then run <tt>qsub_callpermute_random</tt> with the appropriate arguments:

[groening@chef ~]$ cd qb3 [groening@chef qb3]$ ./qsub_callpermute_random 1000 ~/FryPhilip noES Your job-array 2982329.1-1000:1 ("permute_noES") has been submitted [groening@chef qb3]$


 * The first argument is the number of permutations you would like to do. This is typically at least 1000. The second argument is the folder you created previously. The last argument is the algorithm you would like to use. At the moment, you can only choose one algorithm at a time. If you would like to queue up several algorithms at once, you can do so:

[groening@chef qb3]$ ./qsub_callpermute_random 1000 ~/FryPhilip noES Your job-array 2982329.1-1000:1 ("permute_noES") has been submitted [groening@chef qb3]$ ./qsub_callpermute_random 1000 ~/FryPhilip sLORETA Your job-array 2982330.1-1000:1 ("permute_sLORETA") has been submitted [groening@chef qb3]$ ./qsub_callpermute_random 1000 ~/FryPhilip default Your job-array 2982331.1-1000:1 ("permute_default") has been submitted [groening@chef qb3]$


 * At any time, you can run <tt>qstat</tt> on <tt>chef</tt> in order to observe your job or jobs.


 * <tt>permute_stat5</tt> can be used to additionally create original weights-weighted s_beams for default and noES. The syntax is <tt>qsub_permute_stat5 </tt> (it must be run on the grid, or it would tie up the RAID for who knows how long). The <tt> </tt> option is the same as the directory previously; <tt>permute_stat5</tt> will scan through the directory and save the new s_beams in <tt> /Worig</tt>. The <tt> </tt> option is the algorithm, either default or noES. <tt>permute_stat5</tt> uses specially modified copies of <tt>nut_generate_beamforming_activations</tt>, <tt>nut_beamforming_gui</tt>, and <tt>permute_batch</tt>.

Statistical analyses
<tt>small_s_beam_*</tt> files have the weights matrix stripped out for dSPM and sLORETA and the time course data converted to a power map for dSPM, sLORETA, default, and noES. These files and the s_beams for champagne have to be copied back over from chef in order to run statistical analyses. You will also need to run <tt>permute_test</tt> with a dummy dataset argument to generate the s_beams for the original data locally. So you will end up with a folder with several thousand s_beams, including the original ones. You also create a new .mat file, <tt>template.mat</tt> which has information on the filenames.

<tt>permute_stat</tt> is a customizable function that accepts one argument: a string that it will look for in the filenames that it is loading. It will scan the current directory for files with that string (caps matter), so this string is usually the algorithm you want to work with. There is a "style" section within <tt>permute_stat</tt>--you can choose an existing method of analysis or write your own. There's also a hardcoded option for normalization; change the <tt>if</tt> statement to fit the correct way.

%normalizing...

if 0 disp([num2str(cputime,'%#.2f') ' normalizing']) for i=1:size(stat,2) stat(:,i)=stat(:,i)./maxstat(i); end

original=original./max(original);

interestingvalues=interestingvalues/max(interestingvalues); end

About the permutation tester
There are several parts to the permutation tester. Use the MATLAB <tt>help</tt> command to get information on any part of it. The permutation tester requires NUTMEG (duh).

<tt>permute_random</tt> is just a wrapper-type function that generates random numbers to pass to <tt>permute_test</tt>. You can substitute it with something else, such as a program that reads pre-generated random numbers off a list.