function stat_repr=cosmo_statcode(ds, output_format)
% Convert statcode for different analysis packages
%
% stat_repr=cosmo_statcode(ds[, output_format])
%
% Inputs:
% ds dataset struct with N samples, or Nx1 cell with strings
% with statistic labels, or AFNI, BV or NIFTI header
% struct for N samples.
% output_format Optional; one of 'afni', 'bv', or 'nifti'; or empty.
%
% Returns:
% stat_repr - If output_format is empty or omitted: an Nx1 cell
% with a string representation of the statistic in each
% sample, e.g. 'Ftest(123,2)' or 'Zscore()' or empty.
% - If output_format=='afni': struct with field
% .BRICK_STATAUX.
% - If output_format=='bv': Nx1 cell with structs, each
% with fieldnames .name, .DF1 and .DF2.
% - If output_format=='nifti': struct with fieldnames
% .intent_code and .intent_p{1,2,3} if all stat codes
% are the same; empty otherwise (NIFTI does not support
% different stat codes for different samples).
%
% Notes:
% - this function is intended for fmri datasets
%
% # For CoSMoMVPA's copyright information and license terms, #
% # see the COPYING file distributed with CoSMoMVPA. #