%program to superimpose ROIs on an anatomical background.  (analyze images)
%Sue Whitfield    2001
%modified to use spm_image - JC 10/10/2002



%P1 = spm_get(1,'*.img','Specify background image');


spm_image;


num = spm_input('Number of images to display',1,'1 img|2 imgs|3 imgs',[1 2 3]);


P = spm_get(num,'*.img',{'Select image(s) to display'},pwd,0);


for i=1:num,

	c = spm_input(['Color for image:  ' P{i}],'+1','m','Red blobs|Yellow blobs|Green blobs|Cyan blobs|Blue blobs|Magenta blobs|Multi-Valued/T-Stat Image',[1 2 3 4 5 6 7],1);
   colours = [1 0 0;1 1 0;0 1 0;0 1 1;0 0 1;1 0 1];
    
if (~(c > 6))
    spm_orthviews('AddColouredImage', 1, P{i},colours(c,:));
end
if (c == 7)
    v = spm_vol(P{i});
    [Z,XYZ] = spm_read_vols(v);
    XYZ = XYZ(:,find(Z));
    Z = Z(find(Z));
    vinv = inv(v.mat);  %matrix converting mm->voxels
    vox_XYZ = vinv(1:3,:)*[XYZ; ones(1,size(XYZ,2))];
    vox_XYZ = round(vox_XYZ);

    spm_orthviews('AddBlobs',1,vox_XYZ,Z,v.mat);
end



% Update the display..
spm_orthviews('Redraw');

end



