# FastSurfer: deep-learning whole-brain segmentation (FastSurferVINN), plus the # CerebNet (cerebellum), HypVINN (hypothalamus) and FastSurfer-CC (corpus callosum) # networks, from Deep-MI. This package is the Python code and the trained networks. # # Not here: recon-surf, FastSurfer's surface pipeline. It runs FreeSurfer 8.2 binaries # and needs a FreeSurfer licence key, so it belongs with freesurfer8 in # neurofedora-nonfree. The recon_surf Python package is still installed (it is in # upstream's wheel), but nothing here can run it without FreeSurfer. # # The trained checkpoints are not in the source tarball; upstream downloads them on # first use. They are on Zenodo under free licences (Apache-2.0: FastSurferVINN; # CC-BY-4.0: CerebNet, HypVINN), so they ship here as noarch data # subpackages under %%{_datadir}/fastsurfer/checkpoints, and Patch0 makes the code # look there, then in the per-user cache, instead of beside its own sources. %global pypi_name fastsurfer %global ckpt_dir %{_datadir}/fastsurfer Name: python-%{pypi_name} Version: 2.6.0 Release: 1%{?dist} Summary: Deep-learning neuroimaging segmentation (FastSurferVINN, CerebNet, HypVINN) License: Apache-2.0 URL: https://github.com/Deep-MI/FastSurfer Source0: %{url}/archive/v%{version}/FastSurfer-%{version}.tar.gz # FastSurferVINN, Zenodo record 10390573 (v2.0.0), Apache-2.0 Source10: https://zenodo.org/records/10390573/files/aparc_vinn_axial_v2.0.0.pkl Source11: https://zenodo.org/records/10390573/files/aparc_vinn_coronal_v2.0.0.pkl Source12: https://zenodo.org/records/10390573/files/aparc_vinn_sagittal_v2.0.0.pkl # CerebNet, Zenodo record 10390742 (v1.0.0), CC-BY-4.0 Source13: https://zenodo.org/records/10390742/files/CerebNet_axial_v1.0.0.pkl Source14: https://zenodo.org/records/10390742/files/CerebNet_coronal_v1.0.0.pkl Source15: https://zenodo.org/records/10390742/files/CerebNet_sagittal_v1.0.0.pkl # HypVINN, Zenodo record 11184216 (v1.1.0), CC-BY-4.0 Source16: https://zenodo.org/records/11184216/files/HypVINN_axial_v1.1.0.pkl Source17: https://zenodo.org/records/11184216/files/HypVINN_coronal_v1.1.0.pkl Source18: https://zenodo.org/records/11184216/files/HypVINN_sagittal_v1.1.0.pkl # FastSurfer-CC's checkpoints (Zenodo 17141933, Apache-2.0) are not shipped yet: the # CC code needs meshpy and neuroreg, which are not packaged. # Zenodo's MD5s for Source10-18, checked in %%prep. Source30: python-fastsurfer-checkpoints.md5 # Resolve "checkpoints/..." through one helper: FASTSURFER_CHECKPOINT_ROOT (this # package sets its default to %%{ckpt_dir} in %%prep), then the per-user cache # $XDG_CACHE_HOME/fastsurfer, where missing checkpoints are also downloaded. Upstream # resolved them against the source tree, which is site-packages once installed. Patch0: python-fastsurfer-checkpoint-root.patch BuildArch: noarch BuildRequires: python3-devel BuildRequires: python3dist(setuptools) >= 61 # %%check imports the segmentation path. BuildRequires: python3dist(torch) BuildRequires: python3dist(torchvision) BuildRequires: python3dist(numpy) BuildRequires: python3dist(nibabel) BuildRequires: python3dist(scipy) BuildRequires: python3dist(scikit-image) BuildRequires: python3dist(h5py) BuildRequires: python3dist(pyyaml) BuildRequires: python3dist(yacs) BuildRequires: python3dist(simpleitk) BuildRequires: python3dist(pandas) BuildRequires: python3dist(matplotlib) BuildRequires: python3dist(requests) BuildRequires: python3dist(tqdm) BuildRequires: python3dist(scikit-learn) BuildRequires: python3dist(monai) BuildRequires: python3dist(lapy) %global _description %{expand: FastSurfer is a deep-learning pipeline for brain MRI. FastSurferVINN segments a T1-weighted image into the DKT cortical parcellation and subcortical structures in minutes on a CPU, and seconds on a GPU. CerebNet adds a cerebellum sub-segmentation, HypVINN a hypothalamus sub-segmentation, and FastSurfer-CC corpus callosum segmentation and morphometry.} %description %_description %package -n python3-%{pypi_name} Summary: %{summary} # The networks, installed by default but separable: without them, FastSurfer # downloads the checkpoints it needs into ~/.cache/fastsurfer on first use. Recommends: %{name}-checkpoints-vinn = %{version}-%{release} Recommends: %{name}-checkpoints-cerebnet = %{version}-%{release} Recommends: %{name}-checkpoints-hypvinn = %{version}-%{release} %description -n python3-%{pypi_name} %_description The fastsurfer-seg command runs the FastSurferVINN segmentation (FastSurferCNN/run_prediction.py). FastSurfer-CC (corpus callosum) also needs meshpy, neuroreg and pyrr, and training needs tensorboard and torchio; none of them is packaged yet, and neither are the FastSurfer-CC checkpoints. recon-surf (surfaces) needs FreeSurfer and is not part of this package. %package checkpoints-vinn Summary: FastSurferVINN trained networks (whole-brain segmentation) License: Apache-2.0 Requires: python3-%{pypi_name} = %{version}-%{release} %description checkpoints-vinn The axial, coronal and sagittal FastSurferVINN checkpoints (v2.0.0, Zenodo record 10390573) that FastSurfer's default segmentation uses. %package checkpoints-cerebnet Summary: CerebNet trained networks (cerebellum sub-segmentation) License: CC-BY-4.0 Requires: python3-%{pypi_name} = %{version}-%{release} %description checkpoints-cerebnet The axial, coronal and sagittal CerebNet checkpoints (v1.0.0, Zenodo record 10390742). Henschel et al., NeuroImage 2022. %package checkpoints-hypvinn Summary: HypVINN trained networks (hypothalamus sub-segmentation) License: CC-BY-4.0 Requires: python3-%{pypi_name} = %{version}-%{release} %description checkpoints-hypvinn The axial, coronal and sagittal HypVINN checkpoints (v1.1.0, Zenodo record 11184216). Estrada et al., Imaging Neuroscience 2023. %prep %autosetup -p1 -n FastSurfer-%{version} # The checkpoint files are what Zenodo lists for each record. (cd %{_sourcedir} && md5sum --quiet -c %{SOURCE30}) # Default checkpoint root: this package's data directory. sed -i 's|os.environ.get("FASTSURFER_CHECKPOINT_ROOT", str(FASTSURFER_ROOT))|os.environ.get("FASTSURFER_CHECKPOINT_ROOT", "%{ckpt_dir}")|' \ FastSurferCNN/utils/parser_defaults.py grep -q '"FASTSURFER_CHECKPOINT_ROOT", "%{ckpt_dir}"' FastSurferCNN/utils/parser_defaults.py \ || { echo "ERROR: checkpoint root default not set" >&2; exit 1; } # Requirements, to what Fedora has and the installed code needs: # - torch==2.14.* and torchvision>=0.29,<0.30 pin upstream's container build, not an # API (2.4.x required torch>=2.0.1; there is no runtime version check). Fedora 44 # has torch 2.9.1, which runs the full segmentation (see %%changelog). # - libigl (recon-surf's cortical ribbon, recon_surf/volmask.py), meshpy, pyrr # (FastSurfer-CC), neuroreg (registration, eTIV) and tensorboard, torchio (training) # are not packaged; the segmentation path does not import them. # - pip is a packaging-tool requirement of upstream's environment, not of the code. %{python3} - <<'EOF' import re p = "pyproject.toml" s = open(p).read() drop = ("libigl", "meshpy", "neuroreg", "pyrr", "tensorboard", "torchio", "pip") relax = {"torch": "torch", "torchvision": "torchvision"} out, done = [], set() for line in s.splitlines(keepends=True): m = re.match(r"^(\s*)'([A-Za-z0-9_.-]+)[^']*',.*$", line) if m and m.group(2) in drop: done.add(m.group(2)) continue if m and m.group(2) in relax: line = f"{m.group(1)}'{relax[m.group(2)]}',\n" done.add(m.group(2)) out.append(line) missing = (set(drop) | set(relax)) - done if missing: raise SystemExit(f"pyproject.toml: requirement lines not found: {sorted(missing)}") open(p, "w").write("".join(out)) print("requirements: dropped", sorted(drop), "unpinned", sorted(relax)) EOF %generate_buildrequires %pyproject_buildrequires %build %pyproject_wheel %install %pyproject_install %pyproject_save_files FastSurferCNN CerebNet CorpusCallosum HypVINN recon_surf install -d %{buildroot}%{ckpt_dir}/checkpoints for s in %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14} %{SOURCE15} \ %{SOURCE16} %{SOURCE17} %{SOURCE18}; do install -p -m 0644 "$s" %{buildroot}%{ckpt_dir}/checkpoints/ done # Segmentation entry point; upstream calls the script by path from run_fastsurfer.sh. install -d %{buildroot}%{_bindir} cat > %{buildroot}%{_bindir}/fastsurfer-seg <<'EOF' #!/bin/sh # FastSurferVINN segmentation (FastSurferCNN/run_prediction.py). See --help. exec /usr/bin/python3 -m FastSurferCNN.run_prediction "$@" EOF chmod 0755 %{buildroot}%{_bindir}/fastsurfer-seg %check # Every module imports except these, measured: FastSurfer-CC's five need meshpy or # neuroreg, train/run_model need tensorboard, and recon_surf is FreeSurfer-pipeline # scripts importing each other by flat name. %pyproject_check_import -e 'recon_surf*' -e FastSurferCNN.train -e FastSurferCNN.run_model -e CorpusCallosum.cc_visualization -e CorpusCallosum.data.fsaverage_cc_template -e CorpusCallosum.fastsurfer_cc -e CorpusCallosum.registration.midsagittal_plane_alignment -e 'CorpusCallosum.shape*' # Checkpoint paths resolve to the system directory, then the user cache. export PYTHONPATH=%{buildroot}%{python3_sitelib} FASTSURFER_CHECKPOINT_ROOT=%{buildroot}%{ckpt_dir} XDG_CACHE_HOME=/nonexistent %{python3} - <<'EOF' from pathlib import Path from FastSurferCNN.utils.parser_defaults import resolve_fastsurfer_path from FastSurferCNN.utils.checkpoint import load_checkpoint_config_defaults, get_config_file ckpts = load_checkpoint_config_defaults("checkpoint", filename=get_config_file("FastSurferCNN")) for plane, rel in ckpts.items(): p = resolve_fastsurfer_path(rel) assert p.is_file() and "%{ckpt_dir}" in str(p), (plane, p) missing = resolve_fastsurfer_path("checkpoints/not-shipped.pkl") assert missing == Path("/nonexistent/fastsurfer/checkpoints/not-shipped.pkl"), missing print("checkpoint resolution OK:", sorted(ckpts)) EOF %{buildroot}%{_bindir}/fastsurfer-seg --help >/dev/null %files -n python3-%{pypi_name} -f %{pyproject_files} %license LICENSE %doc README.md notice.txt %{_bindir}/fastsurfer-seg %dir %{ckpt_dir} %dir %{ckpt_dir}/checkpoints %files checkpoints-vinn %{ckpt_dir}/checkpoints/aparc_vinn_*_v2.0.0.pkl %files checkpoints-cerebnet %{ckpt_dir}/checkpoints/CerebNet_*_v1.0.0.pkl %files checkpoints-hypvinn %{ckpt_dir}/checkpoints/HypVINN_*_v1.1.0.pkl %changelog * Sat Oct 10 2026 Morgan Hough - 2.6.0-1 - Initial package. FastSurfer 2.6.0 code plus three trained networks (FastSurferVINN, CerebNet, HypVINN) as data subpackages. FastSurfer-CC waits for meshpy and neuroreg; recon-surf (needs FreeSurfer) is for neurofedora-nonfree. - Measured before packaging, f44 x86_64, Fedora torch 2.9.1 (CPU), 8 threads, an HBN T1w: full FastSurferVINN segmentation in 22 min 55 s, 3.9 GB peak RSS; Dice against the same subject's FreeSurfer 6 aparc.DKTatlas+aseg: 0.915 mean over 21 subcortical, ventricle, cerebellar and white-matter labels, 0.892 mean over 62 DKT cortical parcels.