예제 #1
0
    def __init__(self, DB, sid=666, exp="", clear=False):
        """class which holds a list of Problem objects, args are:
		problems = list of problems
		sid = who these problems belong to
		exp = experiment in which these problems were collected
		"""

        self.DB = mongoTools.MongoAdmin(DB)
        if not exp:
            self.posts = self.DB.getTable("%s_problems" % sid)
        else:
            self.posts = self.DB.getTable("%s_%s_problems" % (sid, exp))
        self.sid = sid
        self.exp = exp

        if clear:
            self.posts.remove({})
예제 #2
0
    def loadFromDB(self, dbName, table, s_id="Subject"):
        import mongoTools
        db = mongoTools.MongoAdmin(dbName)
        p = db.getTable(table).posts

        subjects = p.distinct(s_id)

        keys = mongoTools.GetKeys(p)

        for s in subjects:
            VARs = {}

            for k in keys:
                VARs[k.replace('_', '.')] = []

            count = 0

            result = p.find({s_id: s})

            for r in result:
                for k in keys:
                    newKey = k.replace('_', '.')
                    if k in r.keys():
                        VARs[newKey].append(r[k])
                    else:
                        VARs[newKey].append('')

            #print VARs

            self.VARs = VARs
            self.fname = "%s.prt" % s

            self.makePRTDict()
            self.setColors()
            self.makePRT()
            self.writePRT()
예제 #3
0
import sys
import os
import glob
import random

sys.path.append('/home/cogdev/code/OpenPsyc/')

import mongoTools

try:
    number = sys.argv[1]
except:
    sys.stderr("You need to specify a participant ID")

db = mongoTools.MongoAdmin("CAT2")

posts = db.getTable("production_pre").posts

t_posts = db.getTable("training_sets").posts

v_posts = db.getTable("ver_sets").posts

p_posts = db.getTable("post_sets").posts

f = open("P_%s.csv" % number, "w")

t_posts.remove({'s_id': number})
v_posts.remove({'s_id': number})
p_posts.remove({'s_id': number})
예제 #4
0
파일: sorter.py 프로젝트: unshur/OpenPsyc
DB = "CAT3" 

sid = sys.argv[1]


pre = problem.Problems(DB, sid=sid)
post = problem.Problems(DB, sid=sid, exp="post")

pre.name= "pre"
post.name="post"

strats = ['calc', 'mem']

kinds = ['verified', 'erratic']

posts = mongoTools.MongoAdmin(DB).getTable("subject_stats")
#posts.remove({})

row = {}
row['sid'] = sid

for p in [pre, post]:
	
	d = {}
	for k in kinds:
		d[k] = {}
		row[k] = {}
		row[k] = {'tests' : []}
		testNorm = False
		for s in strats:
			row[k][s] = {'tests': []}		
예제 #5
0
sys.path.append('/home/cogdev/code/OpenPsyc/')

import mongoTools

#UPLOAD THE DATA FROM pre test AND THEN TRAIN

try:
    number = sys.argv[1]
except:
    sys.stderr("You need to specify a participant ID")

fileName = "pre/pre_%s*.csv" % number
dbName = "magnitude"
tableName = "pre"

db = mongoTools.MongoAdmin(dbName)

reader = mongoTools.ReadTable(fileName=fileName,
                              dbName=dbName,
                              tableName=tableName,
                              clear=True)

posts = db.getTable("pre").posts

t_posts = db.getTable("training_sets").posts

p_posts = db.getTable("post_sets").posts

f = open("P_%s.csv" % number, "w")

#GENERATE A TRAINING SET FROM THE pre test data
예제 #6
0
 def __init__(self, DB, table, sid):
     self.DB = mongoTools.MongoAdmin(DB)
     self.posts = self.DB.getTable(table).posts
     self.sid = sid
     self.analyze()