Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in tudadecode #112

Open
yingjoeyzhou opened this issue Apr 24, 2024 · 0 comments
Open

error in tudadecode #112

yingjoeyzhou opened this issue Apr 24, 2024 · 0 comments

Comments

@yingjoeyzhou
Copy link

I tried to train a STRM on some localizer trials, and apply the trained STRM on main trials of interest. However, i kept getting the error below while running tudadecode.m.

The error can be reproduced by evaluating the code below (the majority of code is copy-pasted from examples/STRM.m so I'd assume that the tudatrain.m is properly set up.

% ================== COPY-PASTE FROM `STRM.M` EXAMPLE STARTS =====================
%% PART ONE: Simulations for STRM-Classification model:
clear all;
rng(1);
P = 2; % number of data dimensions
Q = 2; % number of classes
K = 2; % number of latent states
T = 50; % number of timepoint in each trial
N = 20; % number of trials

% generate state timecourses:
z = zeros(N*T,K);
for itrial = 1:N
    transtime = rand(1)*48 + 1;
    t_offset = (itrial-1)*T;
    z(t_offset + [1:floor(transtime)],1)=1;
    z(t_offset + [ceil(transtime):T],2)=1;
end
cols = {[1 0 0],[0 1 0]}
% generate each class activation patterns and covariance matrices:
for ik=1:K
    W{ik} = randn(P+1,Q);
    Sigma{ik} = 0.5*wishrnd(eye(P),P);
end

% generate design matrices:
DM = [ones(N*T,1),[ones(N*T/2,1);zeros(N*T/2,1)],[zeros(N*T/2,1);ones(N*T/2,1)]];

% generate data itself:
data = zeros(N*T,P);
for itrial=1:N
    t_offset = (itrial-1)*T;
    for iT = 1:T
        data(t_offset+iT,:) = mvnrnd(DM(t_offset+iT,:)*W{find(z(t_offset+iT,:),1)},Sigma{find(z(t_offset+iT,:),1)});
    end
end

options = [];
options.K = K;
options.encodemodel = true; % this activates the STRM model
options.intercept = true;
options.covtype = 'full';
[STRMmodel,STRMstates] = tucatrain(data,DM(:,2:3),repmat(T,N,1),options);
% ================== COPY-PASTE FROM `STRM.M` EXAMPLE ENDS =====================


% decode
[Gamma,vpath] = tudadecode(data,DM,repmat(T,N,1),STRMmodel);

and the error message I get (in matlab2020b) looks like this:

Screenshot 2024-04-24 at 15 32 36

I'm not sure if I had missed something in the pipeline, or it is something wrong with the sub-functions called by tudadecode?

Thanks in advance for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant