From 9805f6e1a4905dd991bbf41471747b227d34651a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Sat, 5 Jul 2025 17:30:33 -0400 Subject: [PATCH] ENH: Use appropriate message when reporting TCK `file` attribute error Use appropriate message when reporting `file` attribute error in TCK: the previous message was mistakenly reporting the non-existence of the `file` attribute, which indeed has to exist to be able to do the `hdr['file']` without getting a `KeyError`. This patch set uses the message that was not being used when the check was not being successful. --- nibabel/streamlines/tck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nibabel/streamlines/tck.py b/nibabel/streamlines/tck.py index 358c57936..0b4a941c3 100644 --- a/nibabel/streamlines/tck.py +++ b/nibabel/streamlines/tck.py @@ -385,7 +385,7 @@ def _read_header(cls, fileobj): 'TCK only supports single-file - in other words the filename part must be ' f"specified as '.' but '{hdr['file'].split()[0]}' was specified." ) - raise HeaderError("Missing 'file' attribute in TCK header.") + raise HeaderError(msg) # Set endianness and _dtype attributes in the header. hdr[Field.ENDIANNESS] = '>' if hdr['datatype'].endswith('BE') else '<'