Skip to content
Discussion options

You must be logged in to vote

I think a simple script can help. Notice that use np.where() is a lot faster than a rude "for"

import numpy as np
from glob import glob
import SimpleITK as sitk

if __name__ == "__main__":

    in_dir = '/mnt/lijl/MONAI/Result/Upperbound/inferTs/'
    out_dir = '/mnt/lijl/MONAI/Result/Upperbound/trans_seg/'

    img_list = sorted(glob(in_dir + '*.nii.gz'))
    for img_name in img_list:
        index = img_name.split('/')[-1]
        print(index)
        img = sitk.GetArrayFromImage(sitk.ReadImage(img_name))

        sh = img.shape
        print(sh)
        res = np.zeros([sh[1], sh[2], sh[3]])
        for i in range(1, sh[0]):
            channel = img[i]
            res[np.where(channel …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by LIKP0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant