From 6ed1dff606f4b2d92b59851531dd75782cd03cba Mon Sep 17 00:00:00 2001
From: Taylor Hanayik <hanayik@gmail.com>
Date: Mon, 26 Jun 2023 15:23:28 +0100
Subject: [PATCH] add json tests; code cleanup;

---
 fslstats.cc                                   |   2 -
 tests/fslstats/feedsRun                       | 113 ++++++++++++++----
 tests/fslstats/test_cogMM_c.json              |  15 +++
 tests/fslstats/test_cogVox_C.json             |  15 +++
 .../test_diff_d_imageForDiff.nii.gz_m.json    |  11 ++
 tests/fslstats/test_entropyNonzero_E.json     |  11 ++
 tests/fslstats/test_entropy_e.json            |  11 ++
 tests/fslstats/test_histLimits_H_10_0_1.json  |  22 ++++
 tests/fslstats/test_hist_h_10.json            |  22 ++++
 tests/fslstats/test_maxCoord_x.json           |  15 +++
 tests/fslstats/test_meanHistCog_m_h_10_c.json |  28 +++++
 tests/fslstats/test_meanHist_m_h_10.json      |  23 ++++
 tests/fslstats/test_meanNonzero_M.json        |  11 ++
 tests/fslstats/test_mean_m.json               |  11 ++
 tests/fslstats/test_mean_m_a.json             |  11 ++
 tests/fslstats/test_mean_m_a_n.json           |  11 ++
 tests/fslstats/test_minCoord_X.json           |  15 +++
 tests/fslstats/test_notRobust_R.json          |  14 +++
 .../fslstats/test_percentileNonzero_P_50.json |  11 ++
 tests/fslstats/test_percentile_p_50.json      |  11 ++
 ...st_preopIndexMaskMeanTimeSeries_t_K_m.json |  36 ++++++
 .../fslstats/test_preopIndexMaskMean_K_m.json |  20 ++++
 .../test_preopMeanTimeSeries_t_m.json         |  18 +++
 tests/fslstats/test_robust_r.json             |  14 +++
 tests/fslstats/test_roi_w.json                |  20 ++++
 tests/fslstats/test_stdevNonzero_S.json       |  11 ++
 tests/fslstats/test_stdev_s.json              |  11 ++
 .../test_threshold_l_0.25_u_0.75_m.json       |  11 ++
 tests/fslstats/test_volumeNonzero_V.json      |  14 +++
 tests/fslstats/test_volume_v.json             |  14 +++
 30 files changed, 525 insertions(+), 27 deletions(-)
 create mode 100644 tests/fslstats/test_cogMM_c.json
 create mode 100644 tests/fslstats/test_cogVox_C.json
 create mode 100644 tests/fslstats/test_diff_d_imageForDiff.nii.gz_m.json
 create mode 100644 tests/fslstats/test_entropyNonzero_E.json
 create mode 100644 tests/fslstats/test_entropy_e.json
 create mode 100644 tests/fslstats/test_histLimits_H_10_0_1.json
 create mode 100644 tests/fslstats/test_hist_h_10.json
 create mode 100644 tests/fslstats/test_maxCoord_x.json
 create mode 100644 tests/fslstats/test_meanHistCog_m_h_10_c.json
 create mode 100644 tests/fslstats/test_meanHist_m_h_10.json
 create mode 100644 tests/fslstats/test_meanNonzero_M.json
 create mode 100644 tests/fslstats/test_mean_m.json
 create mode 100644 tests/fslstats/test_mean_m_a.json
 create mode 100644 tests/fslstats/test_mean_m_a_n.json
 create mode 100644 tests/fslstats/test_minCoord_X.json
 create mode 100644 tests/fslstats/test_notRobust_R.json
 create mode 100644 tests/fslstats/test_percentileNonzero_P_50.json
 create mode 100644 tests/fslstats/test_percentile_p_50.json
 create mode 100644 tests/fslstats/test_preopIndexMaskMeanTimeSeries_t_K_m.json
 create mode 100644 tests/fslstats/test_preopIndexMaskMean_K_m.json
 create mode 100644 tests/fslstats/test_preopMeanTimeSeries_t_m.json
 create mode 100644 tests/fslstats/test_robust_r.json
 create mode 100644 tests/fslstats/test_roi_w.json
 create mode 100644 tests/fslstats/test_stdevNonzero_S.json
 create mode 100644 tests/fslstats/test_stdev_s.json
 create mode 100644 tests/fslstats/test_threshold_l_0.25_u_0.75_m.json
 create mode 100644 tests/fslstats/test_volumeNonzero_V.json
 create mode 100644 tests/fslstats/test_volume_v.json

