Calling to a different stimuli lists - psychopy

I need to call to a different column with the stimuli depending on a previous given response. I.e. age
ask for age
if age = X --> choose a certain stimuli column (or a certain xlsx file)
What would be the basic procedure to do this. I am new in Psychopy.
Thanks a lot
Elena

You can add a field for age to the experiment info dialog box shown at the beginning of each session. Then you can refer to that value later in code as expInfo['age'].
Let's say you have two columns in your conditions file, labelled list_A and list_B, and you want to use either of those to put values into a text stimulus. In that text stimulus, put a variable called something like $text_list. Then in a code component, in the "begin routine" tab, put something like this:
if expInfo['age'] > 30:
text_list = list_A
else:
text_list = list_B
The same principles apply if you want to select between .xlsx files. Put a variable name in the conditions file file field of the loop dialog, and in some routine prior to the loop, set that variable to contain the desired filename.

Related

Openpyxl How does one define print area from a variable or other input like max rows?

I am very new to python in general but have a set of code where I am needing to define the print area for multiple excel files. My code is built to step through thousands of files in a directory and they are all relatively similar but vary in row length.
I am trying to do something akin to:
worksheet.print_area = "['A1' : 'F' + str(max_rows)]"
The code above is not working because it is not a valid coordinate range because I am guessing the print.area function is requiring an exact range like [A1:F45]. But I am needing that last number to be able to change depending on the max rows within the sheet.
Any and all help is appreciated.

LibreOffice writer field calculations

In a LibreOffice writer document with a field of #temperature_farenheit. Is there a way to create a field named #temperature_celcius that would automatically calculate and insert the correct temperature?
And if this is possible, what types of fields do I use and how do I reference them for purposes of calculations.
This can be achieved with user variables. I'll give a start-to-finish example in painful detail for clarity, and hopefully universal applicability to other cases.
Open a new text document.
Enter some text like Water boils at °F (°C).
Put the cursor before °F where you would normally type the number.
From the menus, choose Insert→Fields→More Fields…
Go to the Variables tab. Choose Type: User Field.
Below that, you'll see each User Field gets a Name and a Value. It will not appear in your document, but enter a Name for this variable we're using to store "water's boiling temperature in degrees Fahrenheit," lets say: BoilF
Enter the Value you want stored in that variable, and accordingly shown in this field in the actual document text. Here, its: 212
Click the Insert button to actually add the field to your document. You should see 212 appear in the text.
You've now added the field, but also created a variable that can be used elsewhere. Now to do the math and use it elsewhere:
Leaving the Fields window open, put the cursor before °C.
In the Fields window, select Type: Insert Formula.
Below that, enter the Formula: (BoilF-32)*5/9
Click the Insert button. You should see 100 appear in the text.
Should you ever need to update a number pair, double-click the first number—that is, the User Field in your text. Example steps, using the above starting point:
Add to the sentence so it reads
Water boils at 212°F (100°C) atop Everest.
It's now wrong, so double-click 212.
The Edit Fields window will appear. In the Value box, enter 154.4 and click the OK button. It will do the math and both temperatures will update in the text.
Water boils at 154.4°F (68°C) atop Everest.
Be mindful of variable names. If you have 20 temperatures scattered through your text, you should in turn have 20 user variables, with thoughtfully-chosen names.

Variable in Generate Rows step in PDI

