


Function to pass optional parameters into the classifier. This is primarily used for complex data prediction methods that need to know something about the experimental design that is normally not accessible to generic prediction functions (e.g. task onsets or TR). Examples of this kind of classifier include multi-class classifier using kernel regression (MCKR) and the machine that implements nested cross-validation. Inputs: ------- PRT: main data structure ID: id matrix for the current cross-validation fold CV: cross-validation structure (current fold only) Outputs: -------- Provides the following fields for use by the classifier param.id_fold: the id matrix for this fold param.model_id: id for the model being computed param.PRT: PRT data structure __________________________________________________________________________ Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory


0001 function param=prt_cv_opt_param(PRT,ID,model_id) 0002 % Function to pass optional parameters into the classifier. This is 0003 % primarily used for complex data prediction methods that need to know 0004 % something about the experimental design that is normally not accessible 0005 % to generic prediction functions (e.g. task onsets or TR). Examples of 0006 % this kind of classifier include multi-class classifier using kernel 0007 % regression (MCKR) and the machine that implements nested 0008 % cross-validation. 0009 % 0010 % Inputs: 0011 % ------- 0012 % PRT: main data structure 0013 % ID: id matrix for the current cross-validation fold 0014 % CV: cross-validation structure (current fold only) 0015 % 0016 % Outputs: 0017 % -------- 0018 % Provides the following fields for use by the classifier 0019 % param.id_fold: the id matrix for this fold 0020 % param.model_id: id for the model being computed 0021 % param.PRT: PRT data structure 0022 %__________________________________________________________________________ 0023 % Copyright (C) 2011 Machine Learning & Neuroimaging Laboratory 0024 0025 % Written by A Marquand 0026 % $Id: prt_cv_opt_param.m 422 2012-01-26 10:30:21Z amarquan $ 0027 0028 param.id_fold = ID; 0029 param.model_id = model_id; 0030 param.PRT = PRT; 0031 0032 % Old fields 0033 % param.cv_fold: the vector from the CV matrix controlling this CV fold 0034 % .group: group data for subjects included in this fold (copied 0035 % from PRT). 0036 % .onsets: matrix of event onsets (n_events x n_conditions) 0037 % .durations: matrix of event durations (n_events x n_conditions) 0038 % .TR: TR for this group/subject/modality/event 0039 % .unit: units for this design 0 = scans, 1 = seconds 0040 % .ids: reduced id matrix (group,subject,modality) 0041 % 0042 % Old approach 0043 % 0044 % groups = unique(ID(:,1)); 0045 % offset = 0; 0046 % onsets_all = []; durations_all = []; TR_all = []; unit_all = []; id_all = []; 0047 % for g = 1:length(groups) 0048 % gidx = ID(:,1) == groups(g); 0049 % subs = unique(ID(gidx,2)); 0050 % 0051 % for s = 1:length(subs) 0052 % sidx = ID(:,1) == groups(g) & ID(:,2) == subs(s); 0053 % mods = unique(ID(sidx,3)); 0054 % for m = 1:length(mods) 0055 % % fist check to see if the subject has a design 0056 % if isfield(PRT.group(groups(g)).subject(subs(s)).modality(mods(m)).design,'conds') 0057 % % save all conditions for this subject 0058 % ons = [PRT.group(groups(g)).subject(subs(s)).modality(mods(m)).design.conds(:).onsets]; 0059 % dur = [PRT.group(groups(g)).subject(subs(s)).modality(mods(m)).design.conds(:).durations]; 0060 % 0061 % % reshape since they are column vectors 0062 % dur = reshape(dur,(size(ons))); 0063 % TR = PRT.group(groups(g)).subject(subs(s)).modality(mods(m)).design.TR; 0064 % unit = PRT.group(groups(g)).subject(subs(s)).modality(mods(m)).design.unit; 0065 % 0066 % param.group(groups(g)).subject(subs(s)) = ... 0067 % PRT.group(groups(g)).subject(subs(s)); 0068 % 0069 % if size(onsets_all,2) == size(ons,2) || isempty(onsets_all) 0070 % % only populate the fields if there are the same number 0071 % % of conditions for every subject 0072 % onsets_all = [onsets_all; ons+offset]; 0073 % durations_all = [durations_all; dur]; 0074 % TR_all = [TR_all; repmat(TR, size(ons,1),1)]; 0075 % unit_all = [unit_all; repmat(unit, size(ons,1),1)]; 0076 % id_all = [id_all; repmat([groups(g) subs(s) mods(m)], size(ons,1),1)]; 0077 % 0078 % if unit == 0 % scans 0079 % offset = offset + size(PRT.group(groups(g)).subject(subs(s)).modality(mods(m)).scans,1); 0080 % else % seconds 0081 % offset = offset + TR*size(PRT.group(groups(g)).subject(subs(s)).modality(mods(m)).scans,1); 0082 % end 0083 % end 0084 % end 0085 % end 0086 % end 0087 % end 0088 % 0089 % % populate output fields 0090 % if ~isempty(onsets_all) 0091 % param.onsets = onsets_all; 0092 % param.durations = durations_all; 0093 % param.TR = TR_all; 0094 % param.unit = unit_all; 0095 % param.ids = id_all; 0096 % end 0097 end