diff --git a/fslstats.cc b/fslstats.cc
index 8e90fd2..b29d9f9 100644
--- a/fslstats.cc
+++ b/fslstats.cc
@@ -199,11 +199,9 @@ int fmrib_main_float(int argc, char *argv[], const bool timeseriesMode, const st
         generateNonZeroMask(mask, masknz, vol);
       }
       int narg(2);
-      bool last = false;
       while (narg < argc)
       {
 
-        last = !(narg < argc - 1);
         string sarg(argv[narg]);
         if (sarg == "-n")
         {
diff --git a/tests/fslstats/feedsRun b/tests/fslstats/feedsRun
index a007f1d..8e722db 100755
--- a/tests/fslstats/feedsRun
+++ b/tests/fslstats/feedsRun
@@ -46,31 +46,31 @@ import nibabel as nib
 np.random.seed(0)
 
 options = [
-    {"option": "-r", "expected": "0.018533 0.978824"},
-    {"option": "-R", "expected": "0.000546 0.999809"},
-    {"option": "-e", "expected": "0.906103"},
-    {"option": "-E", "expected": "0.906103"},
-    {"option": "-v", "expected": "1000 1000.000000"},
-    {"option": "-V", "expected": "1000 1000.000000"},
-    {"option": "-m", "expected": "0.495922"},
-    {"option": "-m -a", "expected": "0.495922"},
-    {"option": "-m -a -n", "expected": "0.495922"},
-    {"option": "-M", "expected": "0.495922"},
-    {"option": "-s", "expected": "0.290744"},
-    {"option": "-S", "expected": "0.290744"},
-    {"option": "-w", "expected": "0 10 0 10 0 10 0 1"},
-    {"option": "-x", "expected": "9 7 4"},
-    {"option": "-X", "expected": "8 2 1"},
-    {"option": "-c", "expected": "4.498706 4.545873 4.613188"},
-    {"option": "-C", "expected": "4.498706 4.545873 4.613188"},
-    {"option": "-p 50", "expected": "0.482584"},
-    {"option": "-P 50", "expected": "0.482584"},
-    {"option": "-m -h 10 -c", "expected": "0.495922 101.000000 \n99.000000 \n108.000000 \n107.000000 \n102.000000 \n93.000000 \n99.000000 \n88.000000 \n95.000000 \n108.000000 \n 4.498706 4.545873 4.613188"},
-    {"option": "-m -h 10", "expected": "0.495922 101.000000 \n99.000000 \n108.000000 \n107.000000 \n102.000000 \n93.000000 \n99.000000 \n88.000000 \n95.000000 \n108.000000"},
-    {"option": "-h 10", "expected": "101.000000 \n99.000000 \n108.000000 \n107.000000 \n102.000000 \n93.000000 \n99.000000 \n88.000000 \n95.000000 \n108.000000"},
-    {"option": "-H 10 0 1", "expected": "98.000000 \n102.000000 \n107.000000 \n108.000000 \n102.000000 \n93.000000 \n99.000000 \n88.000000 \n95.000000 \n108.000000"},
-    {"option": "-l 0.25 -u 0.75 -m", "expected": "0.495150"},
-    {"option": "-d imageForDiff.nii.gz -m", "expected": "0.000000"},
+    {"name": "robust", "option": "-r", "expected": "0.018533 0.978824"},
+    {"name": "notRobust", "option": "-R", "expected": "0.000546 0.999809"},
+    {"name": "entropy", "option": "-e", "expected": "0.906103"},
+    {"name": "entropyNonzero", "option": "-E", "expected": "0.906103"},
+    {"name": "volume", "option": "-v", "expected": "1000 1000.000000"},
+    {"name": "volumeNonzero", "option": "-V", "expected": "1000 1000.000000"},
+    {"name": "mean", "option": "-m", "expected": "0.495922"},
+    {"name": "mean", "option": "-m -a", "expected": "0.495922"},
+    {"name": "mean", "option": "-m -a -n", "expected": "0.495922"},
+    {"name": "meanNonzero", "option": "-M", "expected": "0.495922"},
+    {"name": "stdev", "option": "-s", "expected": "0.290744"},
+    {"name": "stdevNonzero", "option": "-S", "expected": "0.290744"},
+    {"name": "roi","option": "-w", "expected": "0 10 0 10 0 10 0 1"},
+    {"name": "maxCoord", "option": "-x", "expected": "9 7 4"},
+    {"name": "minCoord", "option": "-X", "expected": "8 2 1"},
+    {"name": "cogMM", "option": "-c", "expected": "4.498706 4.545873 4.613188"},
+    {"name": "cogVox","option": "-C", "expected": "4.498706 4.545873 4.613188"},
+    {"name": "percentile", "option": "-p 50", "expected": "0.482584"},
+    {"name": "percentileNonzero","option": "-P 50", "expected": "0.482584"},
+    {"name": "meanHistCog", "option": "-m -h 10 -c", "expected": "0.495922 101.000000 \n99.000000 \n108.000000 \n107.000000 \n102.000000 \n93.000000 \n99.000000 \n88.000000 \n95.000000 \n108.000000 \n 4.498706 4.545873 4.613188"},
+    {"name": "meanHist", "option": "-m -h 10", "expected": "0.495922 101.000000 \n99.000000 \n108.000000 \n107.000000 \n102.000000 \n93.000000 \n99.000000 \n88.000000 \n95.000000 \n108.000000"},
+    {"name": "hist", "option": "-h 10", "expected": "101.000000 \n99.000000 \n108.000000 \n107.000000 \n102.000000 \n93.000000 \n99.000000 \n88.000000 \n95.000000 \n108.000000"},
+    {"name": "histLimits", "option": "-H 10 0 1", "expected": "98.000000 \n102.000000 \n107.000000 \n108.000000 \n102.000000 \n93.000000 \n99.000000 \n88.000000 \n95.000000 \n108.000000"},
+    {"name": "threshold", "option": "-l 0.25 -u 0.75 -m", "expected": "0.495150"},
+    {"name": "diff", "option": "-d imageForDiff.nii.gz -m", "expected": "0.000000"},
 ]
 
 # create a list of tests and expected results
@@ -82,6 +82,7 @@ for option in options:
             "mask": "",
             "options": option["option"],
             "expected": option["expected"],
+            "name": option["name"],
         }
     )
 
