def main(dir):
    container = NDataContainer(load_on_fly=True)
    container.add_axona_files_from_dir(dir, recursive=True)
    container.setup()
    print(container.string_repr(True))
    nca.place_cell_summary(
        container, dpi=200, out_dirname="nc_spat_plots", output_format="pdf",
        burst_thresh=6, isi_bin_length=1, filter_place_cells=False)
Example #2
0
def main(dir):
    container = NDataContainer(load_on_fly=True)
    container.add_axona_files_from_dir(dir, recursive=True)
    container.setup()
    print(container.string_repr(True))
    nca.place_cell_summary(container, dpi=200, out_dirname="nc_spat_plots")
def main(args, config):
    # Unpack out the cfg file into easier names
    in_dir = config.get("Setup", "in_dir")
    regex_filter = config.get("Setup", "regex_filter")
    regex_filter = None if regex_filter == "None" else regex_filter
    analysis_flags = json.loads(config.get("Setup", "analysis_flags"))
    tetrode_list = json.loads(config.get("Setup", "tetrode_list"))
    should_filter = config.getboolean("Setup", "should_filter")
    seaborn_style = config.getboolean("Plot", "seaborn_style")
    plot_order = json.loads(config.get("Plot", "plot_order"))
    fixed_color = config.get("Plot", "path_color")
    fixed_color = None if fixed_color == "None" else fixed_color
    if len(fixed_color) > 1:
        fixed_color = json.loads(fixed_color)
    s_color = config.getboolean("Plot", "should_color")
    plot_outname = config.get("Plot", "output_dirname")
    dot_size = config.get("Plot", "dot_size")
    dot_size = None if dot_size == "None" else int(dot_size)
    summary_dpi = int(config.get("Plot", "summary_dpi"))
    hd_predict = config.getboolean("Plot", "hd_predict")
    output_format = config.get("Output", "output_format")
    save_bin_data = config.getboolean("Output", "save_bin_data")
    output_spaces = config.getboolean("Output", "output_spaces")
    opt_end = config.get("Output", "optional_end")
    max_units = int(config.get("Setup", "max_units"))
    isi_bound = int(config.get("Params", "isi_bound"))
    isi_bin_length = int(config.get("Params", "isi_bin_length"))

    setup_logging(in_dir)

    if output_format == "pdf":
        matplotlib.use("pdf")

    if seaborn_style:
        sns.set(palette="colorblind")
    else:
        sns.set_style("ticks", {
            'axes.spines.right': False,
            'axes.spines.top': False
        })

    # Automatic extraction of files from starting dir onwards
    container = NDataContainer(load_on_fly=True)
    out_name = container.add_axona_files_from_dir(in_dir,
                                                  tetrode_list=tetrode_list,
                                                  recursive=True,
                                                  re_filter=regex_filter,
                                                  verbose=False,
                                                  unit_cutoff=(0, max_units))
    container.setup()
    if len(container) is 0:
        print(
            "Unable to find any files matching regex {}".format(regex_filter))
        exit(-1)

    # Show summary of place
    if analysis_flags[0]:
        place_cell_summary(container,
                           dpi=summary_dpi,
                           out_dirname=plot_outname,
                           filter_place_cells=should_filter,
                           filter_low_freq=should_filter,
                           opt_end=opt_end,
                           base_dir=in_dir,
                           output_format=output_format,
                           isi_bound=isi_bound,
                           isi_bin_length=isi_bin_length,
                           output=plot_order,
                           save_data=save_bin_data,
                           fixed_color=fixed_color,
                           point_size=dot_size,
                           color_isi=s_color,
                           burst_thresh=6,
                           hd_predict=hd_predict)
        plt.close("all")

    # Do numerical analysis of bursting
    should_plot = analysis_flags[2]
    if analysis_flags[1]:
        import re
        out_name = remove_extension(out_name) + "csv"
        out_name = re.sub(r"file_list_", r"cell_stats_", out_name)
        print("Computing cell stats to save to {}".format(out_name))
        cell_classification_stats(in_dir,
                                  container,
                                  out_name,
                                  should_plot=should_plot,
                                  opt_end=opt_end,
                                  output_spaces=output_spaces)

    # Do PCA based analysis
    if analysis_flags[3]:
        print("Computing pca clustering")
        pca_clustering(container, in_dir, opt_end=opt_end, s_color=s_color)