A General Framework for Automated and Accurate b-Matrix Calculation for dMRI Pulse Sequences