

using ArgParse
using MagneticResonanceSignals

function rda_diff(in1file, in2file, outfile; anonymize=true)
    in1header,in1data = load_rda(in1file)
    in2header,in2data = load_rda(in2file)
    outheader = copy(in1header)
    if anonymize
        outheader["PatientName"] = "xxxxxxxxx"
        outheader["PatientID"] = "xxx"
        outheader["PatientBirthDate"] = "20000101"
    end
    save_rda(outfile, outheader, in1data .- in2data)
end

function megapress_argparse(arg_strings; extra_settings...)
    settings = ArgParseSettings(;extra_settings...)
    @add_arg_table settings begin
        "--output", "-o"
            help = "Output file name.  Default is autogenerated based on the input file names."
        "input_files"
            required=true
            nargs=2
            help = "Two input .rda files"
    end
    parse_args(arg_strings, settings)
end

# To test
# megapress_argparse(["a", "b", "c"], exc_handler=ArgParse.debug_handler)

parsed_args = megapress_argparse(ARGS)

rda_diff(parsed_args["input_files"][1], parsed_args["input_files"][2], parsed_args["output"])
