ImagePlus showDialog(String title) {
		int[] wList = WindowManager.getIDList();
		if (wList==null) {
			IJ.noImage();
			return null;
		}

		String[] titles = new String[wList.length];
		int n = titles.length;
		if (n == 1) {
			IJ.showMessage("No image to insert.  Open a second image first, or use Insert File or Paste.");
			return null;
		}

		for (int i=0; i<wList.length; i++) {
			ImagePlus imp = WindowManager.getImage(wList[i]);
			titles[i] = imp!=null?imp.getTitle():"";
		}
		String[] titles1 = new String[n-1];
		int[] wList1 = new int[n-1];
		int ind = 0;
		for (int i = 0; i < n; i++){
			if(!title.equals(titles[i])){
				titles1[ind] = titles[i];
				wList1[ind++] = wList[i];
			}
		}
		if(ind != (n-1)){
			IJ.showMessage("The window titles need to be unique for the insert operation to work.");
			return null;
		}
		if(titles1.length==1)return WindowManager.getImage(wList1[0]);
		GenericDialog gd = new GenericDialog("Choose Image");
		gd.addChoice("Image to insert in stack:", titles1, titles1[0]);
		gd.showDialog();
		if (gd.wasCanceled())
			return null;
		int index = gd.getNextChoiceIndex();
		return WindowManager.getImage(wList1[index]);
	}