A probe, consisting of a flexible insertion tube, for insertion into a subject via a body lumen. The probe includes a sequence of tubular modules contained within the insertion tube, each module having a rigid tube segment having a preset shape and containing internal grooves on an interior surface of the tube segment. The probe further includes a flexible expander tube, which is threaded through the sequence of tubular modules and has external grooves configured to engage the internal grooves within the tube segment of each of the tubular modules when the expander tube is expanded, so as to hold the tubular modules in mutual alignment, wherein the tubular modules are able to move out of mutual alignment when the expander tube is unexpanded. The probe also has an expansion element, which is insertable through the flexible expander tube so as to expand the expander tube.