# Automating 3D Model Animations

**URL:** <https://discourse.slicer.org/t/automating-3d-model-animations/38262>\
**Category:** Support\
**Created:** [September 7, 2024, 1:02pm UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262 "2024-09-07T13:02:25Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miri\_Trope](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/miri_trope/32/67690_2.png) [@Miri\_Trope](https://discourse.slicer.org/u/Miri_Trope)\
**Post date:** [September 7, 2024, 1:02pm UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/1 "2024-09-07T13:02:25Z")

</div>

Hi all, I am looking to create an automated animation (video) that includes rotating a model around a tumor at a 45-degree angle, adjusting the opacity of various volumes in the scene, inserting titles during the video, and performing other similar tasks. What tools or methods would you recommend to achieve this?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 7, 2024, 3:33pm UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/2 "2024-09-07T15:33:29Z")

</div>

Generally speaking you can write a python script to implement exactly what you have in mind.

You can look at the [Animator module](https://github.com/SlicerMorph/SlicerAnimator) to get ideas about how to control various visualization options and generate a sequence that can be exported using the ScreenCapture module to make movies.

A lot of the complexity comes from variability in the input data making it hard to create consistently nice movies automatically.

---

<div class="post-metadata">

**Author:** ![Miri\_Trope](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/miri_trope/32/67690_2.png) [@Miri\_Trope](https://discourse.slicer.org/u/Miri_Trope)\
**Post date:** [September 8, 2024, 7:11pm UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/3 "2024-09-08T19:11:28Z")

</div>

Thank you for your response.

> [@pieper](#):
>
> Generally speaking you can write a python script to implement exactly what you have in mind.

Could you clarify what you mean? I’m new to animation.

Could SlicerMorph be of help as well?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 8, 2024, 8:54pm UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/4 "2024-09-08T20:54:55Z")

</div>

The Animator module is part of SlicerMorph, if you are just making Animations you probably don’t need any of the other features it provides so you can just ignore them.

The Animator already provides some of what you describe, but it may not be expressive enough to cover everything. It’s based on key frame values so there’s an interpolation of the parameters so that things like opacity change frame by frame. But it’s set up to be used interactively and it’s a bit limited. So that’s why I suggest you look at the python code so you can see how to manipulate the view and export the exact animation you have in mind.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [September 8, 2024, 9:22pm UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/5 "2024-09-08T21:22:54Z")

</div>

> [@pieper](#):
>
> The Animator module is part of SlicerMorph, if you are just making Animations you probably don’t need any of the other features it provides so you can just ignore them.

The latest code for Animator is in: [SlicerMorph/Animator at master · SlicerMorph/SlicerMorph · GitHub](https://github.com/SlicerMorph/SlicerMorph/tree/master/Animator)

The other repo Steve linked, is an earlier prototype.

> [@Miri\_Trope](#):
>
> Could SlicerMorph be of help as well?

Animator can do the opacity/volume rendering changes, cliipping as well as rotation. but it doesn’t do the inserting the text (though it will render markup labels, if you keep them on).

It is a bit complex to use, perhaps first try the tutorial, with tutorial example, and decide it if it is going to help you: [Tutorials/Animator at main · SlicerMorph/Tutorials · GitHub](https://github.com/SlicerMorph/Tutorials/tree/main/Animator)

Tutorial is a few years old, since then Annotation ROIs were replaced by MarkupROIs. You can use MarkupROI where it says annotationROIs.

---

<div class="post-metadata">

**Author:** ![AlexBaev](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@AlexBaev](https://discourse.slicer.org/u/AlexBaev)\
**Post date:** [September 9, 2024, 5:30am UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/6 "2024-09-09T05:30:59Z")

</div>

The free 3d blender editor is completely suitable for performing such a task. Do you have time to teach him? Excuse my English…

---

<div class="post-metadata">

**Author:** ![Miri\_Trope](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/miri_trope/32/67690_2.png) [@Miri\_Trope](https://discourse.slicer.org/u/Miri_Trope)\
**Post date:** [September 9, 2024, 7:24am UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/7 "2024-09-09T07:24:21Z")

</div>

Thank you so much for all your responses. Apologies for being a bit of a bother, but I have a really exciting idea that I’d love to bring to life. Let me clarify what I mean: Here’s a [link](https://youtu.be/st3w6nHR6ms) to a screen recording I made using MITK. I’m wondering if it’s possible to automate parts of this process completely (by simply inserting an image and a model, then pressing a button to generate the video). I’m open to using another tool you might suggest, as long as it requires minimal effort. What do you think?

---

<div class="post-metadata">

**Author:** ![AlexBaev](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@AlexBaev](https://discourse.slicer.org/u/AlexBaev)\
**Post date:** [September 9, 2024, 9:21am UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/8 "2024-09-09T09:21:41Z")

</div>

There is no such button to make it “fast and beautiful”. I’ll wait for other answers.  
The blender is difficult for a beginner.Blender: Converting the model to a 3D grid, simplifying the grid, installing cameras and lights, rendering. You can watch my YouTube, there we just count the teeth of a 7-year-old child. Falling from a height, dizziness, nausea. [link](https://www.youtube.com/watch?v=a6jDmCkQKMk)

---

<div class="post-metadata">

**Author:** ![Miri\_Trope](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/miri_trope/32/67690_2.png) [@Miri\_Trope](https://discourse.slicer.org/u/Miri_Trope)\
**Post date:** [September 9, 2024, 4:17pm UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/9 "2024-09-09T16:17:24Z")

</div>

Dear @AlexBaev , your video looks fantastic! I was wondering if you could work with NIfTI images (MRI) in Blender?

---

<div class="post-metadata">

**Author:** ![AlexBaev](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@AlexBaev](https://discourse.slicer.org/u/AlexBaev)\
**Post date:** [September 10, 2024, 8:59am UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/10 "2024-09-10T08:59:01Z")

</div>

This path is not quite easy. First, we get a 3D mesh from Slicer.

 ![Head](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/0/205218610203027de57a57636efebfef2a2a8542.jpeg)  
 ![Bone](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/0/800e085552de2cebc403a0d2b70630e656e4c728.jpeg)  
Then we open it in a Blender.  
 ![BlenderHead](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/4/d4d0a7880854ef89097158fd5d5da119a328eae7.jpeg)  
 ![BlenderBone](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/5/4542cf6f63533295dfc4479927c305b1e3da02a0.jpeg)  
We make textures, transparency, set up a camera and light, bones for animation.  
This is how this cartoon was created. (My first one, I’m a bad cartoonist, but I’m working on it). You can’t just spin the view - Blender will make a cartoon that you can watch, but not spin. If you want, send me your research, we’ll try to do something together.  
[a46779935b@mail.ru](mailto:a46779935b@mail.ru)

---

<div class="post-metadata">

**Author:** ![Miri\_Trope](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/miri_trope/32/67690_2.png) [@Miri\_Trope](https://discourse.slicer.org/u/Miri_Trope)\
**Post date:** [September 10, 2024, 3:14pm UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/11 "2024-09-10T15:14:08Z")

</div>

> [@pieper](#):
>
> Generally speaking you can write a python script to implement exactly what you have in mind.

Dear @pieper  
I’m sorry, but I’m not quite sure what you mean. Could you please explain the pipeline in more detail?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 11, 2024, 4:14pm UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/12 "2024-09-11T16:14:03Z")

</div>

What I mean is that you would approach the animation as a programming project, where you would have use loops to control the transitions from one visual state to the next and record frames at steps in the process. You would use the Slicer API to access the data and set the visual properties incrementally. If you are doing something simple, like rotating an object or fading a structure in/out this can be pretty straightforward. If you want to do multiple things at the same time you need to worry a bit about how those get combined, and you probably end up with a code structure something like what is in the Animator where actions are evaluated at each timepoint and set the visual properties accordingly.

---

<div class="post-metadata">

**Author:** ![Miri\_Trope](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/miri_trope/32/67690_2.png) [@Miri\_Trope](https://discourse.slicer.org/u/Miri_Trope)\
**Post date:** [September 11, 2024, 5:57pm UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/13 "2024-09-11T17:57:43Z")

</div>

Thanks for the links @muratmaga and @pieper ! I think I can make this work. Just to clarify, should the video be generated by running the script in `TransformAction.py`? Here’s the introduction in that file: “This is a placeholder for Animator plugins for transforms. For testing:”. Could you guide me on how to create a basic video using a script, so I can modify it according to my needs?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 11, 2024, 6:41pm UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/14 "2024-09-11T18:41:51Z")

</div>

I don’t think we can spell it out in more detail than we have - the Animator is a python scripted module so you can learn from it, but you’ll need to know enough python and slicer scripting to understand how to work with it.

To your specific question, no you would not run `TransformAction.py`. The `Action` classes are specific scene modifications that take place over a set time frame (start and end time) in the context of an overall animation. Most of the examples are in the main `Animator.py` script, but the idea is that additional types of actions could be added to the `AnimatorLib` package.

You could look at the modules `SelfTest` for an example of how these are used to make an animation:

> <https://github.com/SlicerMorph/SlicerMorph/blob/master/Animator/Animator.py#L1185-L1290>

---

<div class="post-metadata">

**Author:** ![AlexBaev](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@AlexBaev](https://discourse.slicer.org/u/AlexBaev)\
**Post date:** [September 12, 2024, 2:52pm UTC](https://discourse.slicer.org/t/automating-3d-model-animations/38262/15 "2024-09-12T14:52:19Z")

</div>

I offered you to learn a 3d program, here you are offered to learn the python programming language. It’s easier to ask developers to make a transparency level for each layer. Maybe I didn’t search well, but the transparency level is set for the entire 3d view at once. Slicer is a great program, but the buttons are not where they are expected, it’s annoying…

 ![453453](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/8/886ac4e7a0c89bd0c5439fc2992e82183283829b.jpeg)
