Algorithm for automatic nonlinear inter-subject registration