Skip to content

mikebind/SlicerVirtualEndoscopy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

The old Endoscopy module in Slicer didn't work well for my purposes, so I began to write a new version which would work better for me. Note that this repository does NOT contain the code for the current, newer built-in Endoscopy module, which is more functional than the old one, but rather my own version. It is still pretty rough, so use at your own risk. Generally, here is how it works:

  • Start with a MarkupsCurve which represents the path that you want the camera to follow
  • Select a uniform spacing to resample the original curve to
  • Decide how many control points ahead you want the camera to be looking (ahead of the current location)
  • Preprocess the input curve
    • This generates a camera locations curve and a focal points curve
    • The camera locations curve is the set of camera locations for the virtual endoscopy
    • The camera focal points curve is the set of points that the camera is pointed towards. This curve has the same number of points as the camera locations curve. When the look ahead interval would mean that a control point beyond the end of the original curve is needed, the generated focal point is a point projected along the final line segment of the orignal curve, one additional step spacing.
  • Once the camera locations curve and focal points curves are set, it becomes possible to step or play through the series of locations. By default, the module controls the camera for View1, but this can be changed in the Advanced settings. In addition, the playthrough can optionally jump the slice views to follow the camera location. Note also that it is possible to use a set of locations and focal points which have been generated outside of the VirtualEndoscopy module. This would be necessary if you wanted the camera to do something other than look ahead along the travel path.
  • Once happy with the endoscopy viewing, you can record a video of the flythrough, either in the 3D view alone or with the slice views, saving to a specified mp4 file. Note that ffmpeg must be present on the system and configured in Slicer to be able to create mp4 videos. To set this up, set the ffmpeg executable location using the ScreenCapture module, this is saved as a permanent Slicer setting, so you only need to do this once.
  • Advanced Settings allow you to select which Slicer camera to control, the camera view angle, the camera clipping range, the playback rate, and the output video height and frame rate. Note that if the video size is too large, ffmpeg seems to create artifacts or unreadable videos. It's not clear to me why this happens, but a height of 1440 generally works fine for me, so it isn't an issue. Lastly, the advanced settings allow you to set a "View Up Guide Vector (RAS)". This setting is to allow you to guide the orientation of the camera ViewUp vector (i.e. the orientation of the vertical direction in the output video). Not being able to control this was one of the main limitations of the old Endoscopy module that I wanted to overcome in writing this one. Basically, the camera location and focal point set the direction the camera is looking, but not its orientation about that axis. The ViewUp vector controls this last degree of freedom. The "View Up Guide Vector (RAS)" should be set to a vector which is the direction you generally want to be "Up" in the video. The actual ViewUp vector will be the guide vector projected into the plane perpendicular to the camera view direction. Note that this will work best if the camera view direction is roughly perpendicular to the guide vector, and will fail pretty terribly if the camera view direction is roughly parallel with the guide vector. A general solution to this problem would be to allow the user to specify a set of View Up Guide Vectors, one for each camera location, but this seems like a pain to generate and manage, so I haven't taken that route. It's also only really a problem if your trajectory is going over a 90 deg turn in the direction of the guide vector, which hopefully won't be happening very much. If so, a better solution than this single guide vector is going to be needed.

About

Replacement for old endoscopy module in 3D Slicer (work in progress)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published