def main(args): """ main(args) Runs analyses with parser arguments. Required args: - args (dict): parser argument dictionary """ # set logger to the specified level logger_util.set_level(level=args.log_level) # args.device = gen_util.get_device(args.cuda) args.fontdir = DEFAULT_FONTDIR if DEFAULT_FONTDIR.is_dir() else None if args.dict_path != "": plot_dicts.plot_from_dicts(Path(args.dict_path), source="glm", plt_bkend=args.plt_bkend, fontdir=args.fontdir, parallel=args.parallel, datetime=not (args.no_datetime), overwrite=args.overwrite) else: if args.datadir is None: args.datadir = DEFAULT_DATADIR else: args.datadir = Path(args.datadir) mouse_df = DEFAULT_MOUSE_DF_PATH args = reformat_args(args) # get numbers of sessions to analyse if args.sess_n == "all": all_sess_ns = sess_gen_util.get_sess_vals(mouse_df, "sess_n", runtype=args.runtype, plane=args.plane, line=args.line, min_rois=args.min_rois, pass_fail=args.pass_fail, incl=args.incl, omit_sess=args.omit_sess, omit_mice=args.omit_mice) else: all_sess_ns = gen_util.list_if_not(args.sess_n) for sess_n in all_sess_ns: analys_pars = prep_analyses(sess_n, args, mouse_df) analyses_parallel = bool(args.parallel * (not args.debug)) run_analyses(*analys_pars, analyses=args.analyses, parallel=analyses_parallel)
def main(args): """ main(args) Runs analyses with parser arguments. Required args: - args (dict): parser argument dictionary """ # set logger to the specified level logger_util.set_level(level=args.log_level) args.device = "cpu" if args.datadir is None: args.datadir = DEFAULT_DATADIR else: args.datadir = Path(args.datadir) args.mouse_df = DEFAULT_MOUSE_DF_PATH args.runtype = "prod" args.plane = "soma" args.stimtype = "gabors" args.omit_sess, args.omit_mice = sess_gen_util.all_omit( args.stimtype, args.runtype ) all_sessids = sess_gen_util.get_sess_vals( args.mouse_df, "sessid", runtype=args.runtype, sess_n=[1, 2, 3], plane=args.plane, min_rois=1, pass_fail="P", omit_sess=args.omit_sess, omit_mice=args.omit_mice) # bsizes =[1, 15, 30] #3 # outchs = [18, 9, 3] # hiddims = [100, 35, 5] # numlays = [3, 2, 1] # lr_exs = [4, 3, 5] # convs = [True, False] # args.n_epochs = 0 gen_util.parallel_wrap( run_sess_lstm, all_sessids, args_list=[args], parallel=args.parallel)
def main(args): """ main(args) Runs analyses with parser arguments. Required args: - args (dict): parser argument dictionary """ # set logger to the specified level logger_util.set_level(level=args.log_level) args.fontdir = DEFAULT_FONTDIR if DEFAULT_FONTDIR.is_dir() else None if args.dict_path is not None: source = "acr_sess" if args.modif: source = "modif" plot_dicts.plot_from_dicts(Path(args.dict_path), source=source, plt_bkend=args.plt_bkend, fontdir=args.fontdir, parallel=args.parallel, datetime=not (args.no_datetime), overwrite=args.overwrite) else: if args.datadir is None: args.datadir = DEFAULT_DATADIR else: args.datadir = Path(args.datadir) mouse_df = DEFAULT_MOUSE_DF_PATH args = reformat_args(args) analys_pars = prep_analyses(args.sess_n, args, mouse_df, args.parallel) args.parallel = bool(args.parallel * (not args.debug)) run_analyses(*analys_pars, analyses=args.analyses, seed=args.seed, parallel=args.parallel, datatype=args.datatype)
def main(args): """ main(args) Runs analyses with parser arguments. Required args: - args (dict): parser argument dictionary """ # set logger to the specified level logger_util.set_level(level=args.log_level) plot_from_dicts(args.direc, source=args.source, plt_bkend=args.plt_bkend, fontdir=args.fontdir, plot_tc=not (args.not_plot_tc), parallel=args.parallel, datetime=not (args.no_datetime), pattern=args.pattern, depth=args.depth)
def main(args): """ main(args) Runs analyses with parser arguments. Required args: - args (dict): parser argument dictionary """ # set logger to the specified level logger_util.set_level(level=args.log_level) args.fontdir = DEFAULT_FONTDIR if DEFAULT_FONTDIR.is_dir() else None if args.dict_path is not None: source = "modif" if args.modif else "run" plot_dicts.plot_from_dicts(Path(args.dict_path), source=source, plt_bkend=args.plt_bkend, fontdir=args.fontdir, parallel=args.parallel, datetime=not (args.no_datetime), overwrite=args.overwrite) else: args = reformat_args(args) if args.datadir is None: args.datadir = DEFAULT_DATADIR else: args.datadir = Path(args.datadir) mouse_df = DEFAULT_MOUSE_DF_PATH # get numbers of sessions to analyse if args.sess_n == "all": all_sess_ns = sess_gen_util.get_sess_vals(mouse_df, "sess_n", runtype=args.runtype, plane=args.plane, line=args.line, min_rois=args.min_rois, pass_fail=args.pass_fail, incl=args.incl, omit_sess=args.omit_sess, omit_mice=args.omit_mice, sort=True) else: all_sess_ns = gen_util.list_if_not(args.sess_n) # get analysis parameters for each session number all_analys_pars = gen_util.parallel_wrap(prep_analyses, all_sess_ns, args_list=[args, mouse_df], parallel=args.parallel) # split parallel from sequential analyses bool(args.parallel * (not args.debug)) if args.parallel: run_seq = "" # should be run parallel within analysis all_analyses = gen_util.remove_lett(args.analyses, run_seq) sess_parallels = [True, False] analyses_parallels = [False, True] else: all_analyses = [args.analyses] sess_parallels, analyses_parallels = [False], [False] for analyses, sess_parallel, analyses_parallel in zip( all_analyses, sess_parallels, analyses_parallels): if len(analyses) == 0: continue args_dict = { "analyses": analyses, "seed": args.seed, "parallel": analyses_parallel, } # run analyses for each parameter set gen_util.parallel_wrap(run_analyses, all_analys_pars, args_dict=args_dict, parallel=sess_parallel, mult_loop=True)
def main(args): """ main(args) Runs analyses with parser arguments. Required args: - args (dict): parser argument dictionary """ # set logger to the specified level logger_util.set_level(level=args.log_level) args.device = gen_util.get_device(args.cuda) args.fontdir = DEFAULT_FONTDIR if DEFAULT_FONTDIR.is_dir() else None if args.comp == "all": comps = logreg.get_comps(args.stimtype, args.q1v4, args.exp_v_unexp) else: check_args(args.comp, args.stimtype, args.q1v4, args.exp_v_unexp) comps = gen_util.list_if_not(args.comp) args.output = format_output(args.output, args.runtype, args.q1v4, args.bal, args.exp_v_unexp) args_orig = copy.deepcopy(args) if args.dict_path is not None: plot_dicts.plot_from_dicts(Path(args.dict_path), source="logreg", plt_bkend=args.plt_bkend, fontdir=args.fontdir, parallel=args.parallel) else: for comp in comps: args = copy.deepcopy(args_orig) args.comp = comp args.not_ctrl = not (set_ctrl(not (args.not_ctrl), comp=args.comp)) logger.info( f"Task: {args.task}\nStim: {args.stimtype} " f"\nComparison: {args.comp}\n", extra={"spacing": "\n"}) if args.task == "run_regr": run_regr(args) # collates regression runs and analyses accuracy elif args.task == "analyse": logger.info(f"Folder: {args.output}") logreg.run_analysis(args.output, args.stimtype, args.comp, not (args.not_ctrl), args.CI, args.alg, args.parallel) elif args.task == "plot": logreg.run_plot(args.output, args.stimtype, args.comp, not (args.not_ctrl), args.visflow_dir, args.fluor, not (args.no_scale), args.CI, args.alg, args.plt_bkend, args.fontdir, args.modif) else: gen_util.accepted_values_error("args.task", args.task, ["run_regr", "analyse", "plot"])
def main(args): """ main(args) Runs analyses with parser arguments. Required args: - args (dict): parser argument dictionary """ # set logger to the specified level logger_util.set_level(level=args.log_level) if args.datadir is None: args.datadir = DEFAULT_DATADIR else: args.datadir = Path(args.datadir) args.mouse_df_path = DEFAULT_MOUSE_DF_PATH # Directory with additional fonts args.fontdir = DEFAULT_FONTDIR if DEFAULT_FONTDIR.exists() else None # warn if parallel is not used if args.overwrite and not (args.plot_only): if not args.parallel: warnings.warn( "Unless memory demands are too high for the machine being " "used, it is strongly recommended that paper analyses be run " "with the '--parallel' argument (enables computations to be " "distributed across available CPU cores). Otherwise, analyses " "may be very slow.", category=UserWarning, stacklevel=1) time.sleep(paper_organization.WARNING_SLEEP) # run through figure(s) and panel(s) if args.figure == "all": figures = paper_organization.get_all_figures() else: figures = [args.figure] sessions = None panel = args.panel for args.figure in figures: if panel == "all": panels = paper_organization.get_all_panels(args.figure) else: panels = [panel] for p, args.panel in enumerate(panels): new_fig = (p == 0) try: with gen_util.TimeIt(): sessions = run_single_panel(args, sessions=sessions, new_fig=new_fig) except Exception as err: sep = DOUBLE_SEP if new_fig else SEP if "Cannot plot figure panel" in str(err): lead = f"{sep}Fig. {args.figure}{args.panel.upper()}" logger.info(f"{lead}. {err}") else: raise err plot_util.cond_close_figs()