I am having trouble inserting an image as stimuli from the builder view. - psychopy

I am trying to import an image as stimuli from an excell spreadsheet. It is at .tiff image and am receiving this eror "targ.setImage(stimuli) NameError:name 'stimuli' is not defined. I named the column in excell 'stimuli' and used 'PsychoPy\VisualCC\Stimuli\targ.tiff' (without the quotations).
In the image properties I named it targ and set the image to $stimuli. From what I can tell this is accurate. Please advise.
Glitch_311

The usual cause for this error is that you need to set the button next to the image field to "set every repeat" rather than "constant".
The variable name "stimuli" only has meaning within the loop that refers to the conditions file containing it, so if the image is set to be constant, when the image is created at the start of the experiment, it tries to use the variable named "stimuli" but it doesn't exist yet.

Related

Replace a Picture in MS Word header with another in VBA

Using MS access I need to open a word document and change certain images within the header. Whilst I have the code to find and replace any text that I need, I do not quite understand how to replace an image keeping it to a specific width and height.
The header within the Word document is constructed using a basic table with 3 columns as depicted below. The image in the right hand column will need to change for a specific logo.
I have managed so far to add an image to the document using the following code which gives the expected result...
With WordDoc.StoryRanges(wdPrimaryHeaderStory)
.InlineShapes.AddPicture FileName:="test.jpg"
End With
I understand that this is due to me not specifying a specific location, size etc but I am struggling to find resources which would instead allow me to either remove and add a new image to the right column or just swap the images out.
EDIT 1:

Store image in Word document to insert later

I am currently building a word-template for a report. In this report are used red separators as part of the design. The separators are basically just images of red, curved lines.
Instead of copy and pasting these separators when needing them, is there a way to store the image somewhere in the document, allowing it to be inserted with just the click of a button in the ribbon? My first bet would be to create a macro somehow that would insert the image, however that would require the image to be stored in a very specific path on the computer.
As this document is gonna be used by lots of people without this image stored on their harddrive, i need another way.
Thanks so much in advance!
You could insert the images into bookmarks created via SET fields in, say, the document header, then reproduce them elsewhere in the document via cross-references. The images in the SET fields wouldn't themselves be visible.
For example:
{SET Image1 "Actual image1"}
to create the bookmark and
{REF Image1}
to display the image.
No code required.
By default, the size of the pictures when inserted via a cross-reference will be the same size as they are in the SET field, plus they'll be formatted as in-line with text.
If they're meant to be full-width images, simply make sure to insert the cross-reference into a new paragraph with 0 indenting.
To constrain the images' displayed size to something smaller than the width they're inserted into the SET field at, insert them into a table whose row height and/or column width has the required fixed dimension.
To apply text-wrapping, insert the cross-references into a table and format the table's wrapping as 'around'.
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac or, if you’re using a laptop, you might need to use Ctrl-Fn-F9); you can't simply type them or copy & paste them from this message.

Show picture/image from userform in print header, VBA MS Project

I am making a template and thought to store our logo.jpg inside a userform. Then I'll call this userform and insert the logo in the print header for each "macro activated" print.
So far I have managed to print the image only as numbers. Bits and bytes probably(?). I might be missing some conversion of the picture before printing:
FilePageSetupHeader Alignment:=pjLeft, Text:="&P" & UserForm1.Image1.Picture & " "
This prints as: 1-670746914 in the top left header.
What am I missing?
The syntax I found on MSDN gives the following parameters for inserting a picture:
&;P""path"" Inserts the specified image. An example would be &;P"" [My Documents] \Image.gif"". The term [My Documents] represents the full path to your My Documents folder.
My code makes a copy of the current view, make changes to the view settings, headers etc, before exporting to PDF and deleting the view again.
UserForm1.Image1.Picture is a picture object, not the path to the original source file. Once a picture is loaded into an image control, it is embedded and its original path is not stored.
Store the path the the picture so that you can reference it later (e.g. using the Tag property of the Image control). See Stack Overflow: VBA UserForm Get Filename for more details. (FYI: Excel and Project use the same UserForm object, so this is applicable.)
I gave up on saving the logo inside the Project file itself.
Instead I check if the logo exists inside "C:\CompanyLogo", if does not, create that direcotry and download it from imgur.

How do I differentiate between placeholders (Tags, Id, Name) on a template and have the label stay once the template is used in the presentation

I am creating a custom slide template with 8 picture placeholders and 4 text placeholders. The idea is that the user would "fill-in" the template with the text and images and once a macro is run, the values of the placeholders would be collected and added to a JSON file. Ideally, two picture placeholders (big_screen_i and small_screen_i) and one text placeholder (caption_i) would be collected as one JSON object. This set would be repeated 4 times on the same slide.
Here are my problems:
1) The name of the placeholder set in the slide master view changes when more than one of the same template is used (haven't pinpointed the exact trigger). The names also change once an image is inserted into the placeholder. Locating an object by name becomes unstable.
2) Using the .type of placeholder (picture vs text) doesn't differentiate between the big_screen_i and small_screen_i.
3) Tags and keys also change or disappear when using the template more than once (because of the repeated name).
4) I am unable to group the objects because its not possible to group placeholders.
Is there a way to identify each shape/placeholder and connect it to the added content?
Note: I am using powerpoint 2016 .potm file
Thank You!

How to draw a line on image using matlab where the end points are not able to specify?

I have used line() function in matlab to draw line over an image. The line is drawn successfully but the problem is it is not saving on the image or in other words I can't save the line drawn image. I need this lined image for later stages. I can see the lined image. But it is not shown when again that particular image is loaded.
Your question is too specific, but to give you an idea. Images in Matlab are saved as a matrix so you have a column and row of values.
You can alter or access a column or a row of an image easily using the : operator. For instance, to get the first row of data you can do img(1,:), that is to mean all elements in the first row.
I hope with this hint you can solve your problem easily.
You are probably looking for
hold on;
For example:
figure();
plot(1:10,1:10);
hold on;
plot(1:10,2:11,'r')