Skip to content

Commit

Permalink
Add test for ScannerCoil
Browse files Browse the repository at this point in the history
  • Loading branch information
po09i committed Jan 23, 2024
1 parent 9fa813c commit 8008568
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions test/test_coil.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,31 @@ def test_create_scanner_coil_order1():
assert scanner_coil.profile[0, 0, 0, 0] == -1.0


def test_create_scanner_coil_order2():
def test_create_scanner_coil_siemens_order2():
sph_contraints = json.load(open(__dir_config_scanner_constraints__))
scanner_coil = ScannerCoil((4, 5, 6), np.eye(4), sph_contraints, [0, 1, 2])
affine= np.array([[1, 0, 0, -1], [0, 1, 0, -1], [0, 0, 1, -1], [0, 0, 0, 1]])
scanner_coil = ScannerCoil((3, 3, 3), affine, sph_contraints, [0, 1, 2], 'SIEMENS')

assert scanner_coil.profile[0, 0, 0, 0] == -1.0
assert np.allclose(scanner_coil.profile[:, 1, :, 5], np.array([[8.5154957e-05, 0.0000000e+00, -8.5154957e-05],
[-0.0000000e+00, 0.0000000e+00, 0.0000000e+00],
[-8.5154957e-05, -0.0000000e+00, 8.5154957e-05]]))


def test_create_scanner_coil_philips():
sph_contraints = json.load(open(__dir_config_scanner_constraints__))
affine = np.array([[1, 0, 0, -1], [0, 1, 0, -1], [0, 0, 1, -1], [0, 0, 0, 1]])
scanner_coil = ScannerCoil((3, 3, 3), affine, sph_contraints, [0, 1, 2], 'PHILIPS')

assert np.allclose(scanner_coil.profile[1, :, :, 5], np.array([[-8.5154957e-02 / 2, 0, 8.5154957e-02 / 2],
[0, 0, 0],
[8.5154957e-02 / 2, 0, -8.5154957e-02 / 2]]))


def test_create_scanner_coil_ge():
sph_contraints = json.load(open(__dir_config_scanner_constraints__))
affine = np.array([[1, 0, 0, -1], [0, 1, 0, -1], [0, 0, 1, -1], [0, 0, 0, 1]])
scanner_coil = ScannerCoil((3, 3, 3), affine, sph_contraints, [0, 1, 2], 'GE')

assert np.allclose(scanner_coil.profile[1, :, :, 5], np.array([[1.009365e-07, 3.446500e-09, 3.974650e-08],
[6.689500e-08, 0.000000e+00, 6.689500e-08],
[3.974650e-08, 3.446500e-09, 1.009365e-07]]))

0 comments on commit 8008568

Please sign in to comment.