diff --git a/deepreg/dataset/loader/grouped_loader.py b/deepreg/dataset/loader/grouped_loader.py
index a8c8eb87..2b08f2c6 100644
--- a/deepreg/dataset/loader/grouped_loader.py
+++ b/deepreg/dataset/loader/grouped_loader.py
@@ -116,7 +116,11 @@ class GroupedDataLoader(AbstractUnpairedDataLoader, GeneratorDataLoader):
         if self.labeled is True:
             image_ids = self.loader_moving_image.get_data_ids()
             label_ids = self.loader_moving_label.get_data_ids()
-            check_difference_between_two_lists(list1=image_ids, list2=label_ids)
+            check_difference_between_two_lists(
+                list1=image_ids,
+                list2=label_ids,
+                name="images and labels in grouped loader",
+            )
 
     def get_intra_sample_indices(self) -> list:
         """
diff --git a/deepreg/dataset/loader/paired_loader.py b/deepreg/dataset/loader/paired_loader.py
index 3346c80a..3c042fa5 100644
--- a/deepreg/dataset/loader/paired_loader.py
+++ b/deepreg/dataset/loader/paired_loader.py
@@ -80,16 +80,22 @@ class PairedDataLoader(AbstractPairedDataLoader, GeneratorDataLoader):
         moving_image_ids = self.loader_moving_image.get_data_ids()
         fixed_image_ids = self.loader_fixed_image.get_data_ids()
         check_difference_between_two_lists(
-            list1=moving_image_ids, list2=fixed_image_ids
+            list1=moving_image_ids,
+            list2=fixed_image_ids,
+            name="moving and fixed images in paired loader",
         )
         if self.labeled:
             moving_label_ids = self.loader_moving_label.get_data_ids()
             fixed_label_ids = self.loader_fixed_label.get_data_ids()
             check_difference_between_two_lists(
-                list1=moving_image_ids, list2=moving_label_ids
+                list1=moving_image_ids,
+                list2=moving_label_ids,
+                name="moving images and labels in paired loader",
             )
             check_difference_between_two_lists(
-                list1=moving_image_ids, list2=fixed_label_ids
+                list1=moving_image_ids,
+                list2=fixed_label_ids,
+                name="fixed images and labels in paired loader",
             )
 
     def sample_index_generator(self):
diff --git a/deepreg/dataset/loader/unpaired_loader.py b/deepreg/dataset/loader/unpaired_loader.py
index bcf8611f..1077193e 100644
--- a/deepreg/dataset/loader/unpaired_loader.py
+++ b/deepreg/dataset/loader/unpaired_loader.py
@@ -73,7 +73,11 @@ class UnpairedDataLoader(AbstractUnpairedDataLoader, GeneratorDataLoader):
         if self.labeled:
             image_ids = self.loader_moving_image.get_data_ids()
             label_ids = self.loader_moving_label.get_data_ids()
-            check_difference_between_two_lists(list1=image_ids, list2=label_ids)
+            check_difference_between_two_lists(
+                list1=image_ids,
+                list2=label_ids,
+                name="images and labels in unpaired loader",
+            )
 
     def sample_index_generator(self):
         """
diff --git a/deepreg/dataset/util.py b/deepreg/dataset/util.py
index c26ed43a..256fff84 100644
--- a/deepreg/dataset/util.py
+++ b/deepreg/dataset/util.py
@@ -3,6 +3,7 @@ Module for IO of files in relation to
 data loading.
 """
 import glob
+import itertools as it
 import os
 import random
 
@@ -44,22 +45,18 @@ def get_sorted_file_paths_in_dir_with_suffix(dir_path: str, suffix: (str, list))
     return sorted(paths)
 
 
-def check_difference_between_two_lists(list1: list, list2: list):
+def check_difference_between_two_lists(list1: list, list2: list, name: str):
     """
     Raise error if two lists are not identical
+
     :param list1: list
     :param list2: list
