#Enter the specific # jsdata = request.form['v1data'] # specific_stimuli = jsdata # specific_stimuli = open('xhr.js', 'selected_value') specific_stimuli = '02_Berlin_S1.jpg' plaats = r"static\MetroMapsEyeTracking\data_csv\all_fixation_data_cleaned_up.csv" trdata = pd.read_csv(plaats, encoding='latin1', delimiter='\t') trdata.head() location_prefix = r"static\MetroMapsEyeTracking\stimuli\\" concatenate = location_prefix + specific_stimuli with Image.open(concatenate) as img: width, height = img.size testset = trdata[trdata['StimuliName'] == specific_stimuli].reset_index().copy() outofbounds = (testset['MappedFixationPointX']>width) | (testset['MappedFixationPointY']>height) | (testset['MappedFixationPointX']<0) | (testset['MappedFixationPointY']<0) maxduration = trdata[['FixationDuration']].max() meanduration = trdata[['FixationDuration']].mean() testset = testset[np.logical_not(outofbounds)].reset_index().copy() x=np.array([]) y=np.array([]) weight=np.array([]) for index, row in testset.iterrows(): x = np.append(x, np.array([row['MappedFixationPointX']])) y = np.append(y, np.array([row['MappedFixationPointY']])) weight = np.append(weight, np.array([row['FixationDuration']])) H, xe, ye = np.histogram2d(y, x, bins=500, weights=weight) H = filters.gaussian_filter(H, sigma=4) H = np.flipud(H) img_orig = plt.imread(concatenate) img = img_orig.copy().astype(np.uint8) if img.ndim == 2: # gray input img = cv2.cvtColor(img, cv2.COLOR_GRAY2RGBA) elif img.ndim == 3: # rgb input img = cv2.cvtColor(img, cv2.COLOR_RGB2RGBA) img = np.flipud(img) p = figure( x_range=(0, width), y_range=(height, 0), plot_width=int(width/2), plot_height=int(height/2) ) p.xaxis.visible = False p.yaxis.visible = False source = bokeh.plotting.ColumnDataSource(data=dict( img=[img], x=[0], y=[img.shape[0]], dw=[img.shape[1]], dh=[img.shape[0]], R=[img[::-1, :, 0]], G=[img[::-1, :, 1]], B=[img[::-1, :, 2]])) p.image_rgba(source=source, image='img', x='x', y='y', dw='dw', dh='dh') p.image(image=[H], x=0, y=height, dw=width, dh=height, palette="Viridis11", global_alpha=0.6)