I want to use variable in 'Generate rows' step in Pentaho. How can i use it. I want to give a file path in a 'Value' field but that should not be static so that i can pass this value into my csv input.
I am not sure to understand your question (see #mat's comment), but as far as I can understand it, I wonder if you really need a Generate Rows.
The CSV Input File can read the file name from a variable. If you look near this field you'll see a small 'S' in a blue diamond shape. It means that you can put a variable in it, in the format ${var_name}.
This suppose that your variable is indeed a variable, as opposed to a field. You can get the list of variables by pressing on Ctrl+Space on any input box near the 'S' in blue diamond shape. You can add a variable either in defining in a previous job, either in the parameter list [Right-click anywhere and select Parameters], either by editing the kettle.properties [on the top menu Edit], either by specifying the variable value on the small panel that is presented to you each time you want to run a transformation.
With a Generate Rows, you define a field and there is no way to use a field for the filename in a CVS Input file. You can however use a field in a Text file input with the Accept file name from an other step check box, and telling spoon from which step and from which field. If you use this step, specify on the Content tab that the filetype is CSV.
you can use "for" javascript lang step and get variable to generate rows,

Storing user inputs for retrieving later

I have a spreadsheet where the user inputs various details on an inputs page and then presses a calculate button to get what they want. The inputs are strings, numbers and dates.
I want to save the inputs for each calculation for the user so that at a later date they could enter the calc id and not have to renter the inputs.
One simple way I thought of doing this was to copy the inputs when the calculation is run to another sheet with the inputs in a column with the calc id. Then just save future inputs in a separate column and lookup the correct column to retrieve the inputs at a later date.
I read this question - What are the benefits of using Classes in VBA? and thought it would be good to make a class called CalculationInputs that had all the details stored in one object. This may be overkill for what I need but i wanted to ask how other people would solve this simple task.
You can use Names to define variables within the scope of a workbook or worksheet. Typically these are used to define ranges, and more specifically dynamic ranges, but they can also be used to store static/constant values.
To create a Name manually, from the Formula ribbon, Names Manager:
Click on the "New" button, and then give it a meaningful name:
Make sure you put ="" in the "Refers To" field, if you leave it blank, the name will not be created.
Then when you press OK, or any time you go to the Names manager, you will see a list of all available Names in the workbook.
You can edit these through the Names manager, which is probably tedious, or you can easily use VBA and inputs to control them, for example:
Sub Test()
ActiveWorkbook.Names("MyAddress").RefersTo = "734 Evergreen Terrace"
End Sub
You could do something like this to capture the value, our use other macros or user firm code to assign the value to the Name.
Activeworkbook.Names("MyAddress").RefersTo = _
Application.Inputbox("please enter your address")
Etc.
If you run this, and then review the Names manager, you'll see the value has been updated:
In VBE, you can refer to the name like:
Debug.Print ActiveWorkbook.Names("MyAddress").Value '# Prints in the immediate pane
Range("A1") = ActiveWorkbook.Names("MyAddress").Value
These can also be accessed (read) from the worksheet, like:

Printing custom ranges or items in Word 2010 using VBA

I am fairly new to VBA (Word 2010) and I'm unsure if something I'd like to do is even possible in the way that I want to do it, or if I need to investigate completely different avenues. I want to be able to print ranges (or items) that are not currently enumerated as part of either wdPrintOutRange or wdPrintOutItem. Is it possible to define a member of a wd enumeration?
As an example, I'd like to be able to print comments by a particular user. wdPrintComments is a member of the wdPrintOutItem enumeration, but, I only want comments that have an Initial value of JQC. Can I define a wdPrintCommentsJQC constant? My code is reasonably simple; I have a userform that lets the user pick some settings (comments by user, endnotes only, etc.) and a Run button whose Click event should generate a PrintOut method with the proper attributes. Am I on the wrong track?
(If it matters, the Initial values will be known to me as I write the code. I have a discrete list.)
No, it's not possible to add a constant to a predefined enumeration type.
However, one possible way to do this would be to build a string of page numbers which contain the items you wish to print, open the print dialog in the "dialogs" collection, and set it to print a specified range, andinsert the string containing the list of pages (separate them with commas). Finally, execute the .show method of the print dialog to show it to the user and give them the opportunity to set any other items and click the "ok" button. I've done something very similar when I needed to print a specific chapter of a long document, and so I had to specify the "from" section and page and the "to" section and page for the user. Below I just show how to specify a list of pages instead of the ".form" and "to" I was using:
With Dialogs(wdDialogFilePrint)
.Range = wdPrintRangeOfPages
.Pages = "3,5,7-11"
.show
end with
I'm not sure how you want to print the comments (or other elements), but you could create another document and insert what you want to print on this document.
According to what you want, you could insert them as they were (comments, footnotes, etc) or as plain text, or any other format.