Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f456824
Add GitHub Actions CI for unit tests
ntustison Jul 17, 2025
52b177d
BUG: Fix trigger.
ntustison Jul 17, 2025
2db578b
BUG: Fix trigger2.
ntustison Jul 17, 2025
82c7958
BUG: Fix trigger3.
ntustison Jul 17, 2025
78a7a5e
ENH: Adjustments.
ntustison Jul 17, 2025
9cd6d03
BUG: Fix trigger4.
ntustison Jul 17, 2025
fa8cd1d
BUG: Remove nobrainer.
ntustison Jul 17, 2025
5ff457e
BUG: Remove 3tissue.
ntustison Jul 17, 2025
215c70a
BUG: Remove 3tissue.
ntustison Jul 17, 2025
9c2ec17
ENH: Rm inpainting.
ntustison Jul 17, 2025
0a3bf2e
ENH: Download all data.
ntustison Jul 17, 2025
9baa8e9
BUG: Unavailable networks.
ntustison Jul 17, 2025
eb2664a
BUG: Unavailable networks.
ntustison Jul 17, 2025
2d18c1d
BUG: Pytest.
ntustison Jul 17, 2025
4ba64bc
BUG: Rm deepAtropos1.
ntustison Jul 17, 2025
260cf64
BUG: Rm more tests.
ntustison Jul 17, 2025
73c5920
BUG: Rm more tests.
ntustison Jul 17, 2025
296491f
BUG: Log memory.
ntustison Jul 17, 2025
358fc8d
BUG: Log memory.
ntustison Jul 17, 2025
2d816eb
BUG: Log memory.
ntustison Jul 17, 2025
fd2ca10
BUG: Install ANTsPy from source.
ntustison Jul 17, 2025
5680e11
BUG: Install ANTsPy from source2.
ntustison Jul 17, 2025
83f6c5f
BUG: Install ANTsPy from source3.
ntustison Jul 17, 2025
ec46edd
BUG: Install ANTsPy from source4.
ntustison Jul 17, 2025
955dadd
BUG: Install ANTsPy from source5.
ntustison Jul 17, 2025
0b5dc95
BUG: Update pyproject.toml.
ntustison Jul 17, 2025
4abf279
BUG: Turn off build from source.
ntustison Jul 17, 2025
d97c8c7
BUG: Rm MRA and lesion tests.
ntustison Jul 17, 2025
a9a5115
BUG: Rm hypothalamus test.
ntustison Jul 17, 2025
be3e24e
BUG: Rm cereb test.
ntustison Jul 17, 2025
a52567b
BUG: Rm brain ext tests.
ntustison Jul 18, 2025
8481482
ENH: Rm ANTs WMH test.
ntustison Jul 18, 2025
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
71 changes: 71 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: ANTsPyNet Unit Tests

on:
push:
pull_request:

env:
USE_SOURCE_BUILD: false # Set to 'false' to use PyPI version of ANTsPy

jobs:
test:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-22.04

strategy:
matrix:
python-version: [3.11]

steps:
- name: Checkout ANTsPyNet
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install build tools
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential git

- name: Install ANTsPy (source or PyPI)
run: |
if [ "$USE_SOURCE_BUILD" = "true" ]; then
echo "🔧 Installing ANTsPy from GitHub source..."
git clone https://github.com/ANTsX/ANTsPy.git
pip install scikit-build-core pybind11 nanobind # 🔑 install build backend dependencies
pip install ./ANTsPy --no-build-isolation --no-deps
else
echo "📦 Installing ANTsPy from PyPI..."
pip install antspyx
fi

- name: Cache ANTsXNet model/data downloads
uses: actions/cache@v4
with:
path: ~/.keras/ANTsXNet
key: antsxnet-${{ runner.os }}-${{ hashFiles('**/download_all_data.py') }}
restore-keys: |
antsxnet-${{ runner.os }}-

- name: Install ANTsPyNet and dependencies
run: |
pip install -e .
sed -i '/antspyx==/d' requirements.txt
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Pre-download ANTsXNet models and data
run: |
python download_all_data.py --strict

- name: Run tests (individually via pytest)
run: |
pip install pytest pytest-xdist pytest-forked psutil
for f in tests/test_*.py; do
echo "🔍 Running $f"
python -c "import psutil; print('Memory before:', psutil.virtual_memory().used // (1024*1024), 'MB')"
pytest -v -s --forked "$f" || exit 1
python -c "import psutil; print('Memory after :', psutil.virtual_memory().used // (1024*1024), 'MB')"
done
8 changes: 0 additions & 8 deletions antspynet/utilities/get_pretrained_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ def switch_networks(argument):
"ex5_coronal_weights": "https://figshare.com/ndownloader/files/42434193",
"ex5_sagittal_weights": "https://figshare.com/ndownloader/files/42434202",
"allen_brain_mask_weights" : "https://figshare.com/ndownloader/files/36999880", #https://figshare.com/ndownloader/files/42481248
"allen_brain_leftright_coronal_mask_weights" : "",
"allen_cerebellum_coronal_mask_weights" : "",
"allen_cerebellum_sagittal_mask_weights" : "",
"allen_sr_weights" : "",
"mouseMriBrainExtraction" : "https://figshare.com/ndownloader/files/44714947",
"mouseT2wBrainExtraction3D" : "https://figshare.com/ndownloader/files/49188910",
"mouseT2wBrainParcellation3DNick" : "https://figshare.com/ndownloader/files/44714944",
Expand Down Expand Up @@ -268,10 +264,6 @@ def switch_networks(argument):
"ex5_coronal_weights",
"ex5_sagittal_weights",
"allen_brain_mask_weights",
"allen_brain_leftright_coronal_mask_weights",
"allen_cerebellum_coronal_mask_weights",
"allen_cerebellum_sagittal_mask_weights",
"allen_sr_weights",
"mouseMriBrainExtraction",
"mouseT2wBrainExtraction3D",
"mouseT2wBrainParcellation3DNick",
Expand Down
53 changes: 53 additions & 0 deletions download_all_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import antspynet
import argparse
import sys

def download_all_data(strict=False):
print("Downloading data files from get_antsxnet_data...")
try:
data_keys = antspynet.get_antsxnet_data("show")
for key in data_keys:
if key == "show":
continue
try:
print(f" ↳ Downloading data: {key}")
fpath = antspynet.get_antsxnet_data(key)
print(f" ✓ Saved to: {fpath}")
except Exception as e:
print(f" ✗ Failed to download {key}: {e}")
if strict:
raise
except Exception as e:
print(f"✗ Failed to retrieve data keys: {e}")
if strict:
sys.exit(1)

print("\nDownloading model weights from get_pretrained_network...")
try:
model_keys = antspynet.get_pretrained_network("show")
for key in model_keys:
if key == "show":
continue
try:
print(f" ↳ Downloading model: {key}")
fpath = antspynet.get_pretrained_network(key)
print(f" ✓ Saved to: {fpath}")
except Exception as e:
print(f" ✗ Failed to download {key}: {e}")
if strict:
raise
except Exception as e:
print(f"✗ Failed to retrieve model keys: {e}")
if strict:
sys.exit(1)

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--strict", action="store_true", help="Exit on first failed download.")
args = parser.parse_args()

try:
download_all_data(strict=args.strict)
except Exception as e:
print(f"\nAborted due to error: {e}")
sys.exit(1)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies = [
"numpy",
"tensorflow>=2.11,<=2.17",
# "keras<3",
"antspyx>=0.4.2",
"antspyx>=0.6.1",
"scikit-learn",
"requests",
"statsmodels",
Expand Down
Loading
Loading