pro IDACGetROIStats,pinfo,ind,xv,yv
	nvert = n_elements(xv)
	xycoordStr = strarr(nvert)
	retval = fltarr(3)
	fmt = '(I3,A3,F7.2,1x,A3,F7.2)'
	;fmt1 = '(A2,F4.1,1x,A2,F4.1)'
	fmt1 = '(I3,A3,F7.2,1x,A3,F7.2)'
	for i=0,nvert-1 do begin
		str = string(format=fmt,xv[i],yv[i])
		if (*pinfo).helio eq 1 then begin
			; Use Heliographic coords
			retval = sxi_pix2hel(xv[i],yv[i],pinfo)
			if n_elements(retval) gt 1 then begin
				if abs(retval[0] - 0.) lt .5 then begin
					lat=retval[1] & lon = retval[2]
					if lat ge 0 then ns='N' else ns='S'
					if lon ge 0 then ew='W' else ew='E'
					lat = abs(lat) & lon = abs(lon)
					str = string(format=fmt1,i,ns,lat,ew,lon)
				endif else begin
					pa = retval[1] & rv = retval[2]
					str = string(format=fmt1,i,'PA',pa,'RV',rv)
				endelse
			endif
		endif else begin
			; Use Pixel coords
			fmt = '(I3,1x,I3,1x,I3)'
			str = string(format=fmt,i,xv[i],yv[i])
		endelse
		xycoordStr[i] = str ;strjoin(coord)
	endfor
	zpix = (*pinfo).ftsData[ind]
   	zmean = string(format='(F15.3,A10)',mean(zpix,/double),"mean")
	zmax = string(format='(F15.3,A10)',max(zpix),"max")
	zmin = string(format='(F15.3,A10)',min(zpix),"min")
	zmed = string(format='(F15.3,A10)',median(zpix),"median")
	ztot = string(format='(F15.3,A10)',total(zpix),"total")
	znum = string(format='(F15.3,A10)',n_elements(zpix),"n pts")
	zsdv = string(format='(F15.3,A10)',stddev(zpix,/double),"sigma")
	;nvert = string(format='(F15.3,A10)',nvert,"n vert")
	zxv = "x vertices: "+strjoin(xv)
	zyv = "y vertices: "+strjoin(yv)
	znv = "n vertices: "+string(nvert)
	indStr = strarr(znum)
	indStr = string(ind)
	;dat = (*pinfo).ftsData[ind]
	txtarr = strarr(9)
	txtarr = [zmin,zmax,zmean,zmed,ztot,znum,zsdv,znv,"Vertices:"]
	txtarr = [txtarr,xycoordStr,"Pixel indices:"]
	txtarr = [txtarr,indStr]
	;help,txtarr
	print,'Displaying region stats'
	; Keyword introduced into the XDisplayFile (renamed IDACTextPopUp)
	; of IDL: saveable
	; The '1' in the next call causes the 'Save As..' option to appear
	; as a menu option in the widget that displays the text
	IDACTextPopUp,'dummy.txt',saveable=1,wText=w, text=txtarr,width = 40, $
		group=(*pinfo).idacID, title="Region Statistics", $
		font="Courier*8", ptrInfo=pinfo
	device,set_font="System"


end