hi all,
I employed the TDT tool box to calculate the SVM_weights as following:
clear variables
if isempty(which(‘decoding.m’))
error(‘Please add TDT to the matlab path’)
end
clear cfg
data_path=‘K:\Risk’;
base_dir=‘K:\Risk’;
cfg = decoding_defaults;
cfg.plot_design = 0;
cfg.analysis = ‘roi’;
cfg.results.dir = fullfile(base_dir, ‘MVPA_weight’);% Specify where the results should be saved
cfg.files.mask = fullfile(base_dir,‘mask.nii’);
x1 = cellstr(spm_select(‘FPList’,[data_path,‘cer’],’^sub..nii’));
y1 = cellstr(spm_select(‘FPList’,[data_path,‘risk’],’^sub..nii’));
scan = [x1;y1];
cfg.files.name = scan;
cfg.files.label = [ones(133,1);-1*ones(133,1)];
cfg.files.chunk = [(1:133)’;(1:133)’];
cfg.scale.method = ‘z’;
cfg.scale.estimation = ‘all’;
cfg.scale.check_datatrans_ok = true;
cfg.results.overwrite = 1;
cfg.results.output = {‘accuracy’};
cfg.design = make_design_cv(cfg);
results = decoding(cfg);
cfg.results.output = {‘SVM_pattern’}; % if you really want the weights, use ‘SVM_weights’
cfg.design = make_design_alldata(cfg); % overwrite the existing design
cfg.design.nonindependence = ‘ok’; % set non-independence to be ok
results = decoding(cfg); % re-run decoding analysis
but the matlab report an error as following:
Error using warningv (line 70)
Error: The expression left of the equal sign is not a valid target for assignment.
Error transres_SVM_weights_plusbias (line 222)
warningv(‘transres_SVM_weights_plusbias:check_sign_libsvm_labels_1_-1’,
‘Please verify that the sign of the returned weights. libsvm returned labels 1
and -1. This is an exception from an exception. While in general libsvm flips
the sign of the weights (for an unkown reason) when the first passed label is
smaller than the second, for some reason that we dont know it does sort the
labels 1 and -1 in a different way and independent of the order the labels are
given to it, but it does not flip the weight, i.e. as if the first label were
smaller than the second (which it is not, 1 is not smaller than -1). No idea
if anyone knows why that is the case. The last version we checked that
exhibited that strange behaviour is libsvm3.17. If you use a different verion,
check the sign of the output’)
Error transres_SVM_weights (line 37)
output_plus_weights = transres_SVM_weights_plusbias(decoding_out, chancelevel, cfg, data);
Error transres_SVM_pattern (line 49)
w = transres_SVM_weights(decoding_out, chancelevel, cfg, data);
Error decoding_transform_results (line 260)
output = feval(fhandle,decoding_out,chancelevel,cfg,data);
Error decoding_generate_output (line 35)
output = decoding_transform_results(curr_output,decoding_out,chancelevel,cfg,data);
Error decoding (line 568)
results = decoding_generate_output(cfg,results,decoding_out,i_decoding,curr_decoding,current_data);
Error MVPA_weight (line 41)
results = decoding(cfg); % re-run decoding analysis