#!/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 rapidtide.tests.utils import get_test_data_path, get_test_target_path, get_test_temp_path, get_examples_path, get_rapidtide_root, get_scripts_path, create_dir
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 ["happy_"]:

    # copy things into target directory
    for suffix in [
        "_app.nii.gz",
        "_mask.nii.gz",
        "_vesselmask.nii.gz",
        "_cardfromfmri_25.0Hz.txt",
        "_cardfromfmri_dlfiltered_25.0Hz.txt",
        "_cardfromfmrienv_25.0Hz.txt",
    ]:
        # set the source and destination filename
        sourcefile = phase + "output" + suffix
        destfile = sourcefile.replace("_output", "_target")

        # 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")
