
import argparse
import os
import numpy as np

from ModelFit import ModelFit


if __name__ == '__main__':
    # parser = argparse.ArgumentParser()
    # parser.add_argument("dir", help="folder containing the cell folders with the fit results")
    # args = parser.parse_args()

    dir_path = "results/invivo_results/"  # args.dir

    # if not os.path.isdir(dir_path):
    #     print("Argument dir is not a directory.")
    #     parser.print_usage()
    #     exit(0)

    for item in os.listdir(dir_path):
        cell_folder = os.path.join(dir_path, item)

        if not os.path.isdir(cell_folder):
            continue
        min_err = np.inf
        min_run = ""

        for run in os.listdir(cell_folder):
            err = float(run.split("_")[-1])
            if err < min_err:
                min_err = err
                min_run = os.path.join(cell_folder, run)

        results = ModelFit(min_run)
        quit()
        # search folders for one with min error
        # gather images + info about parameters, behaviour

        pass


