-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from ye-zhi/master
fix test
- Loading branch information
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" Tests for smoothvoxels in smooth module | ||
Run at the tests directory with: | ||
nosetests code/utils/tests/test_smoothing.py | ||
""" | ||
|
||
import os | ||
import sys | ||
import numpy as np | ||
import itertools | ||
import scipy.ndimage | ||
from scipy.ndimage.filters import gaussian_filter | ||
import matplotlib.pyplot as plt | ||
import nibabel as nib | ||
from numpy.testing import assert_almost_equal | ||
from nose.tools import assert_not_equals | ||
|
||
|
||
# Add path to functions to the system path. | ||
sys.path.append(os.path.join(os.path.dirname(__file__), "../functions/")) | ||
|
||
# Load smoothing function. | ||
from smoothing import smoothing | ||
|
||
def test_smooth(): | ||
# Read in the image data. | ||
img = nib.load('data/ds114/sub009/BOLD/task002_run001/ds114_sub009_t2r1.nii') | ||
data = img.get_data() | ||
|
||
# Run the smoothing function with sigma 0 at time 12 | ||
non_smoothed_data = smoothing(data, 0, 12) | ||
|
||
# assert that data at time 12 and non_smoothed_data are equal since sigma = 0 | ||
assert_almost_equal(data[..., 12], non_smoothed_data) | ||
|
||
# Run the smoothvoxels function with sigma 5 at time 100 | ||
smoothed_data = smoothing(data, 5, 100) | ||
# assert that data at time 16 and smoothed_data are not equal | ||
assert_not_equals(data[..., 100].all(), smoothed_data.all()) |
Binary file not shown.