Exemplo n.º 1
0
 def test_can_get_surface_areas(self):
     # the following compares images and test images that are known
     # to satisfy the condition that an ROI w/ label n will have n
     # voxels that border white matter... labels in these images
     # are defined for 1:10
     roiImage = images.TNImage(
         filename='test_data/images/ROI_50x50x50.nii.gz')
     maskImage = images.TNImage(
         filename='test_data/images/ROI_WM_MASK_50x50x50.nii.gz')
     result = images.surface_area_for_rois(roiImage, maskImage)
     for label in range(1, 11):  # 1:10
         assert result[label] == label
Exemplo n.º 2
0
 def test_can_get_wm_neighbors_for_value(self):
     # for a test we will provide a 3dim white-matter mask with one
     # zero value in the xyz-center of the cube...  this
     # configuration should yield 26 neighbors (entire cube
     # centered around center voxel, less the voxel itself).  The
     # ROI image will consist of all ones, being of the same shape
     # as the mask.
     roiImage = images.TNImage(
         filename='test_data/images/3dim_images/ones.nii.gz')
     maskImage = images.TNImage(
         filename='test_data/images/3dim_images/wm_mask_only_center.nii.gz')
     assert len(images.get_wm_neighbors_for_value(roiImage, maskImage,
                                                  1)) == 26
Exemplo n.º 3
0
 def test_can_get_number_of_b_zeros(self):
     subject_dir = 'test_data/images/subject_dir/SUB_0001/'
     my_obj = images.TNImage(filename=subject_dir + 'rdata.nii.gz',
                             bvecs_file=subject_dir + 'bvecs',
                             bvals_file=subject_dir + 'bvals')
     # this particular subject has 2 b0's
     assert my_obj.number_of_b_zeros() == 2
Exemplo n.º 4
0
 def test_delta_z_dz_is_accurate(self):
     from os.path import join
     test_img = join(SUPPORT_DIR, 'noise.nii.gz')
     my_obj = images.TNImage(filename=test_img)
     mean_z = my_obj.z_mean()
     delta_z_dz = my_obj.delta_z_dz()
     assert (mean_z[1, :] - mean_z[0, :] == delta_z_dz[1, :]).all()
     assert (mean_z[0, :] - mean_z[-1, :] == delta_z_dz[0, :]).all()
Exemplo n.º 5
0
 def test_delta_z_dv_is_accurate(self):
     from os.path import join
     test_img = join(SUPPORT_DIR, 'noise.nii.gz')
     my_obj = images.TNImage(filename=test_img)
     mean_z = my_obj.z_mean()
     delta_z_dv = my_obj.delta_z_dv()
     assert (mean_z[:, 1] - mean_z[:, 0] == delta_z_dv[:, 1]).all()
     assert (mean_z[:, 0] - mean_z[:, -1] == delta_z_dv[:, 0]).all()
Exemplo n.º 6
0
 def test_access_number_of_b_zeros_without_set_no_error(self):
     my_obj = images.TNImage()
     error = False
     try:
         my_obj.number_of_b_zeros()
     except Exception as e:
         print e
         error = True
     assert not error
Exemplo n.º 7
0
 def test_v_mean_is_accurate(self):
     from nibabel import load
     from os.path import join
     import numpy as np
     test_img = join(SUPPORT_DIR, 'noise.nii.gz')
     my_obj = images.TNImage(filename=test_img)
     data = load(test_img).get_data()
     flat = data[:, :, :, 0].ravel()
     assert np.mean(flat) == my_obj.v_mean()[0]
Exemplo n.º 8
0
 def test_can_set_number_of_b_zeros(self):
     my_obj = images.TNImage()
     my_obj.number_of_b_zeros = 5
     assert my_obj.number_of_b_zeros == 5
Exemplo n.º 9
0
 def test_can_get_delta_z_dv(self):
     from os.path import join
     my_image = images.TNImage(join(SUPPORT_DIR, 'one.nii.gz'))
     assert my_image.delta_z_dv() is not None
Exemplo n.º 10
0
 def test_can_get_z_mean_for_3dim(self):
     from os.path import join
     my_image = images.TNImage(join(SUPPORT_DIR, '3dim_images/3dim.nii.gz'))
     assert my_image.z_mean() is not None
Exemplo n.º 11
0
 def test_can_get_delta_z_dz(self):
     from os.path import join
     my_image = images.TNImage(join(SUPPORT_DIR, 'one.nii.gz'))
     assert (my_image.delta_z_dz() == 0).all()
Exemplo n.º 12
0
 def test_can_instantiate_class_from_filename(self):
     from os.path import join
     assert images.TNImage(join(SUPPORT_DIR, 'noise.nii.gz')) is not None
Exemplo n.º 13
0
 def test_can_instantiate_class(self):
     assert images.TNImage() is not None
Exemplo n.º 14
0
 def setUp(self):
     self._i = images.TNImage()