function example_djm_partitions()
  %{
  %%%%%%%%%%%%%%%%%%%%%
  djm: This shows a simple group analysis for the vt mask of the AK6 dataset.
  It illustrates three types of partition: single split-half (e.g. oddeven), nfold
  (aka leave-one-out), and repeated split-half.
  %%%%%%%%%%%%%%%%%%%%%
  %}

  %% Define data
  config=cosmo_config();
  subs={'s01','s02','s03','s04','s05','s06','s07','s08'};
  partitions={'odd_even', 'nfold', 'full_split_half'};

  rng(0); % reset random number generator for reproducability

  figure(9); clf(9);

  result=nan( numel(subs), numel(partitions) ); % djm, preallocate array
  for s=1:numel(subs)
    fprintf('.')
    data_path=fullfile(config.tutorial_data_path,'ak6',subs{s});
    data_fn=fullfile(data_path,'glm_T_stats_perrun.nii');
    mask_fn=fullfile(data_path,'vt_mask.nii');
    ds=cosmo_fmri_dataset(data_fn,'mask',mask_fn,...
    'targets',repmat(1:6,1,10),... % 6 types of animal
    'chunks',floor(((1:60)-1)/6)+1); % 10 runs

    % remove constant features (due to liberal masking)
    ds=cosmo_remove_useless_data(ds);

    % Assign a function handle to the cosmo_crossvalidation_measure
    measure=@cosmo_crossvalidation_measure;

    % Make a struct containing the arguments for the measure:
    args=struct();
    args.classifier=@cosmo_classify_nn;

    for p=1:numel(partitions)

      switch partitions{p}
        case 'odd_even'
          args.partitions=cosmo_oddeven_partitioner(ds,'half');
        case 'nfold'
          args.partitions=cosmo_nfold_partitioner(ds);
        case 'full_split_half'
          args.partitions=cosmo_nchoosek_partitioner(ds,0.5);
        otherwise
          error('unknown partition type')
      endswitch
      cosmo_check_partitions(args.partitions,ds);

      % Apply the measure to ds, with args as second argument.
      tic
      ds_accuracy=measure(ds,args);

      % for subject 1, plot partitions, and how long this scheme took
      if s==1
        subplot(2,2,p)
        plot_partitions(args.partitions);
        title(sprintf('%s; tooks %.1f s per subject',partitions{p},toc),'interpreter','none')
        drawnow
      endif

      % store the result as accuracy minus chance (so positve values indicate information present)
      result(s,p)=ds_accuracy.samples-1/6;

    end % next partition scheme
  end % next subject

  % Run ttest versus chance (now zero)
  [h, p, ci, stat]=ttest(result);

  % plot results with 95% confidence intervals
  subplot(2,2,4)
  errorbar(mean(result),range(ci)./2,'o')
  set(gca,'xtick',1:numel(partitions),'xticklabel',partitions)
  ylabel('accuracy minus chance')
  ylim([-0.2 0.5]);
  hold on
  plot(xlim,[0 0],'--')
  drawnow

  return

  function plot_partitions(partitions)
    % djm: plot partitions like in documentation
    maxs=max(cellfun(@max,[ partitions.train_indices partitions.test_indices]));
    nc=numel( partitions.test_indices);
    out=zeros(maxs,nc);
    for c=1:nc
      out(partitions.train_indices{c},c)=1;
      out(partitions.test_indices{c},c)=2;
    endfor
    imagesc(out);
    if nc<21
      set(gca,'xtick',1:nc)
    else
      set(gca,'xtick',[1 nc])
    endif
    xlabel('classifiers')
    ylabel('samples')
    colormap([1 1 1; 0 1 0; 1 0 0]);
    caxis([0 2])
    return
