Displaying images from a matrix field from a related field
Relationship field is defined like:

{% for relatedItem in entry.relatedItemField %}
  {{ relatedItem.someField }} {{ relatedItem.someOtherField }}    
{% endfor %}


So maybe:

{% if entry.associatedGallery | length %}
    {% for theGallery in entry.associatedGallery %}
        {% for matrixBlock in theGallery.albumImages %}
            {% if matrixBlock.imageFile | length %}
                {% for asset in matrixBlock.imageFile.first() %}
                    &lt;a href="{{ asset.getUrl() }}"&gt;&lt;img src="{{ asset.getUrl('homeThumb') }}" data-title="{{ matrixBlock.imageName }}"&gt;&lt;/a&gt;
                {% endfor %}
            {% endif %}
        {% endfor %}
    {% endfor %}
{% endif %}