Forum Replies Created
-
AuthorPosts
-
September 21, 2020 at 4:11 pm in reply to: Enabling a button after text is entered without pressing Enter #6144
Jeremy
KeymasterIn that case let’s use a good old javascript function:
newTrial('test', newTextInput('testinput') .print() , newFunction( () => $("textarea.PennController-testinput").bind('keyup', e=> getTextInput('testinput').test.text(/\w/) .success( getButton('Next').enable() ) .failure( getButton('Next').disable() ) ._runPromises() ) ).call() , newButton('Next', 'Next') .print() .disable() .wait() )
Jeremy
-
This reply was modified 4 years, 9 months ago by
Jeremy. Reason: fixed errors in code - see messages below
September 21, 2020 at 3:52 pm in reply to: Enabling a button after text is entered without pressing Enter #6141Jeremy
KeymasterIsn’t it already the case?
September 21, 2020 at 3:24 pm in reply to: Enabling a button after text is entered without pressing Enter #6139Jeremy
KeymasterHello,
Since I haven’t implemented a callback command for the TextInput element that would listen to keypresses, the best solution is to use a Key element (for which there is a callback command) to listen to keypresses. Now, it reacts to keypresses so fast that immediately checking the value of the TextInput element in the callback block won’t capture the newly pressed key, so you want to add a slight delay, e.g. 5ms before checking it.
Here’s how to do it based on the example you give:
newTrial('test', newTextInput('test_input') .print() , // empty string means any key newKey('').callback( newTimer(5).start().wait() , getTextInput('test_input').test.text(/\w/) .success( getButton('Next').enable() ) .failure( getButton('Next').disable() ) ) , newButton('Next', 'Next') .print() .disable() .wait() )
Let me know if you have any questions
Jeremy
September 21, 2020 at 3:04 pm in reply to: Images won't load in experiment, but uploaded in resources #6138Jeremy
KeymasterHi,
Failing to preload resources that were successfully updated to your project most often results from one these things:
- A typo in the filename, ie. check the filename of the file under Resources, and also check how it is spelled in your script and/or table
- Still a typo matter, but maybe less obvious: case matters, pay special attention to whether the extension is lower- or upper-case
- A typo in the column name from your table that should provide the filename (eg. row.Colunm when the actual name of that column in your table is column)
- An unsupported format. Even if your filename ends with an extension that corresponds to a supported format, make sure that you didn’t actually save the file in a different format (eg. you saved it as a vector image but renamed is with a jpg extension—that just won’t work)
There could be other problems that cause the same behavior you’re describing. If you’re having trouble debugging this, feel free to send me a link to your experiment at support@pcibex.net
Also, note that the very first consent trial in your first block of code has no wait command anywhere, so it naturally won’t have time to show its content on the page before moving to the next trial. I don’t know why the trials from the Template command are not executed since they do contain a wait command, maybe your tables are empty, or you made a typo in their names
Jeremy
Jeremy
KeymasterHi Ruby,
Unfortunately what you’re describing won’t be feasible with PCIbex, or you’d need to code so many extra layers that it doesn’t really make sense to use PCIbex as a starting point.
PCIbex is ill-suited for any sort of multi-player study at the moment. Judging from a quick look around, it looks like there are some resources: Empirica, oTree, nodeGame, TurkServer, and there might be more. I have never designed an online synchronuous experiment, and am not familiar with those tools, so I can’t speak to how user-friendly they are.
Jeremy
Jeremy
KeymasterHello,
Unfortunately this is a known problem with Safari, which consecutive releases of PennController try to address with more or less (emphasis on less) success…
I’ll try to rethink the preloading method again for the next release, but in the meantime you should definitely package your audio files in one or several zip archives—you shouldn’t have any problem with that since you’re already hosting your resources on a dedicated server. Follow this guide for instructions, and don’t hesitate to ask any questions you might have
Jeremy
Jeremy
KeymasterHi Sam,
There is no difference between newVoiceRecorder("recorder") and newMediaRecorder("recorder", "audio"), so unfortunately MediaRecorder won’t provide you with a way to detect speech any more than VoiceRecorder.
You could probably listen for a sharp rise in the signal’s volume using the AudioContext javascript API, but it’s a little advanced (it also turns out to be quite unreliable on Safari, which no one on the Internet–except me–seems to have complained about so far…) and it doesn’t necessarily indicate speech, for example it could correspond to a mug spilling on a desk (though that would most likely be accompanied with vocal complaints too).
Not sure I’d have the time to implement that function, but if you’re comfortable with javascript or know someone who is, I’d be happy to help
Jeremy
September 14, 2020 at 7:37 pm in reply to: Best way to transfer HTML-based experiment to pcIBEX? #6121Jeremy
KeymasterHello,
Re-coding everything from scratch is probably still the fastest and easiest way, indeed. The integration of HTML documents in a (PC)Ibex experiment is rather limited, basically you can report data from input fields to the results file using log but here you’re talking about controlling the flow of the trial/experiment by waiting for a click on a particular element included in the HTML content.
I guess one workaround would be to do something like this:
newTrial( newHtml("test.html").print().log() , newFunction( ()=>new Promise(r=>$("input[type=submit]").bind('click', e=>{ e.preventDefault(); e.stopPropagation(); r(); return false; })) ).call( ) )
The call command on the Function element will pause the execution of the script until a submit button is clicked
Jeremy
Jeremy
KeymasterHi Daniela,
You can take two approaches: either use a negative test
testNot.text("")
or a positive test using a regextest.text(/[^\s]+/)
. The latter is more powerful, as it will only validate non-empty text, whereas the former would succeed even if the text only consists of spaces, for exampleJeremy
Jeremy
KeymasterThen you might also be interested in the EyeTracker element, although it’s important to note that it’s still very much an experimental feature and I don’t know that anyone has collected actual data with it yet (as noted on the linked page, one problem is cross-browser compatibility, which seriously compromises the recruitment of paid participants).
I’ll try to get to the documentation in the coming days, but you can already use the MouseTracker element: it is included in PennController, there’s just no documentation entry for it at the moment. Here’s an example of how to use it in one trial:
newTrial( newButton("Start").print("center at 50vw", "middle at 50vh").wait().remove() , newMouseTracker("mouse").log().start() , newCanvas("left", "40vw", "40vh").css("background","red").print("center at 25vw", "middle at 50vh"), newCanvas("right", "40vw", "40vh").css("background","blue").print("center at 75vw", "middle at 50vh"), newSelector("choice").add( getCanvas("left") , getCanvas("right") ).log().wait() , getMouseTracker("mouse").stop() )
Jeremy
Jeremy
KeymasterDear Ana-Maria,
There actually is a MouseTracker element in PCIbex, but it is not documented yet. Let me know if you’re interested and I’ll start writing the documentation. The only caveat is that it can quickly produce massive results files (because it stores coordinates every tens of milliseconds) so you want to make sure you only track during informative periods.
I’m not aware of studies comparing RTs online vs in-lab (not to say there aren’t, see reference in your own message!), but since (PC)Ibex is based on javascript, it will come with the same lag that is described in the paper you cite. Depending on the nature of your investigation, a 25ms lag may or may not be a serious concern. Florian Schwarz and I for example have conducted online visual-world experiments where participants select one of two images after listening to a sentence; RTs were of the order of seconds, and we found significant differences across conditions, in the order of hundreds of milliseconds. You can also check this message by Florian on the forums for references about work from David Embick’s lab on lexical priming.
Jeremy
Jeremy
KeymasterHello,
EDIT: sorry, I misunderstood what you were trying to do. You want to record during the Pic1 trials, not during the praPic1 trials. Just adapt the code below to the content of the Template command that you already have in your script (the one on "PicList1.csv"), changes should be minimal.
So you only have one practice trial that tries to record anything at the moment, the last one, and it doesn’t have time to do so because it reaches the end of the trial immediately after starting to record. Since you seem to want to use the same template for all your practice trials, let’s embed them in a Template command too:
AddTable("practice", `Image feather.png vacuum.png bat.b.png`) Template( "practice" , row => newTrial( "pracPic1" , newImage( row.Image ) .print() , newMediaRecorder("recorder", "audio") .record() .log() , newKey(" ") .wait() , getMediaRecorder("recorder") .stop() ) .log( "Image" , row.Image ) )
Of course I’m just using AddTable here because I can’t upload a CSV file to your project myself, but you should use an external CSV file rather than directly writing your table in the main script like that.
As a general rule of thumb, it’s a bad idea to try to record audio/video across trials (I’m not even sure it will work anyway) that’s why you should call stop before the trial ends, as in this example. This way, you’ll have one audio file per trial in your zip file. Take a look at UploadRecordings if you want more control over when the files are sent to the server
Let me know if you have questions
Jeremy
Jeremy
KeymasterHello,
An invalid-format message does not mean that the extension is wrong, but that the content of the file is not formatted in a way that PennController can parse. What separators do you use in your CSV file? Ideally you want to use commas, but tabs would work too. I think any other separator character (eg. simple space) will fail. Also, double-check how you handle quotes and escaping characters: if you have text cells containing the same character as your separator character (eg. typically a comma) you want to make sure that when you save your file as CSV, those cells are surrounded by quotes, to indicate that the character (eg. the comma) is not actually separating two columns in those cases.
Jeremy
Jeremy
KeymasterHi,
1. Every trial has a label, whether explicitly assigned or not. The standard way of assigning a trial a label with PennController is to provide a string as the first argument of newTrial, but there are special cases (eg. SendResult can directly create a trial labeled after its own argument string). Labels then allow you to manipulate the order of execution of your trials by referencing them in the Sequence command.
In your case, you label all the trials you generate from Practica_Espanol_ButtonNormal-1.csv "practica_spanish", because that’s the string you pass as the first argument of the newTrial command in your Template command. As a result, typing randomize("practica_spanish") somwhere in your Sequence command will insert all those trials, randomly ordered, at that point in the sequence of trials.
The other topic is almost a year old now, and uses native-Ibex syntax to insert trials that use the DashedSentence controller. With the introduction of the Controller element in PennController 1.7, there no longer is a need to resort to native-Ibex syntax in such cases. For your information however, in
"dashed", "DashedSentence", {s: row.Sentence}
, "dashed" is the label of the trial and "DashedSentence" is the name of the controller leveraged to generate the trial. To get the same output using full-PCIbex syntax, you would do this: newTrial( "dashed" , newController("DashedSentence", row.Sentence).print().wait() )2. What file exactly is exhibiting this problem? If it’s a main script file, make sure you don’t have another script file in data_includes that takes precedence over the one you’re updating. If it’s a CSV file in chunk_includes, did you make sure you reference the proper filename in your Template command? If you don’t pass any filename to it, Template will automatically use the CSV file whose name comes first, alpha-numerically speaking.
If deleting the experiment and reloading everything from git doesn’t fix things, it most likely means that the problem lies with the git repo, not with the farm.Jeremy
-
This reply was modified 4 years, 9 months ago by
-
AuthorPosts