Data in clinical medical often exhibit highly imbalanced class distribution. To mitigate this issue, current approaches based on deep neural network typically follow the strategies such as re-sampling and cost-sensitive learning. However, these methods neglect the underlying data structure. We propose a novel sampling method which explicitly enforces constraints on the intra-class and inter-class margins. To achieve this goal, we need 3 steps. In step 1, we first apply K-means for each class to obtain the initial clusters. In step 2, for each sample in the training set, we propose to ensure the following relationship holds $$D(f(x_{i}),f(x_{i}^{a}))