Skip to content
Snippets Groups Projects

unit test for fslcomplex

Merged Paul McCarthy requested to merge test/fslcomplex into master
1 file
+ 13
7
Compare changes
  • Side-by-side
  • Inline
@@ -30,22 +30,28 @@ def imtest(path):
@@ -30,22 +30,28 @@ def imtest(path):
# radio=[True|False] -> whether or not
# radio=[True|False] -> whether or not
# to add a flip on the affine X axis
# to add a flip on the affine X axis
def create_test_input_data(radio):
def create_test_input_data(radio, seed=1):
 
 
np.random.seed(seed)
real = np.random.randint(0, 100, (10, 10, 10)).astype(np.float32)
real = np.random.randint(0, 100, (10, 10, 10)).astype(np.float32)
imag = np.random.randint(0, 100, (10, 10, 10)).astype(np.float32)
imag = np.random.randint(0, 100, (10, 10, 10)).astype(np.float32)
 
affine = np.diag([3, 3, 3, 1])
 
 
if radio:
 
affine[0, 0] *= -1
 
affine[:3, 3] = [37, 20, 30]
 
real = np.flip(real, 0)
 
imag = np.flip(imag, 0)
 
else:
 
affine[:3, 3] = [10, 20, 30]
 
comp = real + imag * 1j
comp = real + imag * 1j
abso = np.abs(comp)
abso = np.abs(comp)
phase = np.arctan2(comp.imag, comp.real)
phase = np.arctan2(comp.imag, comp.real)
comp4d = np.concatenate((comp.reshape(10, 10, 10, 1),
comp4d = np.concatenate((comp.reshape(10, 10, 10, 1),
comp.reshape(10, 10, 10, 1)), 3)
comp.reshape(10, 10, 10, 1)), 3)
affine = np.diag([3, 3, 3, 1])
affine[:3, 3] = [10, 20, 30]
if radio:
affine[0, 0] *= -1
real = nib.Nifti1Image(real, affine)
real = nib.Nifti1Image(real, affine)
imag = nib.Nifti1Image(imag, affine)
imag = nib.Nifti1Image(imag, affine)
comp = nib.Nifti1Image(comp, affine)
comp = nib.Nifti1Image(comp, affine)
Loading