function [transformed, outside]=cosmo_vol_coordinates(ds, coords)
% convert to and from spatial (x,y,z) coordinates
%
% [transformed, outside]=cosmo_vol_coordinates(ds[, coords])
%
% Inputs:
% ds dataset struct with fields .a.fdim.{labels,values}
% (with {'i','j','k'} a subset of .a.fdim.labels) and
% .a.vol.{mat,dim}
% coords (Optional) one of:
% - 1xP matrix of feature indices
% - 3xP matrix with spatial (x,y,z) coordinates
% If omitted then it is set to 1:nfeatures, with
% nfeatures=size(ds.samples,2);
%
% Returns:
% transformed - If coords is 1xP: 3xP spatial coordinates of the
% feature indices; columns have NaN for feature ids
% not in the dataset.
% - If coords is 3xP: 1xP feature indices of the
% coordinates; an entry is 0 for coordinates not
% matching a feature.
%
% # For CoSMoMVPA's copyright information and license terms, #
% # see the COPYING file distributed with CoSMoMVPA. #