matlab

SVM regression (SVR) vs Linear Regression

One particular nice thing about SVR is that the weight of each feature reflects the feature’s true contribution. If some features are highly correlated (this is common in neuroimaging data – e.g. adjacent voxel activity are very similar),
Xu Cui
1 min read

Convert coordinates in MNI space to matrix space

Quite often you need to convert the coordinates of some voxels in MNI space to regular matrix coordinates. Below is a script to do so: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% mni2cor %%%%%%%%%%%%%%%
Xu Cui
43 sec read

Using environment variables in MatLab

Quite often you need to call external or system commands inside MatLab. Sometimes that external commands requires setting up environment variables in the shell. If would be a pain to do the environment setup inside MatLab. The easiest way I know of t
Xu Cui
14 sec read

Small MatLab tips

genpath When you add a folder to path, you often want to add all its subfolders (and their subfolders) to path too. In this case, you can use genpath. e.g. addpath(genpath(pwd)) use ii, instead of i, in loop (suggested by Chess Stetson) You probably
Xu Cui
1 min read

What does a wavelet transform plot tell you?

Let’s say you collected some brain data (time series) using NIRS while the participants were performing a task (say finger tapping), and you use the wt function in the “Cross Wavelet and Wavelet Coherence Toolbox” (link dead. Please
Xu Cui
1 min read

Handy programs to visualize NIRS data (5): plot2

Let’s say you have two correlated variables, x and y. You may have more then one data points with x=10 and y=5. But if you do a scatter plot all these data points of the same value will become a single dot. You may want to use circles with size
Xu Cui
31 sec read

Handy programs to visualize NIRS data (4): wt

In case you need to visualize your time series in both time and frequency domain (or just frequency domain), you can use the wt (wavelet transform) function in the Cross Wavelet and Wavelet Coherence toolbox by Grinsted et al. I often find the color
Xu Cui
33 sec read

Handy programs to visualize NIRS data (3): plotFFT

Sometimes you wish to know the spectrum of a time series. plotFFT is a handy function for this purpose. You instantly know the power of the signal at each frequency. Here is an example on how to use this function: figure; plotFFT(randn(1,1000)); Sour
Xu Cui
11 sec read

Handy programs to visualize NIRS data (1): plotTraces

You often need to plot the time series of NIRS signal from all channels with event indicators (See the example below). plotTraces can do that easily. In the above example, time series of all 24 channels are plotted. The number on the y-axis indicates
Xu Cui
26 sec read