#test cases for pTFCE
require("oro.nifti")
context("true signal")
#test_file("../report.log")
test_that("Volume with spherical signal and random noise, SNR=1", {
expected=readNIfTI(system.file("extdata", "test02A_out.nii.gz", package="pTFCE"))
smooth=read.table(system.file("extdata", "test02A_smoothness.txt", package="pTFCE")); # file generated by FSL smoothest
ptfce=ptfce(img = readNIfTI(system.file("extdata", "test02A_in.nii.gz", package="pTFCE")),
V=smooth[2,2],
Rd = smooth[1,2]*smooth[2,2],
mask = readNIfTI(system.file("extdata", "test02_mask.nii.gz", package="pTFCE")),
Nh=50,
verbose = F
)$logp
expect_equal(mean(ptfce), mean(expected), tolerance=0.001)
expect_equal(sd(ptfce), sd(expected), tolerance=0.005)
expect_equal(ptfce[10,10,10], expected[10,10,10], tolerance=1e-6) #background
expect_equal(ptfce[47,32,16], expected[47,32,16], tolerance=0.001) #true signal
})
test_that("Volume with spherical signal and random noise, SNR=1, smoothness estimated", {
expected=readNIfTI(system.file("extdata", "test02A_out.nii.gz", package="pTFCE"))
smooth=read.table(system.file("extdata", "test02A_smoothness.txt", package="pTFCE")); # file generated by FSL smoothest
ptfce=ptfce(img = readNIfTI(system.file("extdata", "test02A_in.nii.gz", package="pTFCE")),
mask = readNIfTI(system.file("extdata", "test02_mask.nii.gz", package="pTFCE")),
Nh=50,
verbose = F
)$logp
expect_equal(mean(ptfce), mean(expected), tolerance=0.001)
expect_equal(sd(ptfce), sd(expected), tolerance=0.005)
expect_equal(ptfce[10,10,10], expected[10,10,10], tolerance=1e-6) #background
expect_equal(ptfce[47,32,16], expected[47,32,16], tolerance=0.001) #true signal
})
test_that("Volume with spherical signal and random noise, SNR=2", {
expected=readNIfTI(system.file("extdata", "test02B_out.nii.gz", package="pTFCE"))
smooth=read.table(system.file("extdata", "test02B_smoothness.txt", package="pTFCE")); # file generated by FSL smoothest
ptfce=ptfce(img = readNIfTI(system.file("extdata", "test02B_in.nii.gz", package="pTFCE")),
V=smooth[2,2],
Rd = smooth[1,2]*smooth[2,2],
mask = readNIfTI(system.file("extdata", "test02_mask.nii.gz", package="pTFCE")),
Nh=50,
verbose = F
)$logp
expect_equal(mean(ptfce), mean(expected), tolerance=0.01)
expect_equal(sd(ptfce), sd(expected), tolerance=0.01)
expect_equal(ptfce[10,10,10], expected[10,10,10], tolerance=1e-6) #background
expect_equal(ptfce[47,32,16], expected[47,32,16], tolerance = 0.05) #true signal
})
test_that("Volume with spherical signal and random noise, SNR=2, smoothness estimated", {
expected=readNIfTI(system.file("extdata", "test02B_out.nii.gz", package="pTFCE"))
smooth=read.table(system.file("extdata", "test02B_smoothness.txt", package="pTFCE")); # file generated by FSL smoothest
ptfce=ptfce(img = readNIfTI(system.file("extdata", "test02B_in.nii.gz", package="pTFCE")),
mask = readNIfTI(system.file("extdata", "test02_mask.nii.gz", package="pTFCE")),
Nh=50,
verbose = F
)$logp
expect_equal(mean(ptfce), mean(expected), tolerance=0.01)
expect_equal(sd(ptfce), sd(expected), tolerance=0.01)
expect_equal(ptfce[10,10,10], expected[10,10,10], tolerance=1e-6) #background
expect_equal(ptfce[47,32,16], expected[47,32,16], tolerance = 0.05) #true signal
})
test_that("Volume with spherical signal and random noise, SNR=3", {
expected=readNIfTI(system.file("extdata", "test02C_out.nii.gz", package="pTFCE"))
smooth=read.table(system.file("extdata", "test02C_smoothness.txt", package="pTFCE")); # file generated by FSL smoothest
ptfce=ptfce(img = readNIfTI(system.file("extdata", "test02C_in.nii.gz", package="pTFCE")),
V=smooth[2,2],
Rd = smooth[1,2]*smooth[2,2],
mask = readNIfTI(system.file("extdata", "test02_mask.nii.gz", package="pTFCE")),
Nh=50,
verbose = F
)$logp
expect_equal(mean(ptfce), mean(expected), tolerance=0.01)
expect_equal(sd(ptfce), sd(expected), tolerance=0.01)
expect_equal(ptfce[10,10,10], expected[10,10,10], tolerance=1e-6) #background
expect_equal(ptfce[47,32,16], expected[47,32,16], tolerance = 1.2e-05) #true signal
})
test_that("Volume with spherical signal and random noise, SNR=3, smoothness estimated", {
expected=readNIfTI(system.file("extdata", "test02C_out.nii.gz", package="pTFCE"))
smooth=read.table(system.file("extdata", "test02C_smoothness.txt", package="pTFCE")); # file generated by FSL smoothest
ptfce=ptfce(img = readNIfTI(system.file("extdata", "test02C_in.nii.gz", package="pTFCE")),
mask = readNIfTI(system.file("extdata", "test02_mask.nii.gz", package="pTFCE")),
Nh=50,
verbose = F
)$logp
expect_equal(mean(ptfce), mean(expected), tolerance=1e-5)
expect_equal(sd(ptfce), sd(expected), tolerance=1e-5)
expect_equal(ptfce[10,10,10], expected[10,10,10], tolerance=1e-6) #background
expect_equal(ptfce[47,32,16], expected[47,32,16], tolerance = 1.2e-05) #true signal
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.