Skip to content

Commit

Permalink
Merge pull request #103 from nno/_enh/no_sa_needed_single_target_mccs
Browse files Browse the repository at this point in the history
ENH: no not require .sa.{targets,chunks} present when .samples is row vector
  • Loading branch information
nno committed Oct 28, 2016
2 parents 97f64af + 3125ce8 commit 71d9d60
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mvpa/cosmo_balance_partitions.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function bal_partitions=cosmo_balance_partitions(partitions,ds, varargin)
% balances a partition so that each target occurs equally often in each
% training chunk
% training and test chunk
%
% bpartitions=cosmo_balance_partitions(partitions, ds, ...)
%
Expand Down
8 changes: 6 additions & 2 deletions mvpa/cosmo_montecarlo_cluster_stat.m
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,12 @@

function preproc_func=get_preproc_func(ds,opt)
nsamples=size(ds.samples,1);
is_one_independent_sample=numel(unique(ds.sa.targets))==1 && ...
numel(unique(ds.sa.chunks))==nsamples;

has_targets_chunks=all(cosmo_isfield(ds,{'sa.targets',...
'sa.chunks'}));
is_one_independent_sample=has_targets_chunks && ...
numel(unique(ds.sa.targets))==1 && ...
numel(unique(ds.sa.chunks))==nsamples;
is_single_sample=size(ds.samples,1)==1;

has_h0_mean=isfield(opt,'h0_mean');
Expand Down
13 changes: 12 additions & 1 deletion tests/test_montecarlo_cluster_stat.m
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,18 @@
assertEqual(res.fa,ds1.fa);
assertEqual(res.a,ds1.a);

% h0_mean shoudl work
% should also work when no .sa present, or no .sa.targets
ds_no_sa=rmfield(ds1,'sa');
res_no_sa=cosmo_montecarlo_cluster_stat(ds_no_sa,nh,opt);
assertElementsAlmostEqual(res_no_sa.samples,res.samples);

ds_no_targets=ds1;
ds_no_targets.sa=rmfield(ds_no_targets.sa,'targets');
res_no_targets=cosmo_montecarlo_cluster_stat(ds_no_targets,nh,opt);
assertElementsAlmostEqual(res_no_targets.samples,res.samples);


% h0_mean should work
c=8+rand();
null_cell_const=null_cell;
for k=1:numel(null_cell_const)
Expand Down

0 comments on commit 71d9d60

Please sign in to comment.