Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JoOkuma committed May 11, 2023
0 parents commit cdb7248
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.mp4
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2023, Royerlab
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Zebrahub's `napari-animation` Demo

This repository contains an example of how the videos from the zebrahub articles were rendered.

## Installation

```
pip install -r requirements.txt
```

## Usage

Edit the `MULTISCALE` variable inside the script to load a lower or higher resolution version of the dataset.

```
python main.py
```
52 changes: 52 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import napari
from napari_animation import Animation


def main() -> None:
# toggle multiscale to tradeoff between speed and resolution
MULTISCALE = False

viewer = napari.Viewer()

viewer.open(
"http://public.czbiohub.org/royerlab/zebrahub/imaging/multi-view/ZMNS001.ome.zarr",
plugin="napari-ome-zarr",
rendering="attenuated_mip",
gamma=0.7,
)

# disabling multiscale
if not MULTISCALE:
for channel in ("mezzo", "h2afva"):
viewer.layers[channel].multiscale = False
viewer.layers[channel].data = viewer.layers[channel].data[0]

# aesthetics changes
viewer.layers["h2afva"].colormap = "cyan"
viewer.layers["h2afva"].contrast_limits = (50, 850)
viewer.layers["mezzo"].colormap = "magenta"
viewer.layers["mezzo"].contrast_limits = (50, 500)

# making it 3D
viewer.dims.ndisplay = 3

# setting t = 0
viewer.dims.set_point(0, 0)

# starting recording
animation = Animation(viewer)
animation.capture_keyframe()

# setting t = 220
viewer.dims.set_point(0, 220)

# updating contrasts
viewer.layers["h2afva"].contrast_limits = (50, 2500)

# ending recording
animation.capture_keyframe(600)
animation.animate('video.mp4', fps=60)


if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
napari==0.4.17
napari-animation
napari-ome-zarr==0.5.2

0 comments on commit cdb7248

Please sign in to comment.