ChanggungPatientNets, ChanggungHealthyNets)
    X1 = np.zeros((len(ChanggungHealthyNets), 1))  # healthy
    y1 = -1 * np.ones((len(ChanggungHealthyNets), 1))  # label = -1 for healthy
    X2 = np.zeros((len(ChanggungPatientNets), 1))  # patient
    y2 = np.ones((len(ChanggungPatientNets), 1))  # label = 1 for patients

    # Z would be a dict of np.arrays
    # The key is the subject name
    # The value is a 2d time case X feature dim array
    Z = dict()
    y3 = dict()
    for key in testNets:
        Z[key] = np.zeros((len(testNets[key]), 1))
        y3[key] = -1 * np.ones((len(testNets[key]), 1))
    for c in sig_connections:
        normalCList = result_utils.getAllFCAtIdx(c[0], c[1],
                                                 ChanggungHealthyNets)
        X1 = np.insert(X1, 0, normalCList, axis=1)
        patientCList = result_utils.getAllFCAtIdx(c[0], c[1],
                                                  ChanggungPatientNets)
        X2 = np.insert(X2, 0, patientCList, axis=1)
        for key in testNets:
            # for each subject
            testList = result_utils.getAllFCAtIdx(c[0], c[1], testNets[key])
            Z[key] = np.insert(Z[key], 0, testList, axis=1)
    X = np.concatenate([X1[:, :-1], X2[:, :-1]])
    y = np.concatenate((y1, y2)).ravel()
    for key in Z:
        Z[key] = Z[key][:, :-1]

    # classifier
    classifier = svm.SVC(kernel='linear')
    trainingNets = copy.deepcopy(ChanggungPatientNets)
    leftOutNet = trainingNets[pidx]
    trainingNets.remove(leftOutNet)

    sig_connections = stats_utils.filter_sigdiff_connections(
        trainingNets, ChanggungHealthyNets)
    discovery_rates.append(
        float(len(sig_connections)) / (atlasobj.count *
                                       (atlasobj.count - 1) / 2))
    X1 = np.zeros((len(ChanggungHealthyNets), 1))  # healthy
    y1 = -1 * np.ones((len(ChanggungHealthyNets), 1))
    X2 = np.zeros((len(trainingNets), 1))  # patient
    y2 = np.ones((len(trainingNets), 1))
    z = []
    for c in sig_connections:
        normalCList = result_utils.getAllFCAtIdx(c[0], c[1],
                                                 ChanggungHealthyNets)
        X1 = np.insert(X1, 0, normalCList, axis=1)
        patientCList = result_utils.getAllFCAtIdx(c[0], c[1], trainingNets)
        X2 = np.insert(X2, 0, patientCList, axis=1)
        z.append(result_utils.getAllFCAtIdx(c[0], c[1], [leftOutNet])[0])
    X = np.concatenate([X1[:, :-1], X2[:, :-1]])
    y = np.concatenate((y1, y2)).ravel()
    print('Sample data shape: %s, label shape: %s' %
          (str(X.shape), str(y.shape)))
    # train ans score
    classifier.fit(X, y)
    p = classifier.score(np.array(z, ndmin=2), np.array([1]))
    accuracy.append(p)
    if p == 1.0:
        truePositive += 1
    else:
def func(args):
    # input parameters
    atlasobj = args[0]
    ChanggungPatientNets = args[1]

    # return results
    ret = [None, None, None, None,
           None]  # discover rate, accuracy, precision, recall, specificity

    ChanggungHealthyNets = io_utils.loadRandomDynamicNets(
        ChanggungAllFullPath,
        atlasobj,
        totalNum=len(ChanggungPatientNets),
        scanList=os.path.join(ChanggungRootPath, 'normal_scans.txt'))
    sig_connections = stats_utils.filter_sigdiff_connections(
        ChanggungPatientNets, ChanggungHealthyNets)
    ret[0] = float(len(sig_connections)) / (atlasobj.count *
                                            (atlasobj.count - 1) / 2.0)
    X1 = np.zeros((len(ChanggungHealthyNets), 1))  # healthy
    y1 = -1 * np.ones((len(ChanggungHealthyNets), 1))
    X2 = np.zeros((len(ChanggungPatientNets), 1))  # patient
    y2 = np.ones((len(ChanggungPatientNets), 1))
    for c in sig_connections:
        normalCList = result_utils.getAllFCAtIdx(c[0], c[1],
                                                 ChanggungHealthyNets)
        X1 = np.insert(X1, 0, normalCList, axis=1)
        patientCList = result_utils.getAllFCAtIdx(c[0], c[1],
                                                  ChanggungPatientNets)
        X2 = np.insert(X2, 0, patientCList, axis=1)
    X = np.concatenate([X1[:, :-1], X2[:, :-1]])
    y = np.concatenate((y1, y2)).ravel()

    # classifier
    classifier = svm.SVC(kernel='linear')

    # leave one out cross validation
    accuracy = []
    truePositive = 0
    falsePositive = 0
    trueNegative = 0
    falseNegative = 0
    loo = model_selection.LeaveOneOut()
    for trainIdx, testIdx in loo.split(X, y):
        classifier.fit(X[trainIdx, :], y[trainIdx])
        accuracy.append(classifier.score(X[testIdx, :], y[testIdx]))
        p = classifier.predict(X[testIdx, :])[0]
        if p == 1 and y[testIdx] == 1:
            truePositive += 1
        elif p == -1 and y[testIdx] == -1:
            trueNegative += 1
        elif p == 1 and y[testIdx] == -1:
            falsePositive += 1
        else:
            falseNegative += 1
    ret[1] = np.mean(accuracy)

    precision = float(truePositive) / (truePositive + falsePositive)
    recall = float(truePositive) / (truePositive + falseNegative)
    specificity = float(trueNegative) / (trueNegative + falsePositive)
    ret[2] = precision
    ret[3] = recall
    ret[4] = specificity
    return ret
                                 'SCI_incomplete_subjects.txt'))
    ChanggungHealthyNets = io_utils.loadSpecificNets(
        mmdps_locale.ChanggungAllFullPath,
        atlasobj,
        subjectList=os.path.join(mmdps_locale.ChanggungRootPath,
                                 'normal_subjects.txt'))

    # prepare all training
    X1 = np.zeros((len(ChanggungHealthyNets), 1))  # healthy
    y1 = -1 * np.ones((len(ChanggungHealthyNets), 1))
    X2 = np.zeros((len(ChanggungPatientNets), 1))  # patient
    y2 = np.ones((len(ChanggungPatientNets), 1))
    for xidx in range(atlasobj.count):
        print('xidx = %d' % xidx)
        for yidx in range(xidx + 1, atlasobj.count):
            normalCList = result_utils.getAllFCAtIdx(xidx, yidx,
                                                     ChanggungHealthyNets)
            X1 = np.insert(X1, 0, normalCList, axis=1)
            patientCList = result_utils.getAllFCAtIdx(xidx, yidx,
                                                      ChanggungPatientNets)
            X2 = np.insert(X2, 0, patientCList, axis=1)
    X = np.concatenate([X1[:, :-1], X2[:, :-1]])
    y = np.concatenate((y1, y2)).ravel()
    print('Sample data shape: %s, label shape: %s' %
          (str(X.shape), str(y.shape)))

    # classifier
    classifier = svm.SVC(kernel='linear')

    # leave one out cross validation
    accuracy = []
    truePositive = 0