@@ 242-258 (lines=17) @@ | ||
239 | for subfolder in tqdm(subfolders): |
|
240 | files = os.listdir(os.path.join(data_dir, folder, subfolder)) |
|
241 | for file in files: |
|
242 | if file.startswith("case_020"): # this case did not laod correctly |
|
243 | os.remove(os.path.join(data_dir, folder, subfolder, file)) |
|
244 | else: |
|
245 | im_data = np.asarray( |
|
246 | nib.load(os.path.join(data_dir, folder, subfolder, file)).dataobj, |
|
247 | dtype=np.float32, |
|
248 | ) |
|
249 | if np.max(im_data) > 255.0: |
|
250 | im_data = ((im_data + 285) / (3770 + 285)) * 255.0 # rescale image |
|
251 | img = nib.Nifti1Image(im_data, affine=None) |
|
252 | nib.save(img, os.path.join(data_dir, folder, subfolder, file)) |
|
253 | if np.max(img.dataobj) > 255.0: |
|
254 | print( |
|
255 | "Recheck the following file: ", |
|
256 | os.path.join(data_dir, folder, subfolder, file), |
|
257 | ) |
|
258 | nib.save(img, os.path.join(data_dir, folder, subfolder, file)) |
|
259 | ||
260 | ######## DOWNLOAD MODEL CKPT FROM MODEL ZOO ######## |
|
261 |
@@ 214-230 (lines=17) @@ | ||
211 | for subfolder in tqdm(subfolders): |
|
212 | files = os.listdir(os.path.join(data_dir, folder, subfolder)) |
|
213 | for file in files: |
|
214 | if file.startswith("case_020"): # this case did not laod correctly |
|
215 | os.remove(os.path.join(data_dir, folder, subfolder, file)) |
|
216 | else: |
|
217 | im_data = np.asarray( |
|
218 | nib.load(os.path.join(data_dir, folder, subfolder, file)).dataobj, |
|
219 | dtype=np.float32, |
|
220 | ) |
|
221 | if np.max(im_data) > 255.0: |
|
222 | im_data = ((im_data + 285) / (3770 + 285)) * 255.0 # rescale image |
|
223 | img = nib.Nifti1Image(im_data, affine=None) |
|
224 | nib.save(img, os.path.join(data_dir, folder, subfolder, file)) |
|
225 | if np.max(img.dataobj) > 255.0: |
|
226 | print( |
|
227 | "Recheck the following file: ", |
|
228 | os.path.join(data_dir, folder, subfolder, file), |
|
229 | ) |
|
230 | nib.save(img, os.path.join(data_dir, folder, subfolder, file)) |
|
231 | ||
232 | ######## DOWNLOAD MODEL CKPT FROM MODEL ZOO ######## |
|
233 |