Beauchamp:MVPA Notes

From OpenWetWare
Jump to navigationJump to search
Brain picture
Beauchamp Lab Notebook






To analyse data, we use the 3dsvm program. Data from some runs is used for training; data from other runs is used for testing. This process can be automated.


To see what brain areas are important for making the classification, we can look at the weight mask output by

 3dsvm -bucket

For this, we can't just do all runs at once since we don't care about getting an accuracy %.

3dsvm needs brain volumes to train and test on. For block designs, this would just be the volumes collected during each task (possibly eliminating the first few as the MR signal increases). For event-related designs, this can be approximated by just picking the brain volume collected 2 TRs (4 seconds) after the stimulus was presented. Or, it can be calculated using STIM_TIMES_IM in 3dDeconvolve. It is not clear that one way gives better results or not.

For STIM_TIMES_IM, the estimates of the response to trials that are very late in a run will be wacky, so it is best to delete these from the text file first.

 foreach f (*txt)
 cp $f newreg/trunc_{$f}
 end

Manually get rid of anything in last 10 seconds of each run. We only need to use IM for events that we are trying to classify; for other trial types (e.g. controls) there is no need. Sample command line:

 3dDeconvolve -fout -tout -full_first -polort a -concat runs.txt \
 -input {$ec}Albl+orig -num_stimts 15 -nfirst 0 -jobs 2 \
 -mask {$ec}maskAlbl+orig  \
 -stim_times_IM 1 newreg/trunc_VTv1T2.txt 'BLOCK(2,1)'  -stim_label 1 TacD2 \
 -stim_times_IM 2 newreg/trunc_VTv1T5.txt 'BLOCK(2,1)'  -stim_label 2 TacD5 \
 -stim_times_IM 3 newreg/trunc_VTv1V2.txt 'BLOCK(2,1)'  -stim_label 3 VisD2 \
 -stim_times_IM 4 newreg/trunc_VTv1V5.txt 'BLOCK(2,1)'  -stim_label 4 VisD5 \
 -stim_times_IM 5 newreg/trunc_VTv1TV2.txt 'BLOCK(2,1)'  -stim_label 5 TacVisD2 \
 -stim_times_IM 6 newreg/trunc_VTv1TV5.txt 'BLOCK(2,1)'  -stim_label 6 TacVisD5 \
 -stim_times 7 VTv1CT.txt 'BLOCK(2,1)'  -stim_label 7 TacCtrl \
 -stim_times 8 VTv1CV.txt 'BLOCK(2,1)'  -stim_label 8 VisCtrl \
 -stim_times 9 VTv1CVT.txt 'BLOCK(2,1)'  -stim_label 9 TacVisCtrl \
 -stim_file 10 {$ec}vr.1D'[0]'  -stim_base 10 \
 -stim_file 11 {$ec}vr.1D'[1]'  -stim_base 11 \
 -stim_file 12 {$ec}vr.1D'[2]'  -stim_base 12 \
 -stim_file 13 {$ec}vr.1D'[3]'  -stim_base 13 \
 -stim_file 14 {$ec}vr.1D'[4]'  -stim_base 14 \
 -stim_file 15 {$ec}vr.1D'[5]'  -stim_base 15 \
 -prefix {$ec}v{$v}mr

Next, we chop this up into separate files for each event type; it is easiest if there is the same number of events of each type.

 set f = EVv2mr+orig.HEAD
 3dinfo -verb $f | grep Coef

3dbucket -prefix {$ec}_T2 -fbuc $f'[1..59(2)]' 3dbucket -prefix {$ec}_T2 -fbuc $f'[1..59]'

We can further subdivide these for training/testing, e.g. into even and odd trials.

Create the train/test text files depending on how many of each event there is:

 1deval -num 125 -expr '0' > {$ec}_svmv1_train.1D
 1deval -num 125 -expr '1' >> {$ec}_svmv1_train.1D


For event-related designs

 set f = {$ec}_svmv{$v}_results.txt
 rm $f *svmv{$v}*model*
 foreach r (1 2 3 4 5 6)
 3dsvm_new -trainvol  {$ec}_svmv{$v}_r{$r}_LOO+orig \
 -trainlabels /Volumes/data2/TactileMVPA/AZ/afni/AZ_svmv1_train.1D \
 -mask  {$ec}FinalMask_binNoCSF+orig \
 -model {$ec}_svmv{$v}_r{$r}_model
 echo Results from run {$r} >>  $f
 3dsvm_new -nodetrend -classout \
 -testvol {$ec}_svmv{$v}_r{$r}+orig -model {$ec}_svmv{$v}_r{$r}_model+orig \
 -testlabels  /Volumes/data2/TactileMVPA/AZ/afni/AZ_svmv1_test.1D  \
 -predictions {$ec}_svmv{$v}_predict >> $f
 end
 cat $f | grep -i "accuracy"
 open -e $f