#!/usr/bin/env python
# -*- coding: latin-1 -*-
#
#   Copyright 2016-2021 Blaise Frederick
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
#
import os
from shutil import copyfile

import matplotlib.pyplot as plt
import numpy as np
from utils import (
    create_dir,
    get_examples_path,
    get_rapidtide_root,
    get_scripts_path,
    get_test_data_path,
    get_test_target_path,
    get_test_temp_path,
)

for phase in ["rapidtide2x_phase1", "rapidtide2x_phase2", "rapidtide2x_phase3"]:

    # copy things into target directory
    for suffix in [
        "_fitcoff.nii.gz",
        "_MTT.nii.gz",
        "_lagmask.nii.gz",
        "_lagtimes.nii.gz",
        "_lagstrengths.nii.gz",
        "_lagsigma.nii.gz",
    ]:
        # set the source and destination filename
        sourcefile = phase + "output" + suffix
        destfile = sourcefile.replace("phase1output", "phase1target")

        # check to see that the source file exists
        fullsourcefile = os.path.join(get_test_temp_path(), sourcefile)
        if os.path.isfile(fullsourcefile):
            fulldestfile = os.path.join("testtargets", destfile)
            copyfile(fullsourcefile, fulldestfile)
            # print('cp', fullsourcefile, fulldestfile)
        else:
            print(fullsourcefile, "does not exist - skipping")
