From 475ab8aa0e0cf382ed6414d16e4a983ba596837b Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Mon, 26 Jun 2023 11:22:31 +0100
Subject: [PATCH] TEST: avscale is part of flirt, not avwutils

---
 tests/avscale/feedsRun | 116 -----------------------------------------
 1 file changed, 116 deletions(-)
 delete mode 100755 tests/avscale/feedsRun

diff --git a/tests/avscale/feedsRun b/tests/avscale/feedsRun
deleted file mode 100755
index 32062a0..0000000
--- a/tests/avscale/feedsRun
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/usr/bin/env fslpython
-
-# test avscale with different input affines
-
-
-import sys
-import os
-
-import fsl.utils.run as run
-
-import numpy as np
-
-
-PI    = np.pi
-PION2 = np.pi / 2
-
-
-# Each test has the form (input-affine, expected-output)
-# where expected-output comprises:
-#   - scales
-#   - translations
-#   - rotations
-#   - skews
-#   - L/R orientation (preserved or swapped)
-tests = [
-
-    ([[1, 0, 0, 0],
-      [0, 1, 0, 0],
-      [0, 0, 1, 0],
-      [0, 0, 0, 1]], [(1, 1, 1), (0, 0, 0), (0, 0, 0), (0, 0, 0), 'preserved']),
-    ([[2, 0, 0, 0],
-      [0, 2, 0, 0],
-      [0, 0, 2, 0],
-      [0, 0, 0, 1]], [(2, 2, 2), (0, 0, 0), (0, 0, 0), (0, 0, 0), 'preserved']),
-    ([[-2, 0, 0, 0],
-      [ 0, 2, 0, 0],
-      [ 0, 0, 2, 0],
-      [ 0, 0, 0, 1]], [(2, 2, 2), (0, 0, 0), (0, 0, PI), (0, 0, 0), 'swapped']),
-    ([[0, 0, 1, 0],
-      [0, 1, 0, 0],
-      [1, 0, 0, 0],
-      [0, 0, 0, 1]], [(1, 1, 1), (0, 0, 0), (0, -PION2, 0), (0, 0, 0), 'swapped']),
-    ([[ 0,  0, -1, 0],
-      [ 0, -1,  0, 0],
-      [-1,  0,  0, 0],
-      [ 0,  0,  0, 1]], [(1, 1, 1), (0, 0, 0), (-PI, PION2, 0), (0, 0, 0), 'preserved']),
-    ([[0, 1, 0, 0],
-      [1, 0, 0, 0],
-      [0, 0, 1, 0],
-      [0, 0, 0, 1]], [(1, 1, 1), (0, 0, 0), (0, 0, PION2), (0, 0, 0), 'swapped']),
-    ([[1, 0, 0, 0],
-      [0, 0, 1, 0],
-      [0, 1, 0, 0],
-      [0, 0, 0, 1]], [(1, 1, 1), (0, 0, 0), (PION2, 0, 0), (0, 0, 0), 'swapped']),
-    ([[-2, 0, 0,  90],
-      [ 0, 2, 0, -126],
-      [ 0, 0, 2, -72],
-      [ 0, 0, 0,  1]], [(2, 2, 2), (90, -126, -72), (0, 0, PI), (0, 0, 0), 'swapped']),
-
-]
-
-def read_avscale_output(output):
-    lines = output.split('\n')
-    # scales
-    # translations
-    # rotations
-    # skews
-    # l/r orientation (preserved or swapped)
-    scales       = [l for l in lines if l.startswith('Scales ')]        [0]
-    translations = [l for l in lines if l.startswith('Translations ')]  [0]
-    rotations    = [l for l in lines if l.startswith('Rotation Angles')][0]
-    skews        = [l for l in lines if l.startswith('Skews ')]         [0]
-    orient       = [l for l in lines if l.startswith('Left-Right ')]    [0]
-
-    scales       = [float(s) for s in scales      .split()[-3:]]
-    translations = [float(s) for s in translations.split()[-3:]]
-    rotations    = [float(s) for s in rotations   .split()[-3:]]
-    skews        = [float(s) for s in skews       .split()[-3:]]
-    orient       = orient.split()[-1]
-
-    return {
-        'scales'       : np.array(scales),
-        'translations' : np.array(translations),
-        'rotations'    : np.array(rotations),
-        'skews'        : np.array(skews),
-        'orient'       : orient.lower(),
-    }
-
-
-def test_avscale():
-
-    for affine, expected in tests:
-        affine = np.array(affine)
-        np.savetxt('affine.mat', affine, '%0.6f')
-        print(affine)
-        output = run.runfsl('avscale --allparams affine.mat')
-        output = read_avscale_output(output)
-
-        scales, translations, rotations, skews, orient = expected
-
-        try:
-            assert np.all(np.isclose(scales,       output['scales']))
-            assert np.all(np.isclose(translations, output['translations']))
-            assert np.all(np.isclose(rotations,    output['rotations']))
-            assert np.all(np.isclose(skews,        output['skews']))
-            assert                   orient     == output['orient']
-        except AssertionError:
-            print(affine)
-            print(output)
-            raise
-
-
-if __name__ == '__main__':
-    if len(sys.argv) > 1:
-        os.chdir(sys.argv[1])
-    test_avscale()
-- 
GitLab