Skip to content
Snippets Groups Projects
Commit de52f06b authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

TEST: use fixed seed; make radio/neuro images world-aligned for convenience

parent d2737324
No related branches found
No related tags found
1 merge request!46unit test for fslcomplex
Pipeline #15350 skipped
...@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment