#!/usr/bin/env fslpython
#
# An example FEEDS test which loads some data from
# a CSV file, and uses it to test an algorithm.
#

import sys
import os.path as op
import numpy   as np


# Read in the command line arguments.
outdir = sys.argv[1]

def fancy_algorithm_that_needs_testing(data):
    return data.mean()


# Load the data from the CSV file.
data = np.loadtxt('data.csv', delimiter=',')

# Run the algorithm.
result = fancy_algorithm_that_needs_testing(data)

with open(op.join(outdir, 'result.txt'), 'wt') as f:
    f.write('{:6.2f}\n'.format(result))
