File size: 722 Bytes
79856c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np
from scipy import sparse
import ast
import os
import json

uniseg_path = '/zhaobai/joint_data/UniSeg'  # your path
dataset_code = '0012'
json_path = os.path.join('./', dataset_code, dataset_code + '.json')
with open(json_path, 'r') as f:
    dataset_dict = json.load(f)

ct_file_path = os.path.join(uniseg_path, dataset_dict['training'][0]['image'])
gt_file_path = os.path.join(uniseg_path, dataset_dict['training'][0]['label'])

img_array = np.load(ct_file_path)[0]
print('img_array.shape ', img_array.shape)

allmatrix_sp= sparse.load_npz(gt_file_path)
gt_shape = ast.literal_eval(gt_file_path.split('.')[-2])
gt_array=allmatrix_sp.toarray().reshape(gt_shape)
print('gt_array.shape ', gt_array.shape)