@@ -91,21 +92,49 @@ tests_with_preoptions = [
         "mask": "mask.nii.gz",
         "options": "-m",
         "expected": "1.078044 \n1.028827 \n0.986428 \n1.020869",
+        "name": "preopIndexMaskMean",
     },
     {
         "preoptions": "-t -K",
         "mask": "mask.nii.gz",
         "options": "-m",
         "expected": "0.526682 \n0.515652 \n0.492337 \n0.511661 \n0.551362 \n0.513176 \n0.494091 \n0.509208",
+        "name": "preopIndexMaskMeanTimeSeries",
     },
     {
         "preoptions": "-t",
         "mask": "",
         "options": "-m",
         "expected": "0.503236 \n0.504035",
+        "name": "preopMeanTimeSeries",
     },
 ]
 
+json_tests = []
+for option in options:
+    file_string = f"test_{option['name']}_{option['option'].replace(' ', '_')}.json"
+    file_string = file_string.replace("-", "")
+    json_tests.append(
+        {
+            "preoptions": "",
+            "mask": "",
+            "options": option["option"],
+            "expected": file_string,
+        }
+    )
+
+for option in tests_with_preoptions:
+    file_string = f"test_{option['name']}_{option['preoptions'].replace(' ', '_')}_{option['options'].replace(' ', '_')}.json"
+    file_string = file_string.replace("-", "")
+    json_tests.append(
+        {
+            "preoptions": option["preoptions"],
+            "mask": option["mask"],
+            "options": option["options"],
+            "expected": file_string,
+        }
+    )
+
 def test_fslstats():
     imgfile = 'test.nii.gz'
 
