# Breakdown after stimulus random stop

**URL:** <https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867>\
**Category:** Builder\
**Tags:** randomization\
**Created:** [July 5, 2022, 5:38pm UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867 "2022-07-05T17:38:02Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ange](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Ange](https://discourse.psychopy.org/u/Ange)\
**Post date:** [July 5, 2022, 5:38pm UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867/1 "2022-07-05T17:38:02Z")

</div>

**OS** (e.g. Win10): Win10  
**PsychoPy version** (e.g. 1.84.x): 2022.2.1  
**What are you trying to achieve?:**  
I have this experiment and my question is about the ‘movies’-routine:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/9/d/9db5d37c3bf0fdd9c3454ff698b946f8edf9469a.png)

I show movies and want them to stop at different moments, in a random order as specified in the code:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/1/9/19d530bcef56bfe3200829b5c41f1f39541818fc.png)

And it actually works, the movie stops at one of these durations - but not only the movie stops, but the whole experiment, it doesn’t go to the next routine.

At the beginning and the end of the routine I did the following:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/9/f/9fdd98529c3231307ac7d285993212396fc8b154.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/2/c/2cd726cd2c4223ca38bd9ec3e1a4d6689b73abfd.png)

in the movie properties, I specified the Stop duration with the created variable:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/8/b/8bdbde085324ec6c93c053c3d36991cfa2e45b6e.png)

My loops looks like this, each movie should be shown once:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/1/c/1c907f0c4bbbe0f5a3a31558aab7844599075d2d.png)

**What specifically went wrong when you tried that?:**  
When I run the experiment, the movie stops as I desire, but also the whole experiment stops and  
I get the following error message:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/c/7/c709ad1ad44368e539c701d60e0e2f4a0beb8c7d.png)

If anyone has an idea why the whole experiment stops, I would be thankful to learn about it 🙂 Thank you very much!!

---

<div class="post-metadata">

**Author:** ![Jdigg](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@Jdigg](https://discourse.psychopy.org/u/Jdigg)\
**Post date:** [July 6, 2022, 8:42am UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867/2 "2022-07-06T08:42:32Z")

</div>

If you change $stim\_dur to stim\_dur[trials\_3.thisN] does it run further along? I don’t think the “$” is required with the timing boxes, but if that doesn’t work try it with the “$” back in front.

---

<div class="post-metadata">

**Author:** ![Ange](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Ange](https://discourse.psychopy.org/u/Ange)\
**Post date:** [July 6, 2022, 9:10am UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867/3 "2022-07-06T09:10:49Z")

</div>

Hi 🙂  
Thank you for your reply.  
With this specification, the movies don’t start to play anymore (with and without $).  
I don’t know if it matters, but the output data file the trials\_3.thisN column empty

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/c/c/cc65026a657b5342a8b373a2893b342da6b8d3b5.png)

I get the following error:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/4/e/4eb97d65ecf6a7db38952e0c5f6afdbbbb7d423e.png)

---

<div class="post-metadata">

