Introduction: Functional Magnetic Resonance Imaging (fMRI) has been recognized as an attractive tool for understanding brain function for the last two decades. Clustering is a statistical method that opens new doors for researchers to identify the subgroups of the patients and to specialize the treatment. A lot of research has been done on the brain activities of healthy people and people with a history of drug addiction in response to drug stimuli, but there is no literature on whether people with different experiences of quitting drugs and different durations of drug use before quitting have identical brain activities in response to drug stimuli or not. Also, there is not enough research on the fact that how long drug use affects brain activities. Thus, this study is to seek the answer to these two questions. Method: In this study, 11 subjects, with no history of addiction, and 27 subjects, with different quitting durations and different durations of methamphetamine use before quitting, were evaluated. The images obtained fMRI images were initially analyzed by FSL software, this analysis included pre-processing and implementing GLM model on each subject. In the second step, the values obtained by fitting the GLM model to each voxel were extracted; the extracted parameters were standardized and used as the input for the penalized spline collective density estimator in R software. After estimating the parameters of the collective density function model, the estimated coefficients were applied as an inputs for hierarchical clustering. Results: The results of the clustering showed that the brain activities of subjects with different durations of quitting and different durations of drug use before quitting were correlated and four clusters were identified. Conclusion: These findings indicated that in fact, three months can be considered a safe point for being committed to quitting drugs. It is worth to note that the reaction to drugs in people with a quitting duration of less than three months is dependent on the duration of using drugs before quitting, so people with a history of drug use of 60 months and over 60 months before quitting have a different reaction to drug stimuli. These outcomes suggest that in order to do therapeutic works on the subjects to be committed to quitting drugs, the duration of using drugs has to be taken into account as well. Our study was a first step toward this research goal and the results can be used as a suggestion for further research and therapeutic works in this area.