A Unified Fem-Based Framework For Medical Image Registration And Segmentation