copied codes for NIDA analysis