-    :return: error message if lists are not equal
+    :param name: name to be printed in case of difference
+    :raises ValueError: error showing different pairs of items
     """
-
-    list1_unique = sorted(set(list1) - set(list2))
-    list2_unique = sorted(set(list2) - set(list1))
-    if len(list2_unique) != 0 or len(list1_unique) != 0:
-        raise ValueError(
-            "two lists are not identical\n"
-            "list1 has unique elements {}\n"
-            "list2 has unique elements {}\n".format(list1_unique, list2_unique)
-        )
+    diff = [(x, y) for x, y in it.zip_longest(list1, list2) if x != y]
+    if len(diff) > 0:
+        raise ValueError(f"{name} are not identical\n" f"difference are {diff}\n")
 
 
 def get_label_indices(num_labels: int, sample_label: str) -> list:

Wrong message when labels and images names do not match
# Issue description

If the names of the images and the labels do not match (e.g., image0001.nii.gz and label0001.nii.gz) the following Tensorflow error is raised:

"WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 2 batches)."

This is very confusing as one would think that the problem is with the quantity of images instead of the file names.

Could a better error message be shown to point to the documentation?


## Type of Issue

Please delete options that are not relevant.

- [ ] Bug report
- [X] New feature request
- [ ] Documentation update
- [ ] Test request
- [ ] Linting request

#### For bug report or feature request, steps to reproduce the issue, including (but not limited to):

1. OS
2. Environment to reproduce
3. What commands run / sample script used:

#### What's the expected result?

Could a better error message be shown to point to the documentation?

#### What's the actual result?

"WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 2 batches)."

#### Additional details / screenshot

## -

diff --git a/test/unit/test_dataset_util.py b/test/unit/test_dataset_util.py
index 58d76885..470c5e7f 100644
--- a/test/unit/test_dataset_util.py
+++ b/test/unit/test_dataset_util.py
@@ -114,29 +114,34 @@ def test_get_sorted_file_paths_in_dir_with_suffix():
         assert expected == actual
 
 
-def test_difference_lists_same():
+def test_check_difference_between_two_lists():
     """
