Thanks, this was a great help and I have it working more or less...
My case was a bit more complicated because I'm pairing positive or negative images with a third set of neutral images, but I was able to get that working based on your model.
The only thing I still haven't figured out (which isn't terribly important, but...) is whether it's possible to do this where the number of neutral images is larger than the number of positive or negative images (e.g. one of 6 positive images is paired with one of 12 neutral images drawn from a larger pool, and similar for 6 negative images). When I try this the program crashes, I think because the way the code is written it looks for a corresponding item number, and there are no number 7-12 of the positive and negative images.
Again, with your help I got the basics of what I need, so unless there is an obvious way to do the above, let's consider my problem solved!