**Author:** ![Jdigg](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@Jdigg](https://discourse.psychopy.org/u/Jdigg)\
**Post date:** [July 6, 2022, 1:07pm UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867/4 "2022-07-06T13:07:48Z")

</div>

Does it playthrough if you put in a time instead of a coded time? So if you put a duration of 10 seconds for testing purposes, does it move to the next file or does it still throw an error?

---

<div class="post-metadata">

**Author:** ![Ange](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Ange](https://discourse.psychopy.org/u/Ange)\
**Post date:** [July 6, 2022, 2:01pm UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867/5 "2022-07-06T14:01:33Z")

</div>

Yes, if I put 10 sec it works fine.

---

<div class="post-metadata">

**Author:** ![Ange](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Ange](https://discourse.psychopy.org/u/Ange)\
**Post date:** [July 10, 2022, 8:44pm UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867/6 "2022-07-10T20:44:58Z")

</div>

Anyone has some further ideas how I can make my experiment run? 🙏

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [July 13, 2022, 5:13am UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867/7 "2022-07-13T05:13:54Z")

</div>

Could you please provide a copy of

- the `.log` file from your `data` folder (after running with your initial set-up, not with the suggested fix above)?
- your Builder `.psyexp` file, and
- the `empathymovie.xlsx` conditions file.

But before doing that, please:

- delete the `sstim_dur = 0` from the “begin experiment” tab – it isn’t (or shouldn’t) be doing anything, if `sstim_dur` gets defined in the “begin routine” tab.
- please also confirm the actual durations of the movie files – in particular, do they all exceed 60 s?

PS Your approach seems perfectly sensible – so it isn’t clear why it isn’t working.

---

<div class="post-metadata">

**Author:** ![Ange](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Ange](https://discourse.psychopy.org/u/Ange)\
**Post date:** [July 13, 2022, 8:58am UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867/8 "2022-07-13T08:58:47Z")

</div>

Hello,

Thank you so much for your reply.  
All movie files are longer than 1.41min.  
When I use the newest version of psychopy, the movies doesn’t start because PsychoPy does not respond anymore. In this version I upload now, I used the version 2020.1.1.

A second point that occurs now is that the movie presentation is 50 or 60 sec, even though I put the code on showing between 0.5 and 3 sec.

Here are the 3 files:  
[psychpyZip.zip](https://discourse.psychopy.org/uploads/short-url/ncbuRD54HEReo6yipLoZ4cHKLDF.zip) (10.8 KB)

Thank you very very much!

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [July 14, 2022, 10:31pm UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867/9 "2022-07-14T22:31:46Z")

</div>

Thanks, that all seems OK, although the log file doesn’t give any useful information.

> [@Ange](#):
>
> When I run the experiment, the movie stops as I desire, but also the whole experiment stops and  
> I get the following error message:

Going back to you original report, can you scroll up there and provide the entire error report? I’m guessing it starts earlier and will give us a clue as to where in your script (as opposed to within `ffpyplater_player.py`) the error arises.

---

<div class="post-metadata">

**Author:** ![Ange](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Ange](https://discourse.psychopy.org/u/Ange)\
**Post date:** [July 15, 2022, 8:56am UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867/10 "2022-07-15T08:56:55Z")

</div>

Hi Michael,

thanks so much for your help.  
Here is the complete error report

Traceback (most recent call last):  
File “C:\Program Files\PsychoPy\lib\runpy.py”, line 194, in \_run\_module\_as\_main  
return \_run\_code(code, main\_globals, None,  
File “C:\Program Files\PsychoPy\lib\runpy.py”, line 87, in \_run\_code  
exec(code, run\_globals)  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 253, in   
compileScript(args.infile, args.version, args.outfile)  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 242, in compileScript  
thisExp = \_getExperiment(infile, version)  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 137, in \_getExperiment  
thisExp = experiment.Experiment()  
File “C:\Users\rwolm\AppData\Roaming\psychopy3\versions\psychopy\experiment\_experiment.py”, line 89, in **init**  
_settingsComp = getComponents(fetchIcons=False)[‘SettingsComponent’]  
File "C:\Users\rwolm\AppData\Roaming\psychopy3\versions\psychopy\experiment\components\_init_.py", line 153, in getComponents  
if hasattr(module, ‘ **file** ’) and module. **file**.endswith(‘.pyc’):  
AttributeError: ‘NoneType’ object has no attribute ‘endswith’

## Running: C:\Users\rwolm\OneDrive\Desktop\Bianca Francesca\empathy - Copy\_lastrun.py

pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)  
136.8279 EXP Imported empathymovie.xlsx as conditions, 5 conditions, 1 params  
136.8320 EXP Imported empathymovie.xlsx as conditions, 5 conditions, 1 params  
136.8399 EXP Imported VAS.xlsx as conditions, 6 conditions, 1 params  
136.8400 WARNING duplicate variable names: empathymovies  
136.8485 INFO Loaded monitor calibration from [‘2022\_07\_02 13:30’]  
136.8923 EXP Imported empathymovie.xlsx as conditions, 5 conditions, 1 params  
136.8964 EXP Imported empathymovie.xlsx as conditions, 5 conditions, 1 params  
136.9007 EXP Imported VAS.xlsx as conditions, 6 conditions, 1 params  
136.9008 WARNING duplicate variable names: empathymovies  
Traceback (most recent call last):  
Hello from the pygame community. [Contribute - pygame wiki](https://www.pygame.org/contribute.html)  
9.1511 WARNING launchHubServer: If using the iohub mouse or eyetracker devices, fullScr should be True.  
File “C:\Users\rwolm\OneDrive\Desktop\Bianca Francesca\empathy - Copy\_lastrun.py”, line 489, in   
movie.stop()  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movies\__init_\_.py”, line 346, in stop  
self.\_player.stop(log=log)  
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\movies\players\ffpyplayer\_player.py”, line 831, in stop  
raise RuntimeError(“Cannot close stream, not opened yet.”)  
RuntimeError: Cannot close stream, not opened yet.  
[ffpyplayer\_abuffersink @ 000001e527b70140] Removing channel layout 0x3, redundant with 2 channels  
1.7275 WARNING Monitor specification not found. Creating a temporary one…  
[ffpyplayer\_abuffersink @ 000001e527b6f340] Removing channel layout 0x3, redundant with 2 channels  
################# Experiment ended with exit code 1 [pid:9976] #################  
182.5773 EXP Imported empathymovie.xlsx as conditions, 5 conditions, 1 params  
182.5816 EXP Imported empathymovie.xlsx as conditions, 5 conditions, 1 params  
182.5858 EXP Imported VAS.xlsx as conditions, 6 conditions, 1 params  
182.5858 WARNING duplicate variable names: empathymovies  
182.5881 INFO Loaded monitor calibration from [‘2022\_07\_02 13:30’]

---

<div class="post-metadata">

**Author:** ![Ange](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Ange](https://discourse.psychopy.org/u/Ange)\
**Post date:** [August 3, 2022, 4:23pm UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867/11 "2022-08-03T16:23:54Z")

</div>

There is no solution for this error ?

> raise RuntimeError(“Cannot close stream, not opened yet.”)

---

<div class="post-metadata">

**Author:** ![Ange](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Ange](https://discourse.psychopy.org/u/Ange)\
**Post date:** [August 4, 2022, 9:14pm UTC](https://discourse.psychopy.org/t/breakdown-after-stimulus-random-stop/29867/12 "2022-08-04T21:14:29Z")

</div>

I was opening this new thread with maybe a more precise title: [Raise RuntimeError(“Cannot close stream, not opened yet.”)](https://discourse.psychopy.org/t/raise-runtimeerror-cannot-close-stream-not-opened-yet/30283)  
Maybe it helps to find a solution
