function [cXYZ, Z, M, pt, str] = mars_getcluster
% mars_getcluster - load SPM results, returns XYZ point list for cluster
  
[cXYZ Z M pt str] = deal([]);
 
evalin('base','[hReg,SPM,VOL,xX,xCon,xSDM] = spm_results_ui;');
cXYZ = []; M = [];
spm_input('Select cluster, then Yes to continue',1,'d');
if ~spm_input('Continue?',2, 'y/n',[1 0],1)
  return
end

errstr = sprintf(['''Cannot find SPM/VOL structs in the workspace; '...
		  'Please run SPM results GUI''']);
SPM = evalin('base', 'SPM', ['error(' errstr ')']);
M = evalin('base', 'VOL.M', ['error(' errstr ')']);

%-Get current location
%-----------------------------------------------------------------------
pt   = spm_results_ui('GetCoords');

%---------------------------------------------------------------
if ~length(SPM.XYZ)
  spm('alert!','No suprathreshold clusters!',mfilename,0);
  spm('FigName',['SPM{',SPM.STAT,'}: Results']);
  return
end

Clusters = spm_clusters(SPM.XYZ);

[xyzmm,i] = spm_XYZreg('NearestXYZ',pt,SPM.XYZmm);
spm_results_ui('SetCoords',xyzmm);
tmp = Clusters==Clusters(i);
cXYZ = SPM.XYZmm(:, tmp);  
Z = SPM.Z(tmp);
str = SPM.title;
