Skip to content

MRG, ENH: Add brain movies to rendered examples#8265

Merged
agramfort merged 7 commits intomne-tools:masterfrom
larsoner:video
Sep 23, 2020
Merged

MRG, ENH: Add brain movies to rendered examples#8265
agramfort merged 7 commits intomne-tools:masterfrom
larsoner:video

Conversation

@larsoner
Copy link
Copy Markdown
Member

@larsoner larsoner commented Sep 16, 2020

Eventually it would be nice to have animations play for some of our source modeling examples. I plan to:

  • Add time_viewer=False to brain.screenshot to allow getting the brain+traces instead of just the traces
  • Add movie embedding by using matplotlib's javascript (maybe just by subclassing their animation class?) and sphinx-gallery's animation code (maybe by making this public? not sure) turning brain outputs into matplotlib figures and using matplotlib_scraper(...) directly
  • Add # sphinx_gallery_brain_movie code parsing that does brain.save_movie(...) then uses the javascript to embed a movie
  • Add tests

Not 100% sure it will work or produce movies of a reasonable size, but it would be pretty cool if it worked.

@larsoner larsoner added this to the 0.22 milestone Sep 16, 2020
@larsoner
Copy link
Copy Markdown
Member Author

Okay seems to be working:

  • Landing page (400 kB GIF; static image is 288 kB)
  • MNE (7.7 MB; 55 sec instead of 35 sec on master)
  • LCMV (3.8 MB; Also takes ~6 minutes to generate rather than ~3 on master because software rendering of volumes is painfully slow)

HTML sizes can be reduced by reducing the _Brain dimensions, reducing framerates, going to static GIF files, or (maybe; much harder) changing how matplotlib embeds these things. I've already limited the time intervals to a pretty small range (50-150 ms). But maybe these are small enough already to be tolerable.

Let me know if people think it's worthwhile continuing and if so I'll add some tests.

@agramfort
Copy link
Copy Markdown
Member

agramfort commented Sep 23, 2020 via email

@larsoner
Copy link
Copy Markdown
Member Author

At least for dSPM on circle it's only an extra 20 sec. For LCMV volume I agree it's too much

@agramfort
Copy link
Copy Markdown
Member

agramfort commented Sep 23, 2020 via email

@larsoner
Copy link
Copy Markdown
Member Author

Yep, you have to tell it which examples to turn into movies via comments. So I can just deactivate the LCMV one for now. Then the only one that's a movie will be mne_dspm.

@agramfort
Copy link
Copy Markdown
Member

agramfort commented Sep 23, 2020 via email

Comment on lines +139 to +141
# The documentation website's movie is generated with:
# brain.save_movie(..., tmin=0.05, tmax=0.15, interpolation='linear',
# time_dilation=20, framerate=10, time_viewer=True)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@agramfort the scraper looks for a line that is # brain.save_movie( and if it's there actually makes one using the call (equivalently, anyway). So it allows/forces us to keep our narrative doc descriptive while also allowing us to specify parameters.

@agramfort
Copy link
Copy Markdown
Member

agramfort commented Sep 23, 2020 via email

@larsoner
Copy link
Copy Markdown
Member Author

Then the next question is: are there any other examples that you'd like to see turned into movies? I'd like a vector source estimate one, I can look for that.

@agramfort
Copy link
Copy Markdown
Member

agramfort commented Sep 23, 2020 via email

Copy link
Copy Markdown
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

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

LGTM pending removal of the LCMV movie for now

@larsoner larsoner changed the title WIP: Add brain movies to rendered examples MRG, ENH: Add brain movies to rendered examples Sep 23, 2020
@larsoner
Copy link
Copy Markdown
Member Author

Pushed a commit to fix the documentation of _Brain and add a couple more videos. Will post a link once it's done.

Should we make _Brain public? I feel like some parts are maybe not ready, but it would be nice for people to know about the API. I can do it in this PR and we can backport...

@larsoner
Copy link
Copy Markdown
Member Author

@larsoner
Copy link
Copy Markdown
Member Author

Missed visualize_stc image:

@agramfort agramfort merged commit 724f9ae into mne-tools:master Sep 23, 2020
@agramfort
Copy link
Copy Markdown
Member

thx @larsoner !

@larsoner
Copy link
Copy Markdown
Member Author

Should I backport? It does have some nice doc updates in addition to the candy. It would be nice to make _Brain public, maybe with a warning about the API bring incomplete...

@larsoner larsoner deleted the video branch September 24, 2020 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants