Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] FIX: make screenshot() before starting movie #156

Merged
merged 4 commits into from
Jul 5, 2016

Conversation

christianbrodbeck
Copy link
Collaborator

I sometimes get an issue where the first screenshot() is returned at a different resolution (traceback below). If this is not just my system then this PR would fix that.

In [6]: brain.save_movie('R2262-loosetttt.mov', time_dilation=.004)
WARNING:root:IMAGEIO FFMPEG_WRITER WARNING: input image is not divisible by macro_block_size=16, resizing from (739, 800) to (752, 800) to ensure video compatibility with most codecs and players. To prevent resizing, make your input image divisible by the macro_block_size or set the macro_block_size to None (risking incompatibility). You may also see a FFMPEG warning concerning speedloss due to data not being aligned.
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-ca7ef3819486> in <module>()
----> 1 brain.save_movie('R2262-loosetttt.mov', time_dilation=.004)

/Users/christian/Code/PySurfer/surfer/viz.py in save_movie(self, fname, time_dilation, tmin, tmax, framerate, interpolation, codec, bitrate, **kwargs)
   2253         images = (self.screenshot() for _ in
   2254                   self._iter_time(time_idx, interpolation))
-> 2255         imageio.mimwrite(fname, images, **kwargs)
   2256 
   2257     def animate(self, views, n_steps=180., fname=None, use_cache=False,

/Users/christian/anaconda/envs/mayavi/lib/python2.7/site-packages/imageio/core/functions.pyc in mimwrite(uri, ims, format, **kwargs)
    316 
    317             # Add image
--> 318             writer.append_data(im)
    319 
    320     # Return a result if there is any

/Users/christian/anaconda/envs/mayavi/lib/python2.7/site-packages/imageio/core/format.pyc in append_data(self, im, meta)
    464             im = asarray(im)
    465             # Call
--> 466             return self._append_data(im, total_meta)
    467 
    468         def set_meta_data(self, meta):

/Users/christian/anaconda/envs/mayavi/lib/python2.7/site-packages/imageio/plugins/ffmpeg.pyc in _append_data(self, im, meta)
    559             # Check size of image
    560             if size != self._size:
--> 561                 raise ValueError('All images in a movie should have same size')
    562             if depth != self._depth:
    563                 raise ValueError('All images in a movie should have same '

ValueError: All images in a movie should have same size

@@ -37,6 +37,7 @@ def test_offscreen():
"""
mlab.options.backend = 'auto'
brain = Brain(*std_args, offscreen=True)
_ = brain.screenshot()
shot = brain.screenshot()
assert_array_equal(shot.shape, (800, 800, 3))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also get the same issue in the tests, and can fix it with taking an additional screenshot. Before adding the new line I got

AssertionError: 
Arrays are not equal

(mismatch 33.3333333333%)
 x: array([765, 800,   3])
 y: array([800, 800,   3])

Is that specific to my setup? I am using Mayavi from Anaconda (where Mayavi is still at 4.4.0 and forces Anaconda to 2.3) on OS X 10.11...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably a Mayavi quirk. Just add a comment here, too, about Mayavi giving the wrong resolution on OSX sometimes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the comment

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 76.135% when pulling b279db2 on christianbrodbeck:imageio into 79beb15 on nipy:master.

@coveralls
Copy link

coveralls commented Jul 4, 2016

Coverage Status

Coverage increased (+0.02%) to 76.186% when pulling b279db2 on christianbrodbeck:imageio into 79beb15 on nipy:master.

@christianbrodbeck christianbrodbeck changed the title FIX: make screenshot() before starting movie [MRG] FIX: make screenshot() before starting movie Jul 4, 2016
@christianbrodbeck
Copy link
Collaborator Author

@Eric89GXL I added the comment

@larsoner larsoner merged commit 75daf55 into nipy:master Jul 5, 2016
@larsoner
Copy link
Contributor

larsoner commented Jul 5, 2016

Thanks @christianbrodbeck

@christianbrodbeck christianbrodbeck deleted the imageio branch February 9, 2017 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants