%global srcname TractSeg Name: python-tractseg Version: 2.10 Release: 1%{?dist} Summary: Segmentation of white matter bundles from diffusion MRI License: Apache-2.0 URL: https://github.com/MIC-DKFZ/TractSeg # The GitHub tag carries tests/ and its reference data; the sdist does not. Source0: %{url}/archive/v%{version}/%{srcname}-%{version}.tar.gz # Tracking and fibre compression hand work to multiprocessing.Pool workers that # read module globals, which only a forked child inherits. Python 3.14 made # forkserver the default start method on Linux, so every worker saw None and # Tracking died with "'NoneType' object is not subscriptable". Ask for fork. Patch0: python-tractseg-fork-pool.patch BuildArch: noarch BuildRequires: python3-devel BuildRequires: pyproject-rpm-macros BuildRequires: python3dist(pytest) BuildRequires: python3dist(torch) BuildRequires: python3dist(pandas) BuildRequires: python3dist(batchgenerators) BuildRequires: xorg-x11-server-Xvfb %global _description %{expand: TractSeg segments 72 white matter tracts directly from the fibre orientation distribution function peaks of a diffusion MRI scan, using fully convolutional networks. It also produces bundle start and end regions and tract orientation maps, runs bundle-specific tractography from them, and computes tractometry along each bundle with group statistics and plots. The trained networks (about 150 MB each, CC BY 4.0, Zenodo) are not part of this package: TractSeg downloads the ones a run needs into ~/.tractseg, or into $TRACTSEG_WEIGHTS_DIR when that is set. download_all_pretrained_weights fetches them all in advance.} %description %_description %package -n python3-tractseg Summary: %{summary} # Not declared in setup.py, which leaves the PyTorch install to the user. Requires: python3dist(torch) # Nor is batchgenerators, which the training data loaders (ExpRunner) import. Requires: python3dist(batchgenerators) # plot_tractometry_results always starts an Xvfb through xvfbwrapper (for its # optional VTK 3D panel), and python3-xvfbwrapper does not pull Xvfb in. Requires: xorg-x11-server-Xvfb %description -n python3-tractseg %_description %prep %autosetup -p1 -n %{srcname}-%{version} # future is a Python 2 backport: the two `from builtins import object` lines # resolve to the standard library on Python 3. six is declared but not imported # anywhere. sed -i -e "/'future',/d" -e "/'six',/d" setup.py ! grep -rqE '^\s*(import six|from six|from future|from past)' tractseg bin # find_packages() would install the test suite as a top-level "tests" package. sed -i 's/packages=find_packages(),/packages=find_packages(exclude=["tests", "tests.*"]),/' setup.py grep -q 'exclude=\["tests"' setup.py %py3_shebang_fix bin %generate_buildrequires %pyproject_buildrequires %build %pyproject_wheel %install %pyproject_install %pyproject_save_files tractseg %check # tractseg.libs.vtk_utils / plot_utils import fury, VTK and a display only # inside the 3D rendering functions; the modules themselves import cleanly. # create_endpoints_mask_with_clustering is a script that reads sys.argv at # import time. %pyproject_check_import -e tractseg.libs.create_endpoints_mask_with_clustering export PATH=%{buildroot}%{_bindir}:$PATH export PYTHONPATH=%{buildroot}%{python3_sitelib} export HOME=$PWD/home mkdir -p $HOME # Everything below runs without the network weights. Upstream's tests.sh runs # these steps after TractSeg itself; here TractSeg's output is replaced by the # reference outputs shipped in tests/reference_files. # # 1. Bundle-specific tracking from the reference tract orientation maps, # endings and bundle masks, then tractometry against upstream's reference # profile (a stochastic comparison with upstream's tolerance). out=examples/tractseg_output mkdir -p $out for d in TOM endings_segmentations bundle_segmentations; do ln -s $PWD/tests/reference_files/$d $out/$d done Tracking -i tests/reference_files/peaks.nii.gz -o $out --nr_fibers 10000 --test 3 Tractometry -i $out/TOM_trackings -o examples/Tractometry.csv \ -e $out/endings_segmentations/ -s tests/reference_files/FA.nii.gz --test 3 # 2. Tractometry on generated toy streamlines (exact). mkdir -p tractometry_toy_example %{python3} tests/reference_files/create_toy_streamlines.py tractometry_toy_example Tractometry -i tractometry_toy_example/TOM_trackings -o tractometry_toy_example/Tractometry.csv \ -e tractometry_toy_example/endings_segmentations/ -s tractometry_toy_example/toy_FA.nii.gz \ --test 2 --nr_points 10 --tracking_format tck # 3. Group and correlation statistics over the reference tractometry profiles. export MPLBACKEND=Agg plot_tractometry_results -i tests/reference_files/subjects_group.txt \ -o examples/tractometry_result_group.png --mc --save_csv plot_tractometry_results -i tests/reference_files/subjects_correlation.txt \ -o examples/tractometry_result_correlation.png --mc --save_csv %pytest -v tests/test_functions.py \ tests/test_end_to_end.py::test_end_to_end::test_tractometry \ tests/test_end_to_end.py::test_end_to_end::test_tractometry_toy_example \ tests/test_end_to_end.py::test_end_to_end::test_statistical_analysis_group \ tests/test_end_to_end.py::test_end_to_end::test_statistical_analysis_correlation %files -n python3-tractseg -f %{pyproject_files} %license LICENSE %doc Readme.md CHANGELOG.md %{_bindir}/TractSeg %{_bindir}/ExpRunner %{_bindir}/flip_peaks %{_bindir}/calc_FA %{_bindir}/Tractometry %{_bindir}/download_all_pretrained_weights %{_bindir}/Tracking %{_bindir}/rotate_bvecs %{_bindir}/plot_tractometry_results %{_bindir}/get_image_spacing %{_bindir}/remove_negative_values %changelog * Fri Oct 16 2026 Morgan Hough - 2.10-1 - Initial package. The CC BY 4.0 weights stay a first-use download. - Tracking and fibre compression use a fork-context Pool (Python 3.14 made forkserver the default and the workers lost their module globals).