function data = hdfread(SDS,junkstr,Index,verbosity)
%HDFREAD Returns data in SDS in an HDF 4 file.
%
%    Data = HDFREAD(SDS) is (nearly) equivalent to the Matlab command
%    HDFREAD. 
%
%    See also HDFINFO.

if (nargin < 4)
  verbosity = 0;
end

if (nargin > 2 )
  IND(1,:) = Index{1}-1;
  IND(2,:) = Index{2};
  if isempty(Index{2})
    IND(2,:) = [1 1];
  end
  IND(3,:) = Index{3};
else
  IND(1,:) = -1;
  IND(2,:) = -1;
  IND(3,:) = -1;
end

[info,data] = load_hdf(SDS.Filename, SDS.Index-1, IND, verbosity);

if (0)
% Should really pass the Index information to the hdf code 
% since hdf has the ability to randomly access data.
if (nargin > 2)
  START  = Index{1};
  STRIDE = Index{2};
  if isempty(STRIDE)
    STRIDE = [1 1];
  end
  EDGE   = Index{3};
  if (size(data,2) < 3)
    data   = data(  START(1):STRIDE(1):START(1) - 1 + EDGE(1),:);
    data   = data(:,START(2):STRIDE(2):START(2) - 1 + EDGE(2));
  end
end
end
