Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
30a0628
ENH: Testing.
ntustison Jul 17, 2025
c70f0ed
ENH: Testing2.
ntustison Jul 17, 2025
bfd3362
ENH: More testing.
ntustison Jul 17, 2025
59a0ebb
ENH: Change ubuntu.
ntustison Jul 17, 2025
47aaa71
ENH: Update yaml.
ntustison Jul 17, 2025
9e338e5
ENH: Update yaml2.
ntustison Jul 18, 2025
7464431
ENH: Add more tests.
ntustison Jul 18, 2025
ce08bd8
ENH: Add tests.
ntustison Jul 19, 2025
1d85dbc
ENH: Add tests.
ntustison Jul 19, 2025
b17b02b
ENH: Refactor test.yml.
ntustison Jul 19, 2025
fa670fc
ENH: Refactor test.yml2.
ntustison Jul 19, 2025
70f8bd1
ENH: Refactor test.yml3.
ntustison Jul 19, 2025
37375c6
ENH: Refactor test.yml3.
ntustison Jul 19, 2025
3ecd236
ENH: Refactor test.yml4.
ntustison Jul 19, 2025
a845b11
ENH: Refactor test.yml4.
ntustison Jul 19, 2025
6bbddc8
ENH: Refactor test.yml4.
ntustison Jul 19, 2025
348de76
ENH: Refactor test.yml5.
ntustison Jul 19, 2025
3ac251b
ENH: Refactor test.yml5.
ntustison Jul 19, 2025
1386a22
ENH: 1.
ntustison Jul 19, 2025
0b8fbb2
ENH: 2.
ntustison Jul 19, 2025
5f2af4f
ENH: 3.
ntustison Jul 19, 2025
da22d28
ENH: 3.
ntustison Jul 20, 2025
6d64fce
ENH: 3.
ntustison Jul 20, 2025
f6ecd0c
ENH: 3.
ntustison Jul 20, 2025
56cb7c3
ENH: 4.
ntustison Jul 20, 2025
d7b742c
ENH: 5.
ntustison Jul 20, 2025
604c4b9
ENH: 6.
ntustison Jul 20, 2025
6a0d224
ENH: 7.
ntustison Jul 20, 2025
1cccdc5
ENH: 7.
ntustison Jul 20, 2025
cef1ab6
ENH: 7.
ntustison Jul 20, 2025
aec773d
ENH: 8.
ntustison Jul 20, 2025
503ff60
ENH: 9.
ntustison Jul 20, 2025
39ba56c
ENH: 10.
ntustison Jul 20, 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
72 changes: 72 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: R-CMD-check ANTsRNet

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
test:
runs-on: ubuntu-22.04

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RETICULATE_PYTHON: /usr/bin/python3

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup R
uses: r-lib/actions/setup-r@v2

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libcurl4-openssl-dev libssl-dev libxml2-dev python3 python3-pip

- name: Cache R packages
uses: actions/cache@v3
with:
path: ~/.cache/R
key: ${{ runner.os }}-r-pkgs-${{ hashFiles('DESCRIPTION') }}
restore-keys: |
${{ runner.os }}-r-pkgs-

- name: Install Python deps
run: |
python3 -m pip install --upgrade pip
python3 -m pip install tensorflow==2.12 numpy==1.23 h5py

- name: Install R dependencies with pinned reticulate
run: |
Rscript -e '
cat("✅ Installing R packages...\n");
install.packages(c("remotes", "testthat", "tensorflow", "reticulate"), repos = "https://cloud.r-project.org");
cat("✅ Pointing reticulate to system Python...\n");
reticulate::use_python(Sys.getenv("RETICULATE_PYTHON"), required = TRUE);
cat("✅ Installing TensorFlow via R package...\n");
tensorflow::install_tensorflow(version = "2.12");
'

- name: Configure GitHub PAT
run: |
echo "GITHUB_PAT=${{ secrets.GH_PAT }}" >> $GITHUB_ENV
echo "GITHUB_PAT=${{ secrets.GH_PAT }}" >> ~/.Renviron

- name: Install ANTsR
run: |
Rscript -e 'remotes::install_github("ANTsX/ANTsR", dependencies = TRUE)'

- name: Install ANTsRNet
run: |
Rscript -e 'remotes::install_local(".", dependencies = TRUE)'

