Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
Unreleased
==========
``tfmgr sanitize`` becomes a linter, and ``tfmgr add`` stops changing data silently.

* ``tfmgr sanitize`` reports the image rules (TF701 to TF711) and fixes what it can:
``--check`` (the default) lists the problems, ``--fix`` applies the safe fixes (values
and world coordinates kept), ``--fix-unsafe`` also those that rescale, round or move.
The silent int16 cast, probseg rescaling and intensity normalization are gone (the
latter for good), and the swapped ``--force-dtype``/``--deoblique`` options with them.
* New rules: TF707 not-ras, TF708 oblique, TF709 storage-dtype, TF710 image-units and
TF711 unreadable-image. Issues say whether ``--fix`` or ``--fix-unsafe`` corrects them.
* ``tfmgr add`` copies the template without changing it, validates it strictly (images
included) before uploading anything, and records each step in a work directory
(``--workdir``, by default in the user cache directory), so a failed run resumes where
it stopped. Failing commands stop it. It reconfigures existing GIN and GitHub
siblings instead of replacing them, opens the pull request with ``gh`` (``hub`` is no
longer needed), names the intake file ``tpl-<ID>.toml``, honours ``--nprocs``, asks
for an SPDX license identifier, and writes the ``SPDX-License-Identifier`` header.

26.0.0rc1 (December 2, 2026)
============================
TemplateFlow 2.0 rule set and validator.

* New ``tfmgr validate`` checks templates (directories, Archive checkouts or skeleton zips)
Expand Down
34 changes: 33 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,36 @@ and values are only checked with ``--level content``, which needs ``tfmanager[co
and the images' data. The command exits with 1 when there are errors, and 2 when it
could not run.

Adding a template needs DataLad and the TemplateFlow client: ``pip install tfmanager[add]``.
Checking and fixing images
--------------------------
``tfmgr sanitize`` works like a linter on the images of a template (rules TF701 to
TF711; needs ``tfmanager[content]``)::

tfmgr sanitize tpl-MyTemplate # --check (the default): list the problems
tfmgr sanitize --fix tpl-MyTemplate # apply the safe fixes
tfmgr sanitize --fix-unsafe tpl-MyTemplate # apply all of them

Safe fixes keep the values and the world coordinates of every voxel: reorienting to RAS,
setting unset units to mm, storing labels as the smallest unsigned integer type, and
integer-valued images as int16. Unsafe fixes change values or move the image: rescaling
probabilities into [0, 1], removing the rotation of oblique images, setting the qform to
the sform when they disagree, and storing floating-point images as int16 with a slope and
an intercept. When a fix moves the grid of every image of a resolution, the ``res`` block
of template_description.json is updated to match. Annexed images are replaced by regular
files (``datalad save`` annexes them again).

Adding a template
-----------------
Adding a template needs DataLad, the GitHub CLI (``gh``) and the TemplateFlow client:
``pip install tfmanager[add]``::

tfmgr add MyTemplate --path tpl-MyTemplate

``tfmgr add`` asks for the metadata that template_description.json misses (with an SPDX
license identifier), copies the template into a DataLad dataset without changing it
(``--fix`` and ``--fix-unsafe`` apply ``tfmgr sanitize`` fixes to the copies), and checks
it with ``tfmgr validate --mode strict --level content``: errors stop it before anything
is uploaded. The data then go to GIN, the dataset to GitHub, and a pull request proposes
the template to the Archive. Each step is recorded in a work directory (by default in
the user's cache directory; ``--workdir`` sets another one), so a run that fails resumes
where it stopped; ``--restart`` starts again.
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ quote-style = "single"

[tool.ruff.lint]
select = ["E", "F", "W", "I", "UP", "B"]
# cli.py, io.py and utils.py predate the linter
per-file-ignores = { "{setup.py,tfmanager/cli.py,tfmanager/io.py,tfmanager/utils.py}" = ["E", "W", "I", "UP", "B"] }

# setup.py predates the linter
[tool.ruff.lint.per-file-ignores]
"setup.py" = ["E", "W", "I", "UP", "B"]
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ add =
datalad >= 0.16
nibabel
numpy
platformdirs
templateflow >= 0.4.2
content =
nibabel
Expand Down
Loading