Esempio n. 1
0
    def load_nii_and_gen_label(patients_path, hc_path, mask):
        # train data
        data1 = main(patients_path)
        data1 = np.squeeze(
            np.array([np.array(data1).reshape(1, -1) for data1 in data1]))
        data2 = main(hc_path)
        data2 = np.squeeze(
            np.array([np.array(data2).reshape(1, -1) for data2 in data2]))
        data = np.vstack([data1, data2])

        # validation data
        data_val = main(validation_path)
        data_val = np.squeeze(
            np.array(
                [np.array(data_val).reshape(1, -1) for data_val in data_val]))

        # data in mask
        data_tr = data[:, mask]
        data_val = data_val[:, mask]

        # label_tr
        label_tr = np.hstack(
            [np.ones([
                len(data1),
            ]) - 1, np.ones([
                len(data2),
            ])])
        return label_tr, data_tr, data_val
def load_nii_and_gen_label(BD_path, MDD_path, HC_path, suffix='.nii'):
    # data
    data1, _ = main(BD_path, suffix)
    data1 = np.squeeze(
        np.array([np.array(data1).reshape(1, -1) for data1 in data1]))

    data2, _ = main(MDD_path, suffix)
    data2 = np.squeeze(
        np.array([np.array(data2).reshape(1, -1) for data2 in data2]))

    data3, _ = main(HC_path, suffix)
    data3 = np.squeeze(
        np.array([np.array(data3).reshape(1, -1) for data3 in data3]))

    data = np.vstack([data1, data2, data3])

    # data in mask
    # data_in_mask=data[:,mask]
    # label
    label = np.hstack([
        np.ones([
            len(data1),
        ]) - 1,
        np.ones([
            len(data2),
        ]),
        np.ones([
            len(data2),
        ]) + 1
    ])
    return data, label
def load_nii_and_gen_label(folder_p, folder_hc, mask):

    # data
    data_p = main(folder_p)
    data_p = np.squeeze(
        np.array([np.array(data_p).reshape(1, -1) for data_p in data_p]))

    data_hc = main(folder_hc)
    data_hc = np.squeeze(
        np.array([np.array(data_hc).reshape(1, -1) for data_hc in data_hc]))

    data = np.vstack([data_p, data_hc])

    # data in mask
    #    mask=np.sum(data==0,0)<=0
    data_in_mask = data[:, mask]

    # label
    label = np.hstack(
        [np.ones([
            len(data_p),
        ]), np.ones([
            len(data_hc),
        ]) - 2])

    return data, data_in_mask, label
def load_nii_and_gen_label(patients_path,controls_path,mask):
    # data
    data_p=main(patients_path)
    data_p=np.squeeze(np.array([np.array(data_p).reshape(1,-1) for data_p in data_p]))
    data_hc=main(controls_path)
    data_hc=np.squeeze(np.array([np.array(data_hc).reshape(1,-1) for data_hc in data_hc]))
    data=np.vstack([data_p,data_hc])
    # data in mask
    data_in_mask=data[:,mask]
    # label
    label=np.hstack([np.ones([len(data_p),]),np.ones([len(data_hc),])-2])
    return data,data_in_mask,label
Esempio n. 5
0
def load_nii_and_gen_label(patients_path, hc_path, mask):
    # data
    data1, _ = main(patients_path, '.img')
    data1 = np.squeeze(
        np.array([np.array(data1).reshape(1, -1) for data1 in data1]))

    data2, _ = main(hc_path, '.img')
    data2 = np.squeeze(
        np.array([np.array(data2).reshape(1, -1) for data2 in data2]))

    data = np.vstack([data1, data2])

    # data in mask
    data_in_mask = data[:, mask]
    # label
    label = np.hstack([np.ones([
        len(data1),
    ]) - 1, np.ones([
        len(data2),
    ])])
    return data, data_in_mask, label