Exemple #1
0
    def agg(self, table):
        """aggregate interface
		table(string)
		"""
        datatable = "%s_%s" % (table, cherrypy.user.name)
        sid, trial, IVs, DVs, run, outlier, sids = common.getVariables(datatable, sids=False)

        check_vars = common.checkVariables(datatable, ["subject", "trial", "IV", "DV"])

        if check_vars:
            output = check_vars
        else:
            form = ""
            form += getCheckbox(IVs)
            form += getCheckbox(DVs)
            form += getCondition(IVs + DVs + [trial], "Include only data where:")

            output = "<p>Here are the variables you have labelled.  Select the ones you want to combine into your new file.  You will get a single file with each subject's average DV(s) for each IV(s).</p>"
            output += getForm(form, download_url, hidden=["dl", "agg"])

        return output
Exemple #2
0
    def index(self, **kwargs):
        u = cherrypy.user.name
        up = mt.MongoAdmin("datamaster").db["user_files"].posts

        output = ""

        aggregate = ""

        table = common.getCookie("datamaster_table")

        # select any tables
        if kwargs.has_key("select_table"):
            table = kwargs["select_table"]
            common.setCookie("datamaster_table", table)

        if table:
            tableName = "%s_%s_vars" % (table, cherrypy.user.name)
            posts = mt.MongoAdmin("datamaster").db[tableName].posts

            IVs = posts.find({"var_type": "IV"}).distinct("name")
            DVs = posts.find({"var_type": "DV"}).distinct("name")

            # aggregate, download
            datatable = "%s_%s" % (table, cherrypy.user.name)
            agg_out = common.checkVariables(datatable, ["subject", "trial"])
            if agg_out:
                aggregate = agg_out
                download_raw = agg_out
                multi_sub = agg_out
            else:
                aggregate = self.agg(table)
                download_raw = self.raw(table)
                multi_sub = self.onefile(table)

                # make_prts
            prts_out = common.checkVariables(datatable, ["subject", "trial", "run"])
            if prts_out:
                make_prts = prts_out
            else:
                make_prts = self.make_prts(table)

            if kwargs.has_key("dl"):
                if kwargs["dl"] == "agg":
                    output += self.aggregate(table, kwargs)
                elif kwargs["dl"] == "multi":
                    output += self.get_onefile(table, kwargs)
                else:
                    output += self.get_raw(table, kwargs)
            elif kwargs.has_key("prt_onset"):
                output += self.prts(table, kwargs)

        else:
            aggregate = no_table
            download_raw = no_table
            make_prts = no_table
            multi_sub = no_table

        dl = "<p>"
        fcount = 1
        for row in up.find({"user": u}):
            dl += "File %s : <a href='%s/output/%s'>%s</a><br/>" % (fcount, domain, row["fname"], row["fname"])
            fcount += 1
        dl += "</p>"

        items = [
            ["select table", select_table(download_url, table)],
            ["aggregate", aggregate],
            ["download multi-subject file", multi_sub],
            ["create single subject files", download_raw],
            ["make PRTs", make_prts],
            ["download existing file", dl],
        ]

        output += getAccordion(items, contentID="download-small")

        return getPage(output, "download", "download")