- name: Run tests individually (non-fatal)
continue-on-error: true
run: |
for f in tests/testthat/test_*.R; do
echo "===== Running $f ====="
Rscript -e "testthat::test_file('$f', reporter = 'summary')" || echo "Test $f failed"
done
1 change: 1 addition & 0 deletions R/getPretrainedNetwork.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ getPretrainedNetwork <- function(
"dktOuterWithSpatialPriors",
"DesikanKillianyTourvilleOuter",
"HarvardOxfordAtlasSubcortical",
"elBicho",
"ex5_coronal_weights",
"ex5_sagittal_weights",
"allen_brain_mask_weights",
Expand Down
39 changes: 0 additions & 39 deletions tests/testthat/test-alexNetModel.R

This file was deleted.

58 changes: 0 additions & 58 deletions tests/testthat/test-alexNetModel3D.R

This file was deleted.

19 changes: 0 additions & 19 deletions tests/testthat/test-pretrained.R

This file was deleted.

65 changes: 65 additions & 0 deletions tests/testthat/test_brain.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# test_that("deepAtropos runs with default input", {
# # skip_if_not_installed("ANTsRNet")
# skip_if_not_installed("ANTsR")
# library(ANTsRNet); library(ANTsR)

# t1 <- antsImageRead(getANTsXNetData('mprage_hippmapp3r'))
# seg <- deepAtropos(t1, verbose = FALSE)

# expect_type(seg, "list")
# expect_s4_class(seg$segmentationImage, "antsImage")
# })

# test_that("deepAtropos accepts list input with NULLs", {
# # skip_if_not_installed("ANTsRNet")
# skip_if_not_installed("ANTsR")
# library(ANTsRNet); library(ANTsR)

# t1 <- antsImageRead(getANTsXNetData('mprage_hippmapp3r'))
# seg <- deepAtropos(list(t1, NULL, NULL), verbose = FALSE)

# expect_type(seg, "list")
# expect_s4_class(seg$segmentationImage, "antsImage")
# })

# test_that("DKT labeling versions 0 and 1 work", {
# # skip_if_not_installed("ANTsRNet")
# skip_if_not_installed("ANTsR")
# library(ANTsRNet); library(ANTsR)

# t1 <- antsImageRead(getANTsXNetData('mprage_hippmapp3r'))
# dkt0 <- desikanKillianyTourvilleLabeling(t1, version = 0)
# dkt1 <- desikanKillianyTourvilleLabeling(t1, version = 1)

# expect_s4_class(dkt0, "antsImage")
# expect_s4_class(dkt1, "antsImage")
# })

# test_that("Harvard-Oxford Atlas labeling works", {
# # skip_if_not_installed("ANTsRNet")
# skip_if_not_installed("ANTsR")
# library(ANTsRNet); library(ANTsR)

# t1 <- antsImageRead(getANTsXNetData('mprage_hippmapp3r'))
# hoa <- harvardOxfordAtlasLabeling(t1)
# })

test_that("deepFlash returns expected segmentation", {
skip_if_not_installed("ANTsRNet")
skip_if_not_installed("ANTsR")
library(ANTsRNet); library(ANTsR)

t1 <- antsImageRead(getANTsXNetData('mprage_hippmapp3r'))
df <- deepFlash(t1, verbose = FALSE)
expect_type(df, "list")
})

test_that("claustrum segmentation runs", {
skip_if_not_installed("ANTsRNet")
skip_if_not_installed("ANTsR")
library(ANTsRNet); library(ANTsR)

t1 <- antsImageRead(getANTsXNetData('mprage_hippmapp3r'))
seg <- claustrumSegmentation(t1)
expect_s4_class(seg, "antsImage")
})
26 changes: 26 additions & 0 deletions tests/testthat/test_brainExtraction.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
test_that("brainExtraction runs correctly across modalities", {
skip_if_not_installed("ANTsRNet")
skip_if_not_installed("ANTsR")

library(ANTsR)
library(ANTsRNet)

# Download and read test image
t1 <- antsImageRead(getANTsXNetData('mprage_hippmapp3r'))

# Define modalities to test
# modalities <- c("t1", "t1threetissue", "t1hemi", "t1lobes")
modalities <- c("t1")

for (mod in modalities) {
bext <- brainExtraction(t1, modality = mod, verbose = FALSE)

if (mod %in% c("t1")) {
expect_s4_class(bext, "antsImage")
} else {
expect_type(bext, "list")
expect_true("segmentationImage" %in% names(bext))
expect_s4_class(bext$segmentationImage, "antsImage")
}
}
})
40 changes: 40 additions & 0 deletions tests/testthat/test_generalApplications.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
test_that("MRI super-resolution runs and returns antsImage", {
skip_if_not_installed("ANTsRNet")
skip_if_not_installed("ANTsR")

library(ANTsRNet)
library(ANTsR)

t1 <- antsImageRead(getANTsXNetData('mprage_hippmapp3r'))
t1_lr <- resampleImage(t1, c(4, 4, 4), useVoxels = FALSE)
t1_sr <- mriSuperResolution(t1_lr, expansionFactor = c(1, 1, 2))
expect_s4_class(t1_sr, "antsImage")
})

test_that("T1w neural image QA returns numeric score", {
skip_if_not_installed("ANTsRNet")
skip_if_not_installed("ANTsR")

library(ANTsRNet)
library(ANTsR)

t1 <- antsImageRead(getANTsXNetData('mprage_hippmapp3r'))
qa_score <- tidNeuralImageAssessment(t1)
expect_type(qa_score, "list")
})

test_that("PSNR and SSIM return valid similarity values", {
skip_if_not_installed("ANTsRNet")
skip_if_not_installed("ANTsR")

library(ANTsRNet)
library(ANTsR)

r16 <- antsImageRead(getANTsRData("r16"))
r64 <- antsImageRead(getANTsRData("r64"))

psnr_val <- PSNR(r16, r64)
expect_equal(psnr_val, 10.37418, tolerance = 1e-3)
ssim_val <- SSIM(r16, r64)
expect_equal(ssim_val, 0.5654819, tolerance = 1e-3)
})
Loading
Loading