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

Viz: image stack as animated GIF #20

Open
2 of 5 tasks
JohnTigue opened this issue Oct 16, 2019 · 5 comments
Open
2 of 5 tasks

Viz: image stack as animated GIF #20

JohnTigue opened this issue Oct 16, 2019 · 5 comments
Assignees
Projects

Comments

@JohnTigue
Copy link
Contributor

JohnTigue commented Oct 16, 2019

Demo: datatset_get_eyes_on_image_stack.ipynb

To do

  • Get minimally working
  • MinIP as slide 0 i.e. the preview. What people see before animation. Use libgif
  • MinIP as last slide. This way after playing, MinIP is left on the screen.
  • Get Colab to play animation.
  • Add progress bar to bottom of each image, showing depth of stack

Goal, animated GIF of stack i.e. all images into a single GIF. This is an initial "eyes on data" thing, which does not involve any automated reconstructions, just visualizing the input dataset.

The Brightfield Challenge dataset is basically just a raw z-stack of 2D images, plus SWC files. This project seeks to explore "doing neuroscience on Colab." So, crank out some code that does basic image processing on the image stack

Each neuron has an image stack.

The whole image stack is on the order of 6 to 60 GB
Each stack has a few hundred images
Each image file is on the order of 10s of MB each
So, how about "compress" the image stack into an animated GIF file of no more than a few MB, for easy viewing over the web? Looks like ImageJ already does this. That's Java; would be nice to find a Python implementation.

@JohnTigue JohnTigue self-assigned this Oct 16, 2019
@JohnTigue JohnTigue added this to Done in Jupyter UI Oct 16, 2019
@JohnTigue
Copy link
Contributor Author

JohnTigue commented Oct 16, 2019

@JohnTigue JohnTigue moved this from Done to In progress in Jupyter UI Oct 16, 2019
@JohnTigue JohnTigue reopened this Oct 16, 2019
@JohnTigue
Copy link
Contributor Author

Still need to figure out how to get the animated gif to show in the notebook. As is need to download and embed in an HTML page. Unacceptable.

Embedding Matplotlib Animations in Jupyter Notebooks
Louis Tiao 2016-04-16 21:10 11 Comments Source
(2016):

UPDATE (March 2018): For a more modern solution that uses an interactive JavaScript widget, please go to my new post: Embedding Matplotlib Animations in Jupyter as Interactive JavaScript Widgets.

Embedding Matplotlib Animations in IPython Notebooks is the original article referenced.

@JohnTigue JohnTigue changed the title Daseset: Animated GIF of stack Viz: Daseset as Animated GIF of stack Oct 17, 2019
@JohnTigue JohnTigue changed the title Viz: Daseset as Animated GIF of stack Viz: image stack as animated GIF Oct 24, 2019
@JohnTigue
Copy link
Contributor Author

JohnTigue commented Oct 24, 2019

Various techniques to control animated gif

  • handcoded: preloading
  • libgif and x-gif: ping-pong
  • libgif: rubbable, progress-bar, play/pause and move_to() means can make like a movie i.e. paused movie with draggable time slider equals z-stack explorer.

Pre-caching:

<script type="text/javascript">
  (new Image()).src = "animatedgif.gif"; // this would preload the GIF, so future loads will be instantaneous
</script>

@JohnTigue
Copy link
Contributor Author

PIL.Image and animated gif:
https://stackoverflow.com/questions/7960600/python-tkinter-display-animated-gif-using-pil

canvas = Image.new("RGB",(Width,Height),"white")
gif = Image.open('text.gif', 'r')
frames = []
try:
    while 1:
        frames.append(gif.copy())
        gif.seek(len(frames))
except EOFError:
    pass

for frame in frames:
     canvas.paste(frame)
     canvas.show()

@JohnTigue
Copy link
Contributor Author

@JohnTigue JohnTigue moved this from In progress to To do in Jupyter UI Oct 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Jupyter UI
  
To do
Development

No branches or pull requests

1 participant