Skip to content

Commit

Permalink
Renamed seg variable to label
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscyyeung committed Oct 13, 2021
1 parent 844a8ff commit e58d9f1
Show file tree
Hide file tree
Showing 101 changed files with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions code/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def process_dataset():
image_list = glob("../data/2018_LA_Seg_Challenge/*/lgemri.nrrd")
for file in tqdm.tqdm(image_list):
image, img_header = nrrd.read(file)
seg, seg_header = nrrd.read(file.replace("lgemri.nrrd", "laendo.nrrd"))
seg = (seg == 255).astype(np.uint8)
w, h, d = seg.shape
label, seg_header = nrrd.read(file.replace("lgemri.nrrd", "laendo.nrrd"))
label = (label == 255).astype(np.uint8)
w, h, d = label.shape

tempL = np.nonzero(seg)
tempL = np.nonzero(label)
minx, maxx = np.min(tempL[0]), np.max(tempL[0])
miny, maxy = np.min(tempL[1]), np.max(tempL[1])
minz, maxz = np.min(tempL[2]), np.max(tempL[2])
Expand All @@ -36,10 +36,10 @@ def process_dataset():
image = (image - np.mean(image)) / np.std(image)
image = image.astype(np.float32)
image = image[minx:maxx, miny:maxy]
seg = seg[minx:maxx, miny:maxy]
label = label[minx:maxx, miny:maxy]
f = h5py.File(file.replace('lgemri.nrrd', 'mri_norm2.h5'), 'w')
f.create_dataset('image', data=image, compression="gzip")
f.create_dataset('seg', data=seg, compression="gzip")
f.create_dataset('label', data=label, compression="gzip")
f.close()


Expand Down
Loading

0 comments on commit e58d9f1

Please sign in to comment.