@@ -121,8 +150,11 @@ def test_fslstats():
         try:
             assert output == test["expected"]
         except AssertionError:
+            print('Failed test')
             print(cmd)
+            print('Output')
             print(output)
+            print('Expected')
             print(test["expected"])
             raise
 
@@ -147,6 +179,37 @@ def test_fslstats():
             print(test["expected"])
             raise
 
+    # run the json tests
+    for test in json_tests:
+        cmd = f"fslstats -json {test['preoptions']} {test['mask']} {imgfile} {test['options']}"
+        # remove any double spaces from empty test options
+        cmd = " ".join(cmd.split())
+        print(cmd, flush=True)
+        output = run.runfsl(cmd)
+
+        # try to load the expected json file
+        # if it exists, compare the output to the expected
+        try:
+            print(test["expected"])
+            with open(test["expected"], "r") as json_file:
+                # read the file as a string
+                expected = json_file.read()
+                try:
+                    assert output == expected    
+                except AssertionError:
+                    print('Failed test')
+                    print(cmd)
+                    print('Output')
+                    print(output)
+                    print('Expected')
+                    print(expected)
+                    raise
+        except FileNotFoundError:
+            # if the expected json file doesn't exist, create it from the output
+            # usefull for creating new tests or the first time a test is run
+            with open(test["expected"], "w") as json_file:
+                json_file.write(output)
+
 
 if __name__ == "__main__":
     test_fslstats()
