psychopy / psychojs Goto Github PK
View Code? Open in Web Editor NEWPsychoJS is the online counterpart of the PsychoPy Python library
License: MIT License
PsychoJS is the online counterpart of the PsychoPy Python library
License: MIT License
Hey,
Not sure exactly where this issue should go as it's related to a JS error in the online version related to Pixi (so apologies if this should go the JS repo instead - please delete/close if in wrong place or if not relevant as it's from a separate library). Other than my movie playing issues, I've noticed another non fatal issue in the console while attempting to play movies with the part of the library responsible for the video base texture with Safari.
This is on the latest non technical preview build of Safari - have not checked other browsers but not seen this as an error anywhere else.
I don't think this is due to Pixi, I believe it's Safari (so again, not much of a fix possible I think but I wouldn't know how to get around it personally).
Error given in Console below:
[Error] Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission. (anonymous function) rejectPromise play _onCanPlay (pixi-4.8.1.min.js:16:13796) (anonymous function) e (pixi-4.8.1.min.js:16:12750) fromVideo (pixi-4.8.1.min.js:16:14212) fromVideo (pixi-4.8.1.min.js:16:5535) _updateIfNeeded (visual-3.0.5.js:346) setAutoDraw (core-3.0.5.js:1310) trialRoutineEachFrame (Movie_Mp4.js:133) _runNextTasks (util-3.0.5.js:1051) _runNextTasks (util-3.0.5.js:1044) update (util-3.0.5.js:1011)
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play (I'm using their explanation about the following because it's more succinct then what I can describe - this applies to using play but I believe it's a related error here):
"NotAllowedError
The user agent (browser) or operating system doesn't allow playback of media in the current context or situation. This may happen, for example, if the browser requires the user to explicitly start media playback by clicking a "play" button."
Basically, I know that Chrome and Safari and other major browsers were moving towards blocking auto-playing elements to stop people front-loading data heavy clips, especially on mobile that auto-play and sap your data allowance (or in fact, slow things down to a crawl or if you hide an iframe and just play an annoying ad constantly in the background on less then reputable sites) and to require an explicit user action before allowing anything to play. However, I've not run into this on desktop and I'm not entirely sure what the client side can do for this.
For the record, this is in the same experiment as my mp4 video test issues which I've mentioned on Discourse but here is the link for the experiment: https://pavlovia.org/run/Makataui/video-test/html/
Screenshot of video error included below with console showing:
Ferenc
In PsychoPy, you can change the color of your image component on every repeat or every frame using the Color
parameter in the Builder image component. However, the code that is used for the JavaScript is not working - where "image" is the name of the image component:
image.setColor(new util.Color('red'))
Example of current PsychoJS behaviour
https://pavlovia.org/run/dvbridges/imagefade/html/
Github isn't up to date with pavlovia version of psychojs:
We also need to add version 3.1.2 release version to pavlovia/lib
Response choice types as list currently create errors for the online version if fieldname/key has special character, such as a question mark. The special character is allowed when using the escape character, but the escape character is then presented in the string.
Error URL for list:
https://pavlovia.org/run/dvbridges/trialattributes/html/
We want to be able to force the browser into a fullscreen view, in the way that internet video players can go fullscreen. This should be an option for Window
The builder generated script stays in full screen display mode after quitPsychoJS requiring the user to exit full screen mode manually. I can see the advantage of this, but by default it should return the user to their normal display settings which are likely not full screen.
This could be done by fixing the builder translation to either add "document.exitFullscreen();" to quitPsychoJS, or to modify quitPsychoJS to take a boolean parameter to return full screen.
The size of the triangle marker is not scaling the with vertical dimension of the Slider, and as a result looks too big
Hi @apitiot -
Seems like ShapeStims in builder (3.0.5) are always compiled as Rect stims, although ShapeStim is a valid component and already exists. Is this something that you've already updated without pushing back to github? Any reason for this builder shortcut?
Super-basic example of a "triangle" shape stim compiled as a Rect with a coded shapestim side-by-side:
Today, a user reported the following error:
{ “origin”: “pavlovia.org”, “context”: “when signing in”, “error”: “mismatched states for OAuth2 authentication, possible CSRF attack?”}
On my home Linux box, I also received this error today. So, not specific to one computer, as I had previously thought.
See the URL below for an example. In the example, a valid click of either the "Click Me!" text or the polygon rect should end the trial. The text component that does not register valid clicks with the mouse, and the trial does not end when the text component is clicked. The polygon component works correctly to end the trial when clicked.
URL to example
https://pavlovia.org/run/dvbridges/textcontains/html/
Hey, cool project. I have two questions:
I am currently working on combining two projects (openexp and expfactory that would work to support deploying experiments in an electron app or web page powered by different backends such as jspsych or perhaps soon psychojs.
I think this should be an option rather than requirement - the current system of csv files being pushed to git is going to be nice for some people, but only if they do a good job of keeping personal that can be fully removed.
Given the idea of pavlovia having a data-submission API the activate step should have some way of setting what format the data will be?
We've started on the Form class in PsychoPy, supporting a spreadsheet of questions as an input and laying them out, with various answer options (slider, choices, free text).
The PsychoPy implementation is rendered by us manually using the Slider class and text stimuli (free text will need textbox2 to be completed) but potentially for the JS version it could be done with other controls and integrated with GL canvas?
A text engine that supports text entry (TextStim only allows display) and provides a border and background color.
This probably needs TextBox2 to be completed on the Python side but otherwise we could just agree the params/attributes and code simultaneously
Appears to be resolved when there are fewer or smaller images.
Was brought up on the forum:
https://discourse.psychopy.org/t/online-script-throwing-webgl-loss-of-context
Warning: Unpleasant content in one of the video files
A user wants to play movies from Pavlovia. They upload ok, but the experiment freezes when you click "Ok" to begin, and then the Pavlovia dashboard also freezes.
project deleted
If there is a preferred file type (e.g., not .wmv) or file size limit, perhaps we can put this as a warning, or document it.
After you start a task, by clicking OK
in the starting GUI, the screen does not switch to full screen with Chrome, but it does with Firefox. However, if Chrome is not already full size, the browser will switch to full screen mode after the start up GUI.
URL of an example task
https://pavlovia.org/run/dvbridges/coloredrects/html/
Two examples of empty trials being added to the trial handler, probably related to the condition files formatting.
Example 1
https://pavlovia.org/run/dvbridges/dpbe_l2/html/
Example 2
https://pavlovia.org/run/FrankBartel/epp3-keyboard/html/
Slightly different example with what may be errors in filenaming - filenames starting with numbers do not work - perhaps we can warn users in PsychoPy as well
https://pavlovia.org/run/jvcasillas/dpbe_l2/html/
To fix this issue, users are currently required to:
In PsychoPy, the setPos
function allows users to set a position for the mouse at any point in a routine.
By the summer we need to be able to receive payments, assign to users and consume them with participants (and this needs to be working flawlessly!)
When the color of the Slider is changed via the Color param in Sliders Builder component to black, the marker is visible (see demo below). The slider depth order also changes on click.
Here is an example:
// wait until document is ready:
$(document).ready(function() {{
psychoJS.frameCount=0;
win= new psychoJS.visual.Window({color:'green', size:(300,300)});
psychoJS.init(win);
s=new psychoJS.Scheduler();
t = new psychoJS.visual.TextStim({text:'hello wold', 'win':win,pos:(100,200), color: 'red'})
t2=new PIXI.Text('hello world 2');
task=function(){
t.draw();
// t.pixiRep.position={x:1,y:2}
win._container.addChild(t2);
console.log(win._container.children.length)
// win._renderer.render(win._container);
return
console.log(psychoJS.frameCount);
if( psychoJS.frameCount<500)return psychoJS.FLIP_REPEAT;
}
s.add(task);
s.start(win);
// s.run()
}})</script>
No error but the t
did not show while t2
is right.
And in the console , t._pos
is 200 . Why? I missed anything?
Filenames could give away info to the participant about the experiment. Best not to show them when loading resources
When saving data using psychoJS.experiment.addData
, list data is not being saved. For example, saving "all keys" for the keyboard, or mouse state on every frame, saves no data for that response device.
Example including a single data file, where keyboard responses are missing for all keys pressed
https://gitlab.pavlovia.org/dvbridges/mousetesting
https://pavlovia.org/run/dvbridges/mousetesting/html/
Response times should be measured from when the stimulus actually appears, not when it is requested. To do that we need to reset the RT clock when screen flip occurs. Most general way to do that (in keeping with psychopy) is with a Window.callOnFlip()
function. Operates a bit like the scheduler calls: first arg is the function, and further args to be passed to the function if needed.
We need code to detect the win flip and run the list of function calls then. That's the tricky bit, but seems possible using opengl trick with a flush() call. I think I sent a link on how to do that in an email a few months ago, but can't now find the details again. I'll go back to google and re-link here
As far as I can see we can't currently run more than one cycle of a set of conditions.
The code to select TrialHandler.thisTrial
is commented out at
Lines 163 to 172 in 65667d2
In the test examples we've indexed into the conditions file entries directly (i.e. not using the TrialHandler to do this)
Problem: I added a bunch of images to the wrong directory manually in html/resources
. I then moved them and git rm
'd them, so that they're now not in the current git tree. However, they are still being listed and found by resource loader and downloaded at the start of the task each time, which is doubling startup time for some already embarrassingly large images.
I suspect the pavlovia server is downloading a zip of the task and unzipping it to overwrite things instead of checking out a repo, and that the resource list is just built by listing the directory? I'm sure there's a way to reset this (maybe even a new fork of the repo), but it seems like something that would be helpful to fix.
Also, a feature request would be to not display the name of each resource in the loading dialogue but only show the progress, as the names of stimuli or other resources can sometimes have meaning that you wouldn't want a participant to see. If that sounds reasonable I'll add it as another issue.
Hello!
I found two bugs that occur when i want to dynamically set the position and/or size of a rectangle (shape stimulus). These bugs only happen in the online javascript version and not when i run the experiment locally in python
The first bug happens when the component is being initialized in the beginning of the experiment. PsychoJS is trying to set the position and size attributes with the variable, instead of giving them a placeholder value for the time being, which results in a reference error because the variable hasnt yet been pulled from the csv file.
The second bug is specifically related to the rectangle subclass (maybe some other shapes will have it as well). It happens when the size attribute is being dynamically adjusted at the beginning of the routine. PsychoJS is trying to use the setSize setter method, but it doesnt work because the rectangle has specific setWidth and setHeight methods, which have to be used instead.
This is my first time reporting bugs like this so i hope i provided enough info for you to fix the issue, i just thought since i spent my day trying to make my experiment work there might as well be some use from it for you guys as well :)
The desired behaviour is to break the current loop when loop.finished === true
, so no more trials in that loop are presented.
At the moment the csv data file doesn't indicate the condition that was being run. It needs columns for each of the attributes in the input conditions file for that trial
Is it true that continueRoutine
doesn't work in PsychoJS? I've been trying to write a conditional loop like in psychopy using continueRoutine
but it doesn't work. Just knowing that it doesn't work now is helpful. A fix is even better.
TrialHandler attributes (e.g., below) need to update every block and every trial:
.thisRepN - which repeat you are currently on
.thisTrialN - which trial number within that repeat
In PsychoPy, this happens within the trialhandler class (see __next__ iterator method).
Now that it was extracted from psychopy code body into a submodule I think it would make sense to make dedicated psychojs "project" and have releases etc
If a cell contains either a comma (e.g. a coordinate, an array or list) or a newline (a multi-line piece of text) then that cell needs to be written inside quotes. Note that newline chars could also differ according to the user's OS of course.
For example of new-line problems: https://discourse.psychopy.org/t/online-experiment-saved-data-was-format-misplacement/5986
Lets add a .editorconfig
file to the PsychoJS repository so we have consistent indentation for the HTML and JS files, see EditorConfig. Currently, the indentation in JS and HTML looks wrong because of GitHubs default settings (I think is 8 spaces for an indent?). Setting a .editorconfig
file allows us to define what indentation params should be used for specific file types. Below is all that is required...
# top-most EditorConfig file
root = true
# Don't use tabs for indentation.
[*]
indent_style = space
# (Please don't specify an indent_size here; that has too many unintended consequences.)
# Python files
[*.{py}]
indent_style = tab
indent_size = 4
# HTML+CSS/JS files
[*.{html,css,js}]
indent_style = tab
indent_size = 2
Hi,
I was looking through the files and cannot see any functions involving staircasing or QUEST thresholding. These are in psychopy and I was wondering if they were going to be in psychojs. Thanks.
A user has the occasional participant receiving a FILE_LOAD_ERROR while completing the personal info field during the experiment resource download stage.
The error reported on Discourse was found on Windows machine using Chrome - No further info given.
URL to the task
https://gitlab.pavlovia.org/AndreiRazvanCostea/edsc30
e.g. in the GET attributes
If the participant name or condition is passed in the GET attributes then we don't need to collect that in the dialog box.
If all attributes are passed then maybe we don't need the dialog box at all? Maybe we should keep it anyway though and just present the OK button (ie. don't present attributes that aren't needed but still have the dialog so that people get ready to start and resources load)
Leaving the sound duration empty in the Sound component gives a sound component parameter of secs: -1
e.g.,
sound = new Sound({
win: psychoJS.window,
value: 'A',
secs: -1,
});
In PsychoPy, secs: -1
should give an infinite duration tone, but online only a brief sound is played.
Last I knew (i.e. back in July) sounds only supported tones, but sound files were "imminent". Has that changed?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.