SELECT_ALL=("SELECT coordinates from embody_answer")
SELECT_BY_EXP_ID='select coordinates from embody_answer as em JOIN (SELECT idanswer_set FROM answer_set as a JOIN experiment as e ON a.experiment_idexperiment=e.idexperiment AND e.idexperiment=%s) as ida ON em.answer_set_idanswer_set=ida.idanswer_set'
SELECT_BY_ANSWER_SET='select coordinates from embody_answer WHERE answer_set_idanswer_set=%s'
SELECT_BY_PAGE='select coordinates from embody_answer WHERE page_idpage=%s'
arg_parser=argparse.ArgumentParser(description='Draw bodily maps of emotions')
arg_parser.add_argument('-s','--stimulus',help='Select drawn points from certain stimulus',required=False,action='store_true')
arg_parser.add_argument('-e','--experiment',help='Select drawn points from certain experiment',required=False,action='store_true')
arg_parser.add_argument('-a','--answer-set',help='Select drawn points from certain answer_set',required=False,action='store_true')
arg_parser.add_argument('integers',metavar='N',type=int,nargs='+',help='an integer for the accumulator')
args=vars(arg_parser.parse_args())
value=args['integers'][0]
ifargs['stimulus']:
get_coordinates(value,SELECT_BY_PAGE)
elifargs['experiment']:
get_coordinates(value,SELECT_BY_EXP_ID)
elifargs['answer_set']:
get_coordinates(value,SELECT_BY_ANSWER_SET)
else:
print("No arguments given. Exit.")
sys.exit(0)
SELECT_ALL=("SELECT coordinates from embody_answer")
SELECT_BY_EXP_ID='select coordinates from embody_answer as em JOIN (SELECT idanswer_set FROM answer_set as a JOIN experiment as e ON a.experiment_idexperiment=e.idexperiment AND e.idexperiment=%s) as ida ON em.answer_set_idanswer_set=ida.idanswer_set'
exp_id=2
cursor.execute(SELECT_BY_EXP_ID,(exp_id,))
# Init coordinate arrays
x=[]
y=[]
# Loop through all of the saved coordinates and push them to coordinates arrays
forcoordinateincursor:
coordinates=json.loads(coordinate[0])
x.extend(coordinates['x'])
y.extend(coordinates['y'])
defmap_coordinates(a,b):
return[a,b]
coordinates=list(map(map_coordinates,x,y))
# Plot coordinates as points
plt.subplot2grid((2,2),(0,0))
plt.title("raw points")
plt.plot(x,y,'ro',alpha=0.2)
plt.imshow(image)
plt.grid(True)
# Draw circles from coordinates (imshow don't need interpolation)