diff --git a/tests/fslstats/test_cogMM_c.json b/tests/fslstats/test_cogMM_c.json
new file mode 100644
index 0000000..758ec3c
--- /dev/null
+++ b/tests/fslstats/test_cogMM_c.json
@@ -0,0 +1,15 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-c": [
+                        4.505939956803816,
+                        4.486097425091172,
+                        4.488288600081377
+                    ]
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_cogVox_C.json b/tests/fslstats/test_cogVox_C.json
new file mode 100644
index 0000000..1b6b7b0
--- /dev/null
+++ b/tests/fslstats/test_cogVox_C.json
@@ -0,0 +1,15 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-C": [
+                        4.505939956803816,
+                        4.486097425091172,
+                        4.488288600081377
+                    ]
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_diff_d_imageForDiff.nii.gz_m.json b/tests/fslstats/test_diff_d_imageForDiff.nii.gz_m.json
new file mode 100644
index 0000000..76d250a
--- /dev/null
+++ b/tests/fslstats/test_diff_d_imageForDiff.nii.gz_m.json
@@ -0,0 +1,11 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-m": 0.0077142266542650755
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_entropyNonzero_E.json b/tests/fslstats/test_entropyNonzero_E.json
new file mode 100644
index 0000000..9573a6e
--- /dev/null
+++ b/tests/fslstats/test_entropyNonzero_E.json
@@ -0,0 +1,11 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-E": 0.9468094676591793
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_entropy_e.json b/tests/fslstats/test_entropy_e.json
new file mode 100644
index 0000000..407d186
--- /dev/null
+++ b/tests/fslstats/test_entropy_e.json
@@ -0,0 +1,11 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-e": 0.9468094676591793
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_histLimits_H_10_0_1.json b/tests/fslstats/test_histLimits_H_10_0_1.json
new file mode 100644
index 0000000..4ce81ec
--- /dev/null
+++ b/tests/fslstats/test_histLimits_H_10_0_1.json
@@ -0,0 +1,22 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-H": [
+                        193.0,
+                        220.0,
+                        194.0,
+                        201.0,
+                        190.0,
+                        184.0,
+                        191.0,
+                        199.0,
+                        200.0,
+                        228.0
+                    ]
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_hist_h_10.json b/tests/fslstats/test_hist_h_10.json
new file mode 100644
index 0000000..2e210d2
--- /dev/null
+++ b/tests/fslstats/test_hist_h_10.json
@@ -0,0 +1,22 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-h": [
+                        198.0,
+                        216.0,
+                        194.0,
+                        200.0,
+                        190.0,
+                        184.0,
+                        191.0,
+                        199.0,
+                        199.0,
+                        229.0
+                    ]
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_maxCoord_x.json b/tests/fslstats/test_maxCoord_x.json
new file mode 100644
index 0000000..1a20172
--- /dev/null
+++ b/tests/fslstats/test_maxCoord_x.json
@@ -0,0 +1,15 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-x": [
+                        4,
+                        8,
+                        7
+                    ]
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_meanHistCog_m_h_10_c.json b/tests/fslstats/test_meanHistCog_m_h_10_c.json
new file mode 100644
index 0000000..58380fd
--- /dev/null
+++ b/tests/fslstats/test_meanHistCog_m_h_10_c.json
@@ -0,0 +1,28 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-c": [
+                        4.505939956803816,
+                        4.486097425091172,
+                        4.488288600081377
+                    ],
+                    "-h": [
+                        198.0,
+                        216.0,
+                        194.0,
+                        200.0,
+                        190.0,
+                        184.0,
+                        191.0,
+                        199.0,
+                        199.0,
+                        229.0
+                    ],
+                    "-m": 0.5036357601464115
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_meanHist_m_h_10.json b/tests/fslstats/test_meanHist_m_h_10.json
new file mode 100644
index 0000000..c8316e5
--- /dev/null
+++ b/tests/fslstats/test_meanHist_m_h_10.json
@@ -0,0 +1,23 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-h": [
+                        198.0,
+                        216.0,
+                        194.0,
+                        200.0,
+                        190.0,
+                        184.0,
+                        191.0,
+                        199.0,
+                        199.0,
+                        229.0
+                    ],
+                    "-m": 0.5036357601464115
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_meanNonzero_M.json b/tests/fslstats/test_meanNonzero_M.json
new file mode 100644
index 0000000..e7892ba
--- /dev/null
+++ b/tests/fslstats/test_meanNonzero_M.json
@@ -0,0 +1,11 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-M": 0.5036357601464115
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_mean_m.json b/tests/fslstats/test_mean_m.json
new file mode 100644
index 0000000..3763ba8
--- /dev/null
+++ b/tests/fslstats/test_mean_m.json
@@ -0,0 +1,11 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-m": 0.5036357601464115
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_mean_m_a.json b/tests/fslstats/test_mean_m_a.json
new file mode 100644
index 0000000..3763ba8
--- /dev/null
+++ b/tests/fslstats/test_mean_m_a.json
@@ -0,0 +1,11 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-m": 0.5036357601464115
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_mean_m_a_n.json b/tests/fslstats/test_mean_m_a_n.json
new file mode 100644
index 0000000..3763ba8
--- /dev/null
+++ b/tests/fslstats/test_mean_m_a_n.json
@@ -0,0 +1,11 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-m": 0.5036357601464115
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_minCoord_X.json b/tests/fslstats/test_minCoord_X.json
new file mode 100644
index 0000000..aa72b2e
--- /dev/null
+++ b/tests/fslstats/test_minCoord_X.json
@@ -0,0 +1,15 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-X": [
+                        8,
+                        1,
+                        6
+                    ]
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_notRobust_R.json b/tests/fslstats/test_notRobust_R.json
new file mode 100644
index 0000000..b5b7acd
--- /dev/null
+++ b/tests/fslstats/test_notRobust_R.json
@@ -0,0 +1,14 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-R": [
+                        0.00036734374589286745,
+                        0.9998085498809814
+                    ]
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_percentileNonzero_P_50.json b/tests/fslstats/test_percentileNonzero_P_50.json
new file mode 100644
index 0000000..47aeceb
--- /dev/null
+++ b/tests/fslstats/test_percentileNonzero_P_50.json
@@ -0,0 +1,11 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-P": 0.5013243556022644
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_percentile_p_50.json b/tests/fslstats/test_percentile_p_50.json
new file mode 100644
index 0000000..a105e7c
--- /dev/null
+++ b/tests/fslstats/test_percentile_p_50.json
@@ -0,0 +1,11 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-p": 0.5013243556022644
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_preopIndexMaskMeanTimeSeries_t_K_m.json b/tests/fslstats/test_preopIndexMaskMeanTimeSeries_t_K_m.json
new file mode 100644
index 0000000..9f0e754
--- /dev/null
+++ b/tests/fslstats/test_preopIndexMaskMeanTimeSeries_t_K_m.json
@@ -0,0 +1,36 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-m": 0.5266819608311916
+                },
+                {
+                    "-m": 0.5156517274568186
+                },
+                {
+                    "-m": 0.49233699466459285
+                },
+                {
+                    "-m": 0.5116614613561304
+                }
+            ]
+        },
+        {
+            "indices": [
+                {
+                    "-m": 0.5513619920395724
+                },
+                {
+                    "-m": 0.5131755568141885
+                },
+                {
+                    "-m": 0.49409089087108476
+                },
+                {
+                    "-m": 0.5092079986783641
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_preopIndexMaskMean_K_m.json b/tests/fslstats/test_preopIndexMaskMean_K_m.json
new file mode 100644
index 0000000..fd62a2f
--- /dev/null
+++ b/tests/fslstats/test_preopIndexMaskMean_K_m.json
@@ -0,0 +1,20 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-m": 1.078043952870764
+                },
+                {
+                    "-m": 1.0288272842710071
+                },
+                {
+                    "-m": 0.9864278855356776
+                },
+                {
+                    "-m": 1.0208694600344945
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_preopMeanTimeSeries_t_m.json b/tests/fslstats/test_preopMeanTimeSeries_t_m.json
new file mode 100644
index 0000000..b2b481f
--- /dev/null
+++ b/tests/fslstats/test_preopMeanTimeSeries_t_m.json
@@ -0,0 +1,18 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-m": 0.503236498022452
+                }
+            ]
+        },
+        {
+            "indices": [
+                {
+                    "-m": 0.504035022270371
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_robust_r.json b/tests/fslstats/test_robust_r.json
new file mode 100644
index 0000000..9810ac1
--- /dev/null
+++ b/tests/fslstats/test_robust_r.json
@@ -0,0 +1,14 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-r": [
+                        0.018357284367084503,
+                        0.982818067073822
+                    ]
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_roi_w.json b/tests/fslstats/test_roi_w.json
new file mode 100644
index 0000000..d023769
--- /dev/null
+++ b/tests/fslstats/test_roi_w.json
@@ -0,0 +1,20 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-w": [
+                        0,
+                        10,
+                        0,
+                        10,
+                        0,
+                        10,
+                        0,
+                        2
+                    ]
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_stdevNonzero_S.json b/tests/fslstats/test_stdevNonzero_S.json
new file mode 100644
index 0000000..cdb0547
--- /dev/null
+++ b/tests/fslstats/test_stdevNonzero_S.json
@@ -0,0 +1,11 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-S": 0.2949828225878523
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_stdev_s.json b/tests/fslstats/test_stdev_s.json
new file mode 100644
index 0000000..b473581
--- /dev/null
+++ b/tests/fslstats/test_stdev_s.json
@@ -0,0 +1,11 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-s": 0.29498282199940035
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_threshold_l_0.25_u_0.75_m.json b/tests/fslstats/test_threshold_l_0.25_u_0.75_m.json
new file mode 100644
index 0000000..6712e13
--- /dev/null
+++ b/tests/fslstats/test_threshold_l_0.25_u_0.75_m.json
@@ -0,0 +1,11 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-m": 0.49646345829352356
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_volumeNonzero_V.json b/tests/fslstats/test_volumeNonzero_V.json
new file mode 100644
index 0000000..9a1ed33
--- /dev/null
+++ b/tests/fslstats/test_volumeNonzero_V.json
@@ -0,0 +1,14 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-V": [
+                        2000.0,
+                        2000.0
+                    ]
+                }
+            ]
+        }
+    ]
+}
diff --git a/tests/fslstats/test_volume_v.json b/tests/fslstats/test_volume_v.json
new file mode 100644
index 0000000..5e4fb29
--- /dev/null
+++ b/tests/fslstats/test_volume_v.json
@@ -0,0 +1,14 @@
+{
+    "volumes": [
+        {
+            "indices": [
+                {
+                    "-v": [
+                        2000.0,
+                        2000.0
+                    ]
+                }
+            ]
+        }
+    ]
+}
-- 
GitLab