A method of optimizing 4D cone beam computed tomography (4DCBCT) imaging is provided that includes using a scanner to generate projections of a target, where the projections are used to form a cone beam computed tomography (CBCT) scan of the target, where the CBCT includes a 3D image of the target, and using an appropriately programmed computer to control rotation speed of a gantry and projection acquisition of the CBCT in real-time according to a measured patient respiratory signal, where the real-time acquisition of the 4CBCT forms an optimized 4DCBCT image set.