def load_behavior_folders_from_matlab(path, name, timing_override = False): date_dirs = [os.path.join(path,x) for x in os.listdir(path) if os.path.isdir(os.path.join(path, x))] for date_dir in date_dirs: start_time = time.time() dirs = [os.path.join(date_dir, x) for x in os.listdir(date_dir) if 'cycle' not in x] for dir in dirs: cons = Cons(dir, timing_override) print('[***] LOADED {0:<50s} in: {1:3.3f} seconds'.format(dir, time.time() - start_time)) save_path = os.path.join(Config.LOCAL_DATA_PATH, Config.LOCAL_DATA_BEHAVIOR_FOLDER, name) save_name = cons.NAME_MOUSE + '__' + cons.NAME_DATE + '__' + cons.NAME_PLANE Config.save_cons_f(save_path, save_name, data=cons)
def load_single_from_matlab(data_path, save = True): start_time = time.time() eng = matlab.engine.start_matlab() cons = Cons(data_path) mat, _ = load_calcium_traces_from_matlab(cons.STORAGE_DATA, eng) print('Time taken to load matfiles: {0:3.3f}'.format(time.time() - start_time)) print(mat.shape) if save == True: mouse = cons.NAME_MOUSE date = cons.NAME_DATE plane = cons.NAME_PLANE save_path = os.path.join(Config.LOCAL_DATA_PATH, Config.LOCAL_DATA_SINGLE_FOLDER, mouse) save_name = date + '_' + plane Config.save_mat_f(save_path, save_name, data=mat) Config.save_cons_f(save_path, save_name, data=cons) return mat, cons
def load_timepoint_from_matlab(path, name, timing_override = False): eng = matlab.engine.start_matlab() data_path = os.path.join(path, 'data') data_wildcard = os.path.join(data_path, '*.mat') matfile_paths = glob.glob(data_wildcard) for p in matfile_paths: start_time = time.time() mat, obj_name = load_calcium_traces_from_matlab(p, eng) dir = eng.eval(obj_name + ".constants.DIR") dir = 'I' + dir[1:] cons = Cons(dir, timing_override) print('[***] LOADED {0:<50s} in: {1:3.3f} seconds'.format(p, time.time() - start_time)) save_path = os.path.join(Config.LOCAL_DATA_PATH, Config.LOCAL_DATA_TIMEPOINT_FOLDER, name) save_name = cons.NAME_MOUSE + '__' + cons.NAME_DATE + '__' + cons.NAME_PLANE Config.save_mat_f(save_path, save_name, data=mat) Config.save_cons_f(save_path, save_name, data=cons)