-
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 #236 from berkeley-stat159/Tests
Tests for find activated voxel function
- Loading branch information
Showing
3 changed files
with
51 additions
and
32 deletions.
There are no files selected for viewing
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
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
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,33 @@ | ||
import os | ||
import sys | ||
import numpy as np | ||
import nibabel as nib | ||
from nose.tools import assert_equal | ||
from numpy.testing import assert_almost_equal, assert_array_equal | ||
|
||
|
||
# Add path to functions to the system path. | ||
sys.path.append(os.path.join(os.path.dirname(__file__), "../functions/")) | ||
|
||
from find_activated_voxel_functions import * | ||
project_path=os.path.join(os.path.dirname(__file__), '../../../') | ||
|
||
|
||
def test_size(): | ||
shape = (2, 3, 2) | ||
assert_equal(size(shape), 12) | ||
assert_equal(size(shape, axis=0),2) | ||
|
||
def test_get_increment(): | ||
assert_equal(get_increment((2, 4)),[4, 1]) | ||
assert_equal(get_increment((2, 2, 2)),[4, 2, 1]) | ||
|
||
def test_get_index(): | ||
shape = (2, 2, 2) | ||
assert_equal(get_index(shape, 4),(1, 0, 0)) | ||
assert_equal(get_index(shape, 2),(0, 1, 0)) | ||
|
||
|
||
def test_find_activated_voxel(): | ||
p = np.array([[ 0.39764537],[ 0.005514348],[ 0.04195935]]) | ||
assert_array_equal(find_activated_voxel((2, 3, 4),p)[0],[[0, 0, 0]]) |