Ejemplo n.º 1
0
def data_dump(_files, labels=["CANS", "ORCO", "TBEH"]):
    outdict = [{}, {}, {}]
    exp = labels
    for idx, ex in enumerate(exp):
        _file = ex + "_BodyXCentroids.csv"
        df = pd.read_csv(_files + os.sep + _file,
                         delimiter=';',
                         usecols=[0],
                         skip_blank_lines=True,
                         header=0)
        N = df.shape[0]
        bit = pd.read_csv(_files + os.sep + _file,
                          delimiter=';',
                          skip_blank_lines=True,
                          header=0,
                          nrows=1)
        nflies = len(bit.columns)
        print("Found", nflies, "flies.")
        parts = ["BodyX", "BodyY", "HeadX", "HeadY"]
        for flies in range(nflies):
            filearray = np.full((N, len(parts)), np.nan)
            for idx, part in enumerate(parts):
                _file = ex + "_" + part + "Centroids.csv"
                df = pd.read_csv(_files + os.sep + _file,
                                 delimiter=';',
                                 usecols=[flies],
                                 skip_blank_lines=True,
                                 header=0)
                filearray[:, idx] = np.array(df)[:, 0]
                del df
            fname = ex + "_{:03d}".format(flies + 1)
            if os.name == 'nt':
                outfold = "E:/Dennis/Google Drive/PhD Project/Archive/VERO/vero_elife_2016/"
            else:
                outfold = "/Users/degoldschmidt/Google Drive/PhD Project/Archive/VERO/vero_elife_2016/"
            #fullname = _files+os.sep+"new_files"+os.sep+fname
            fullname = outfold + fname
            print("Saving data for:", fname)
            print("Runtime:", strfdelta(now() - startdt, "%H:%M:%S"))
            np.savetxt(fullname + ".csv",
                       filearray,
                       fmt='%.3f',
                       delimiter='\t',
                       newline='\n',
                       header='body_x\tbody_y\thead_x\thead_y')
Ejemplo n.º 2
0
                    if delta < 0:
                        this_file = self.data[sortkeys[ind]]["filename"]
                        that_file = self.data[sortkeys[ind + 1]]["filename"]
                        messagebox.showwarning(
                            "Warning: Overlap detected",
                            base(this_file) + " and " + base(that_file) +
                            " seem to overlap. Glued data will be invalid.")
                        self.buffer.append(0)
                    else:
                        self.buffer.append(secs(end) - secs(start))
                    self.refresh_fig(np.array([secs(start),
                                               secs(end)]),
                                     np.array([1, 1]),
                                     'r-',
                                     resize=False)
        else:
            self.clear_fig()


def main(argv):
    app = App()
    app.root.mainloop()


if __name__ == "__main__":
    #_apppath = '/Users/degoldschmidt/workspace/ribeirolab-codeconversion/python/flyPAD/'
    startdt = now()
    #os.chdir(_apppath)
    main(sys.argv[1:])
    print("Done. Runtime:", strfdelta(now() - startdt, "%H:%M:%S"))