Interview with David Shelly
David is an amazing person: he has published 5 papers in Nature and 1 in Science, two of which were published this year. Check out what he says in Peaya interview (click the photo below).
David is an amazing person: he has published 5 papers in Nature and 1 in Science, two of which were published this year. Check out what he says in Peaya interview (click the photo below).
I noticed that gmail will remind you if you have something like “… is attached” in the email body but actually you don’t attach any files. This is very considerate.
If variable X and Y has correlation 0.1, how much does it help to predict Y based on X? In the simplest binary case, the probability (p) to correctly predict Y based on X is a linear function of correlation (c), i.e.
$$p=\frac{c+1}{2}$$
That means, a 0.1 correlation will increase the prediction probability from 0.5 to 0.55, a 5% increase. This could be significant if you are betting a lot of money :)
Null hypothesis (H0): Octopus Paul doesn’t have the ability to predict. Or, the probability that he predicts correctly on each event is 1/2.
Data: In 2010 World Cup, Octopus Paul correctly predicted the outcomes of 8 games out of 8 games.
p-Value: (the probability to obtain the data assuming the null hypothesis is true): 1/2^8 = 0.0039
Statistical significance threshold: alpha = 0.05
Conclusion: as pvalue < alpha, we conclude that the null hypothesis should be rejected. Loosely speaking, octopus Paul does have prediction power.
Comic strips about our academia life – the excitement, joy, depression, and pain. We hope the strips will make you smile. Below is the latest comics:
A software tool that allows you to manage papers and PDFs and access them anywhere (Windows, Mac, and Linux). It also makes it easy to share with friends and collaborators. We hope Peaya Paper will make your work more productive. See how happy Iris (below) is after using Peaya Paper!
A MS Word add-in that offers a completely new way to insert citations — Cite Seamlessly with real-time context-dependent reference hinting. We hope Peaya Cite will allow you to concentrate on writing itself rather than on trivial citation insertion or formatting.
Tools: SPM, cor2mni
Assume the image is “a.img”, do
v = spm_vol('a.img');
v.mat
If v.mat is a diagonal matrix, you can simply read the number and they are the voxel size in mm.
If not, a trick is to calculate the distance between adjacent voxels. For example, if v.mat =
-3.4337 -0.0518 -0.1776 110.2825
-0.0919 3.3036 1.1004 -97.8366
-0.1324 -0.9487 3.8416 19.7459
0 0 0 1.0000
Use cor2mni.m to calculate the voxel coordinate in MNI space.
point1 = cor2mni([1 1 1], v.mat); point2 = cor2mni([1 1 2], v.mat);
Then calculate the distance between point1 and point2 you will get the voxel size in z direction. Repeat for x and y direction.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% cor2mni
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function mni = cor2mni(cor, T)
% function mni = cor2mni(cor, T)
% convert matrix coordinate to mni coordinate
%
% cor: an Nx3 matrix
% T: (optional) rotation matrix
% mni is the returned coordinate in mni space
%
% caution: if T is not given, the default T is
% T = ...
% [-4 0 0 84;...
% 0 4 0 -116;...
% 0 0 4 -56;...
% 0 0 0 1];
%
% xu cui
% 2004-8-18
% last revised: 2005-04-30
if nargin == 1
T = ...
[-4 0 0 84;...
0 4 0 -116;...
0 0 4 -56;...
0 0 0 1];
end
cor = round(cor);
mni = T*[cor(:,1) cor(:,2) cor(:,3) ones(size(cor,1),1)]';
mni = mni';
mni(:,4) = [];
return;
Here are some parameters in matlab lighting. I first use patch command to plot the surface, then use camlight to shed some light on the surface.
In your AIR application, if you overwrite the application menu, you might find that the keyboard shortcuts (e.g. Cmd-C, V) doesn’t work under Mac. It seems the “Edit” menu in the default application is essential to these functions. So you should at least keep the “Edit” menu if you need to use your own menu.
SVM is mostly commonly used for binary classifications. But one branch of SVM, SVM regression or SVR, is able to fit a continuous function to data. This is particularly useful when the predicted variable is continuous. Here I tried some very simple cases using libsvm matlab package:
1. Feature 1D, use 1st half to train, 2nd half to test. The fitting is pretty good.
2. Still 1D, but apparently the data is nonlinear. So I use nonlinear SVR (radial basis). The fitting is good.
3. What if we have a lot of dimensions? Here I tried feature space with up to 100 dimensions and calculated the correlation between predicted values and the actual values. For linear SVR (blue), the number of dimension doesn’t affect the correlation much. (red: nonlinear, blue:linear, same data for both cases)
One property of SVR I like is that, when two features are similar (i.e. highly correlated), their weights are similar. This is in contrast with “winner take all” property of general linear model (GLM). This property is desired in brain imaging analysis: neighbor voxels have highly correlated signals and you want them to have similar weights.
About performance: If different features have different scales, then normalization of data will improve the speed of libsvm. Also, the cost parameter c also affects the speed. The larger c is, the slower libsvm is. For the simulated data I used, the parameters don’t affect the accuracy.
MatLab code: test_svr.m
libsvm: http://www.csie.ntu.edu.tw/~cjlin/libsvm/#matlab
options: -s svm_type : set type of SVM (default 0) 0 -- C-SVC 1 -- nu-SVC 2 -- one-class SVM 3 -- epsilon-SVR 4 -- nu-SVR -t kernel_type : set type of kernel function (default 2) 0 -- linear: u'*v 1 -- polynomial: (gamma*u'*v + coef0)^degree 2 -- radial basis function: exp(-gamma*|u-v|^2) 3 -- sigmoid: tanh(gamma*u'*v + coef0) -d degree : set degree in kernel function (default 3) -g gamma : set gamma in kernel function (default 1/num_features) -r coef0 : set coef0 in kernel function (default 0) -c cost : set the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default 1) -n nu : set the parameter nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5) -p epsilon : set the epsilon in loss function of epsilon-SVR (default 0.1) -m cachesize : set cache memory size in MB (default 100) -e epsilon : set tolerance of termination criterion (default 0.001) -h shrinking: whether to use the shrinking heuristics, 0 or 1 (default 1) -b probability_estimates: whether to train a SVC or SVR model for probability estimates, 0 or 1 (default 0) -wi weight: set the parameter C of class i to weight*C, for C-SVC (default 1) The k in the -g option means the number of attributes in the input data.
>
This is an example of brain activation plotted on surface. In many circumstances surface view is much more straightforward than a slice view. Here is how I created such a plot using MatLab and SPM.
Environment and Tools:
Step 1. Generate “faces” and “vertices” of the surface using SPM
If you prefer to use SPM’s interface, launch SPM, then click “Render …” box and click “Xtract surface”. You are asked to input an image file. Select an image file and press Done. Select “Save Extracted Surface” and a few seconds later you will find a file called “surf_???.mat” saved in the current directory. Load this mat file and you will find two variables, faces and vertices. These two variables will be used in the future steps.
If you prefer to use command line, you can simple call function
spm_surf(’xxx.img’, threshold)
About the input image: If you want to plot surface of brain, you should use a segmentation tool (such as FSL) to get the gray matter image, and use this image as input to spm_surf. If you want to plot the surface of skull, you can input the original structural image but with careful choice of threshold.
Step 2. Plot the surface
Plot using MatLab’s patch function. Here is a sample code
p=patch(’faces’,faces,’vertices’,vertices, ‘facecolor’, ‘flat’, ‘edgecolor’, ‘none’, ‘facealpha’, 1);
facecolor = repmat([1 1 1], length(faces), 1);
set(p,’FaceVertexCData’,facecolor);daspect([1 1 1])
view(3); axis tight
view([50 -40 100])
camlight
lighting gouraud
Step 3. Overlay a functional image
The strategy here is that you first get the coordinates of the activated voxels and the corresponding colors you want to use for each voxel (presumablly dependent on the intensity of each voxel). Then find the vertices and faces that are “close” to the coordinates, and change the face color.
a. get coordinates
v = spm_vol(imagefile); % functional image file
m = spm_read_vols(v);
pos = find(m>=threshold);[xyzcor(:,1) xyzcor(:,2) xyzcor(:,3)] = ind2sub(size(m), pos);
xyz = cor2mni(xyzcor, v.mat);
intensity = m(pos);
b. convert intensity to color
tmp = hot; % using ‘hot’ color scheme
mx = max(intensity);
mn = min(intensity);
intensity = round((intensity - mn)/(mx - mn) * 63 + 1);
colors = tmp(intensity,:);
c. plot
distanceThreshold = 2;
p=patch(’faces’,faces,’vertices’,vertices, ‘facecolor’, ‘flat’, ‘edgecolor’, ‘none’, ‘facealpha’, 1);
facecolor = repmat([1 1 1], length(faces), 1);
pos = [];
for ii=1:size(xyz, 1)
tmp = find(abs(vertices(:,1) - xyz(ii, 1)) <= distanceThreshold & abs(vertices(:,2) - xyz(ii, 2)) <= distanceThreshold & abs(vertices(:,3) - xyz(ii, 3)) <= distanceThreshold );
pos = [tmp];
posf = find(sum(ismember(faces, pos),2)>0);
facecolor(posf,:) = repmat(colors(ii,:), length(posf), 1);
endset(p,’FaceVertexCData’,facecolor);
daspect([1 1 1])
view(3); axis tight
view([50 -40 100])
camlight
lighting gouraud