-    Check ValueError not raised if lists same
+    Check check_difference_between_two_lists by verifying ValueError
     """
-    list_1 = list_2 = [0, 1, 2]
-    util.check_difference_between_two_lists(list_1, list_2)
+    # same lists, no error
+    list1 = list2 = [0, 1, 2]
+    util.check_difference_between_two_lists(list1, list2, name="same case")
 
+    # diff lists with same unique numbers
+    list_1 = [0, 1, 2]
+    list_2 = [1, 2, 0]
+    with pytest.raises(ValueError) as err_info:
+        util.check_difference_between_two_lists(list_1, list_2, name="diff case")
+    assert "diff case are not identical" in str(err_info.value)
 
-def test_difference_lists_different():
-    """
-    Assert ValueError raised if two lists not identical
-    """
+    # totally diff lists
     list_1 = [0, 1, 2]
     list_2 = [3, 4, 5]
-    with pytest.raises(ValueError):
-        util.check_difference_between_two_lists(list_1, list_2)
+    with pytest.raises(ValueError) as err_info:
+        util.check_difference_between_two_lists(list_1, list_2, name="diff case")
+    assert "diff case are not identical" in str(err_info.value)
 
 
 def test_label_indices_sample():
     """
     Assert random number for passed arg returned
     """
-    expected = set([0, 1, 2, 3])
+    expected = {0, 1, 2, 3}
     actual = util.get_label_indices(4, "sample")
     assert expected.intersection(set(actual))
 

pip install -e .
parse_log_pytest
requirements.txt
pytest
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
absl-py==2.1.0
alabaster==0.7.13
anyio==3.7.1
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
aspy.refactor-imports==3.0.2
astunparse==1.6.3
attrs==24.2.0
Babel==2.14.0
backcall==0.2.0
beautifulsoup4==4.13.3
black==23.3.0
bleach==6.0.0
cached-property==1.5.2
cachetools==4.2.4
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
cfgv==3.3.1
charset-normalizer==3.4.1
click==8.1.8
coverage==7.2.7
cycler==0.11.0
debugpy==1.7.0
decorator==5.1.1
-e git+https://github.com/DeepRegNet/DeepReg.git@3bb693edcc396dbb5147fec3da7a8a9caec3b6d0#egg=deepreg
defusedxml==0.7.1
distlib==0.3.9
docutils==0.18.1
entrypoints==0.4
exceptiongroup==1.2.2
fastjsonschema==2.21.1
filelock==3.12.2
flake8==5.0.4
fonttools==4.38.0
gast==0.3.3
google-auth==1.35.0
google-auth-oauthlib==0.4.6
google-pasta==0.2.0
grpcio==1.62.3
h5py==2.10.0
identify==2.5.24
idna==3.10
imagesize==1.4.1
importlib-metadata==4.2.0
importlib-resources==5.12.0
iniconfig==2.0.0
ipykernel==6.16.2
ipython==7.34.0
ipython-genutils==0.2.0
isort==5.11.5
jedi==0.19.2
Jinja2==3.1.6
jsonschema==4.17.3
jupyter-server==1.24.0
jupyter_client==7.4.9
jupyter_core==4.12.0
jupyterlab-pygments==0.2.2
Keras-Preprocessing==1.1.2
kiwisolver==1.4.5
lxml==5.3.1
m2r2==0.3.2
Markdown==3.3.4
MarkupSafe==2.1.5
matplotlib==3.5.3
matplotlib-inline==0.1.6
mccabe==0.7.0
mistune==0.8.4
mypy-extensions==1.0.0
nbclassic==1.2.0
nbclient==0.7.4
nbconvert==6.5.4
nbformat==5.8.0
nest-asyncio==1.6.0
nibabel==4.0.2
nodeenv==1.9.1
notebook==6.5.7
notebook_shim==0.2.4
numpy==1.21.6
oauthlib==3.2.2
opt-einsum==3.3.0
packaging==24.0
pandas==1.3.5
pandocfilters==1.5.1
parso==0.8.4
pathspec==0.11.2
pexpect==4.9.0
pickleshare==0.7.5
Pillow==9.5.0
pkgutil_resolve_name==1.3.10
platformdirs==2.6.2
pluggy==1.2.0
pre-commit==2.21.0
prometheus-client==0.17.1
prompt_toolkit==3.0.48
protobuf==4.24.4
psutil==7.0.0
ptyprocess==0.7.0
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycodestyle==2.9.1
pycparser==2.21
pyflakes==2.5.0
Pygments==2.17.2
pyparsing==3.1.4
pyrsistent==0.19.3
pytest==7.4.4
pytest-cov==4.1.0
pytest-dependency==0.6.0
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.1
pyzmq==26.2.1
requests==2.31.0
requests-oauthlib==2.0.0
rsa==4.9
scipy==1.4.1
seed-isort-config==2.2.0
Send2Trash==1.8.3
simple_http_server==0.22.3
six==1.17.0
sniffio==1.3.1
snowballstemmer==2.2.0
soupsieve==2.4.1
Sphinx==3.2.1
sphinx-notfound-page==0.8.3
sphinx-rtd-theme==1.3.0
sphinx-tabs==3.4.7
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
tensorboard==2.2.2
tensorboard-plugin-wit==1.8.1
tensorflow==2.2.0
tensorflow-estimator==2.2.0
termcolor==2.3.0
terminado==0.17.1
testfixtures==8.3.0
tinycss2==1.2.1
tomli==2.0.1
tornado==6.2
tqdm==4.67.1
traitlets==5.9.0
typed-ast==1.5.5
typing_extensions==4.7.1
urllib3==2.0.7
virtualenv==20.16.2
wcwidth==0.2.13
webencodings==0.5.1
websocket-client==1.6.1
Werkzeug==2.2.3
wrapt==1.16.0
zipp==3.15.0

name: DeepReg
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - absl-py==2.1.0
      - alabaster==0.7.13
      - anyio==3.7.1
      - argon2-cffi==23.1.0
      - argon2-cffi-bindings==21.2.0
      - argparse==1.4.0
      - aspy-refactor-imports==3.0.2
      - astunparse==1.6.3
      - attrs==24.2.0
      - babel==2.14.0
      - backcall==0.2.0
      - beautifulsoup4==4.13.3
      - black==23.3.0
      - bleach==6.0.0
      - cached-property==1.5.2
      - cachetools==4.2.4
      - cffi==1.15.1
      - cfgv==3.3.1
      - charset-normalizer==3.4.1
      - click==8.1.8
      - coverage==7.2.7
      - cycler==0.11.0
      - debugpy==1.7.0
      - decorator==5.1.1
      - deepreg==0.0.1
      - defusedxml==0.7.1
      - distlib==0.3.9
      - docutils==0.18.1
      - entrypoints==0.4
      - exceptiongroup==1.2.2
      - fastjsonschema==2.21.1
      - filelock==3.12.2
      - flake8==5.0.4
      - fonttools==4.38.0
      - gast==0.3.3
      - google-auth==1.35.0
      - google-auth-oauthlib==0.4.6
      - google-pasta==0.2.0
      - grpcio==1.62.3
      - h5py==2.10.0
      - identify==2.5.24
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.2.0
      - importlib-resources==5.12.0
      - iniconfig==2.0.0
      - ipykernel==6.16.2
      - ipython==7.34.0
      - ipython-genutils==0.2.0
      - isort==5.11.5
      - jedi==0.19.2
      - jinja2==3.1.6
      - jsonschema==4.17.3
      - jupyter-client==7.4.9
      - jupyter-core==4.12.0
      - jupyter-server==1.24.0
      - jupyterlab-pygments==0.2.2
      - keras-preprocessing==1.1.2
      - kiwisolver==1.4.5
      - lxml==5.3.1
      - m2r2==0.3.2
      - markdown==3.3.4
      - markupsafe==2.1.5
      - matplotlib==3.5.3
      - matplotlib-inline==0.1.6
      - mccabe==0.7.0
      - mistune==0.8.4
      - mypy-extensions==1.0.0
      - nbclassic==1.2.0
      - nbclient==0.7.4
      - nbconvert==6.5.4
      - nbformat==5.8.0
      - nest-asyncio==1.6.0
      - nibabel==4.0.2
      - nodeenv==1.9.1
      - notebook==6.5.7
      - notebook-shim==0.2.4
      - numpy==1.21.6
      - oauthlib==3.2.2
      - opt-einsum==3.3.0
      - packaging==24.0
      - pandas==1.3.5
      - pandocfilters==1.5.1
      - parso==0.8.4
      - pathspec==0.11.2
      - pexpect==4.9.0
      - pickleshare==0.7.5
      - pillow==9.5.0
      - pkgutil-resolve-name==1.3.10
      - platformdirs==2.6.2
      - pluggy==1.2.0
      - pre-commit==2.21.0
      - prometheus-client==0.17.1
      - prompt-toolkit==3.0.48
      - protobuf==4.24.4
      - psutil==7.0.0
      - ptyprocess==0.7.0
      - pyasn1==0.5.1
      - pyasn1-modules==0.3.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pyflakes==2.5.0
      - pygments==2.17.2
      - pyparsing==3.1.4
      - pyrsistent==0.19.3
      - pytest==7.4.4
      - pytest-cov==4.1.0
      - pytest-dependency==0.6.0
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyyaml==6.0.1
      - pyzmq==26.2.1
      - requests==2.31.0
      - requests-oauthlib==2.0.0
      - rsa==4.9
      - scipy==1.4.1
      - seed-isort-config==2.2.0
      - send2trash==1.8.3
      - simple-http-server==0.22.3
      - six==1.17.0
      - sniffio==1.3.1
      - snowballstemmer==2.2.0
      - soupsieve==2.4.1
      - sphinx==3.2.1
      - sphinx-notfound-page==0.8.3
      - sphinx-rtd-theme==1.3.0
      - sphinx-tabs==3.4.7
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jquery==4.1
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - tensorboard==2.2.2
      - tensorboard-plugin-wit==1.8.1
      - tensorflow==2.2.0
      - tensorflow-estimator==2.2.0
      - termcolor==2.3.0
      - terminado==0.17.1
      - testfixtures==8.3.0
      - tinycss2==1.2.1
      - tomli==2.0.1
      - tornado==6.2
      - tqdm==4.67.1
      - traitlets==5.9.0
      - typed-ast==1.5.5
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - virtualenv==20.16.2
      - wcwidth==0.2.13
      - webencodings==0.5.1
      - websocket-client==1.6.1
      - werkzeug==2.2.3
      - wrapt==1.16.0
      - zipp==3.15.0
prefix: /opt/conda/envs/DeepReg

test/unit/test_dataset_util.py::test_check_difference_between_two_lists
test/unit/test_dataset_util.py::test_sorted_h5_keys test/unit/test_dataset_util.py::test_sorted_h5_keys_many test/unit/test_dataset_util.py::test_get_sorted_file_paths_in_dir_with_suffix test/unit/test_dataset_util.py::test_label_indices_sample test/unit/test_dataset_util.py::test_label_indices_first test/unit/test_dataset_util.py::test_label_indices_all test/unit/test_dataset_util.py::test_label_indices_unknown
deepreg/dataset/loader/paired_loader.py deepreg/dataset/util.py deepreg/dataset/loader/grouped_loader.py deepreg/dataset/loader/unpaired_loader.py
deepreg/dataset/loader/paired_loader.py deepreg/dataset/util.py deepreg/dataset/loader/grouped_loader.py deepreg/dataset/loader/unpaired_loader.py