-
Notifications
You must be signed in to change notification settings - Fork 13
7 ‐ Chaining
Alexander Refsum Jensenius edited this page Sep 1, 2026
·
1 revision
For complete documentation see Working with Results on the docs site.
Analyses often come in sequences: trim the video, extract the motion, draw the motiongram. Because every method returns the object it produced, a sequence can be written as one line, each call feeding the next—like a sentence rather than a list of errands.
Every analysis method returns its result object (MgVideo, MgImage, or MgFigure), so calls can be chained directly:
import musicalgestures as mg
mv = mg.MgVideo('/path/to/video.avi', skip=4, crop='auto')
mv.motion().show()
mv.motionvideo().history().show()
mv.motionvideo().blend(component_mode='average').show()
mg.MgVideo('/path/to/video.avi', skip=4, crop='auto').motion().history().average().show()The basic non-chained workflow is equivalent and sometimes clearer:
mv = mg.MgVideo('/path/to/video.avi', starttime=5, endtime=15, skip=3)
mv.motion()
mv.history()
mv.show(key='motion')
mv.show(key='history')A project from the fourMs Lab, RITMO Centre for Interdisciplinary Studies in Rhythm, Time and Motion, Department of Musicology, University of Oslo.