I have not been able to find a satisfactory answer regarding rules about this issue. What I have heard are lots of opinions:
Here is a picture of my house, which I like very much.
Here is a picture of my house that I like very much.
In the second example, that clearly refers to the subject of the main clause, since we could omit it and it would still mean the same thing:
Here is a picture of my house I like very much.
In the first example, is there any rule about what which refers to? There is some ambiguity otherwise.