Significance: Functional near-infrared spectroscopy (fNIRS) presents an opportunity to study human brains in everyday activities and environments. However, achieving robust measurements under such dynamic condition remains a significant challenge. Aim: The modular optical brain imaging (MOBI) system is designed to enhance optode-to-scalp coupling and provide real-time probe 3-D shape estimation to improve the use of fNIRS in everyday conditions. Approach: The MOBI system utilizes bendable and lightweight modular circuit-board design to enhance probe's conformity to head surface and comfort for long-term wearing. Combined with automatic module connection recognition, the built-in orientation sensors on each module can be used to estimate optode 3-D positions in real-time to enable advanced tomographic data analysis and motion tracking. Results: Optical characterization of the MOBI detector reports a noise equivalence power (NEP) of 8.9 and 7.3 pW/√Hz at 735 nm and 850 nm, respectively, with a dynamic range of 88 dB. The 3-D optode shape acquisition yields an average error of 4.2 mm across 25 optodes in a phantom test compared to positions acquired from a digitizer. Results for initialin vivovalidations, including a cuff occlusion and a finger-tapping test, are also provided. Conclusions: To the best of our knowledge, the MOBI system is the first modular fNIRS system featuring fully flexible circuit boards. The self-organizing module sensor network and automatic 3-D optode position acquisition, combined with lightweight modules (18 g/module) and ergonomic designs, would greatly aid emerging explorations towards brain functions in naturalistic settings. Conclusions: