Errors when 'bridging' two programmes together.

1 view (last 30 days)
Hi,
I am currently working on a toolbox, where I have created plugins to create a nicer user interface.
It's a pretty long program but hopefully what I have supplied below is enough please ask for more info in required.
I have tried to set the format so it is easy to read...I hope it has worked!!
User-interface code (menu):
cv_none = cfg_const; % For if no covariates are used (default)
cv_none.tag = 'cv_none';
cv_none.name = 'None';
cv_none.val = {1};
cv_none.help = {'Covariate value = none'};
cov_Val = cfg_entry; %For if a covariate value needs to be entered...enter value
cov_Val.tag = 'cov_Val';
cov_Val.name = 'Enter Number of Covariate';%arbitary name
cov_Val.help = {'Help'};
cov_Val.strtype = 'e';
cov_Val.num = [Inf 1];
cv_one = cfg_branch; %Text display of this option in menu
cv_one.tag = 'cv_one';
cv_one.name = 'Enter Different Covariate Value';
cv_one.val = {cov_Val};
cv_one.help = {'Help'};
covariate = cfg_choice; %Menu showing an option
covariate.tag = 'covariate';
covariate.name = 'Covariate'; %arbitary name
covariate.val = {cv_none };
covariate.help = {'Help'};
covariate.values = {cv_none cov_Val };
%% Executable Branch
snpmui = snpm_cfg_ui(DesNm,DesFile,DesHelp,{covariate}); % In the configure file (separate)
Code for the plugin to be able to run the software (where the errors are pointing me towards!):
if BATCH
covariate = job.covariate(:);
if ~all(size(covariate)==[nScan,1])
error(sprintf('Covariate [%d,1] does not match number of subjects [%d]',...
size(covariate,1),nScan))
end
else
covariate = [];
while ~all(size(cov_Val)==[nScan,1])
covariate = spm_input(sprintf('Enter covariate values
[%d]',nScan),'+1');
covariate = cov_Val(:);
end
end
The error I am getting when I insert '12' into the space for "Enter covariate value"
------------------------------------------------------------------------
Running job #1
------------------------------------------------------------------------
Running 'MultiSub: One Sample T test on diffs/contrasts'
Failed 'MultiSub: One Sample T test on diffs/contrasts'
Error using ==> snpm_pi_OneSampT at 115
Covariate [1,1] doesn't match number of subjects [12]
In file
"C:\Users\Emma\Documents\Project\snpm10_devel\snpm_pi_OneSampT.m" (???), function "snpm_pi_OneSampT" at line 115.
In file "C:\Users\Emma\Documents\Project\snpm10_devel\snpm_ui.m" (???), function "snpm_ui" at line 297.
In file "C:\Users\Emma\Documents\Project\snpm10_devel\config\snpm_run_ui.m" (???), function "snpm_run_ui" at line 12.
The following modules did not run:
Failed: MultiSub: One Sample T test on diffs/contrasts
Thank you for reading, I appreciate you're time :)
Emma T

Accepted Answer

Walter Roberson
Walter Roberson on 6 Apr 2011
You haven't given us enough code to work with, but from the output message we can see that you are hitting the condition BATCH which is overwriting the structure "covariate" that it has set up, with whatever is in "job.covariate(:)" . You haven't give us any information about what is in "job", but if there is any consistency with the code proceeding that, I would expect that job.covariate would be a structure array with a single array member; the code before that point does not attempt to create a structure array, so there is no reason to think that there would be one structure array element per subject.
Perhaps the BATCH condition should be testing the size of covariate.values or covariate.val .
  2 Comments
Emma Thomas
Emma Thomas on 6 Apr 2011
Hi!
I did fear that there was not enough information!
From what I gather the job.covariate links to the *main* file which contains all default values and structures... which then links to the first bit of code - they all kind of interrelate! (I am not sure this is helping!)
The BATCH is the newly developed user interface - so the new menu system what needs to happen is for the BATCH to be used to overwrite the old system to still use the same functions & variables within the old system. So What I am trying to say is that all the calculations and variables and functions that are being used in the code (2nd bit) needs to stay the same it just needs to work with the new menu system. BATCH.
Job. is basically the function which takes the informations from one piece of code to another.
My programming knowledge is really limited (as you can tell!) This is the original code:
G = []; Gnames = ''; Gc = []; Gcnames = ''; q = nScan;
g = spm_input('# of confounding covariates','+1','0|1|2|3|4|5|>',0:6,1);
if (g == 6), g = spm_input('# of confounding covariates','+1'); end
while size(Gc,2) < g
nGcs = size(Gc,2);
d = spm_input(sprintf('[%d] - Covariate %d',[q,nGcs + 1]),'0');
if (size(d,1) == 1), d = d'; end
if size(d,1) == q
%-Save raw covariates for printing later on
Gc = [Gc,d];
%-Always Centre the covariate
bCntr = 1;
if bCntr, d = d - ones(q,1)*mean(d); str=''; else, str='r'; end
G = [G, d];
dnames = [str,'ConfCov#',int2str(nGcs+1)];
for i = nGcs+1:nGcs+size(d,1)
dnames = str2mat(dnames,['ConfCov#',int2str(i)]); end
Gcnames = str2mat(Gcnames,dnames);
end
end
%-Strip off blank line from str2mat concatenations
if size(Gc,2), Gcnames(1,:)=[]; end
%-Since no FxC interactions these are the same
Gnames = Gcnames;
erm, make much more sense?
Walter Roberson
Walter Roberson on 6 Apr 2011
"job" cannot be a function, as it is not allowed to use a structure reference off of a function call as would be the case for
covariate = job.covariate(:)
"job" is perhaps a variable that the output of "Job" has been assigned to, but there is no obvious structure assignment in the code you showed for "Job", and no "function" statement either.
The G and Gc variables that are calculated in the code you show, which are commented as having to do with the covariances, are plain numeric variables, not structure variables. If either of them is being returned as job.covariances then that would be a numeric array and then as I noted earlier you would be overwriting a structure array with a numeric array, which your description of BATCH would indicate is not what you want.
Anyhow, in the first executable line of snpm_pi_OneSampT after job is initialized, put a breakpoint, and check what the type and size is of job and job.covariance .

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!