Commit
·
1fa8afc
1
Parent(s):
78ae283
Minor clean up
Browse files
DeepDeformationMapRegistration/utils/nifty_utils.py
DELETED
|
@@ -1,40 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import nibabel as nb
|
| 3 |
-
import numpy as np
|
| 4 |
-
import zipfile
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
TEMP_UNZIP_PATH = '/mnt/EncryptedData1/Users/javier/ext_datasets/LITS17/temp'
|
| 8 |
-
NII_EXTENSION = '.nii'
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
def save_nifti(data, save_path, verbose=True):
|
| 12 |
-
data_nifti = nb.Nifti1Image(data, affine=np.eye(4))
|
| 13 |
-
|
| 14 |
-
data_nifti.header.get_xyzt_units()
|
| 15 |
-
try:
|
| 16 |
-
data_nifti.to_filename(save_path) # Save as NiBabel file
|
| 17 |
-
if verbose:
|
| 18 |
-
print('Saved {}'.format(save_path))
|
| 19 |
-
except ValueError:
|
| 20 |
-
print('Could not save {}'.format(save_path))
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
def unzip_nii_file(file_path):
|
| 24 |
-
file_dir, file_name = os.path.split(file_path)
|
| 25 |
-
file_name = file_name.split('.zip')[0]
|
| 26 |
-
|
| 27 |
-
dest_path = os.path.join(TEMP_UNZIP_PATH, file_name)
|
| 28 |
-
zipfile.ZipFile(file_path).extractall(TEMP_UNZIP_PATH)
|
| 29 |
-
|
| 30 |
-
if not os.path.exists(dest_path):
|
| 31 |
-
print('ERR: File {} not unzip-ed!'.format(file_path))
|
| 32 |
-
dest_path = None
|
| 33 |
-
return dest_path
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
def delete_temp(file_path, verbose=False):
|
| 37 |
-
assert NII_EXTENSION in file_path
|
| 38 |
-
os.remove(file_path)
|
| 39 |
-
if verbose:
|
| 40 |
-
print('Deleted file: ', file_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EvaluationScripts/Evaluate_3d_weaklySupervised.py
CHANGED
|
@@ -14,7 +14,7 @@ from datetime import datetime
|
|
| 14 |
import DeepDeformationMapRegistration.utils.constants as C
|
| 15 |
from DeepDeformationMapRegistration.data_generator import DataGeneratorManager
|
| 16 |
from DeepDeformationMapRegistration.utils.misc import try_mkdir
|
| 17 |
-
from DeepDeformationMapRegistration.utils.
|
| 18 |
from DeepDeformationMapRegistration.networks import WeaklySupervised
|
| 19 |
from DeepDeformationMapRegistration.losses import HausdorffDistanceErosion
|
| 20 |
from DeepDeformationMapRegistration.layers import UncertaintyWeighting
|
|
|
|
| 14 |
import DeepDeformationMapRegistration.utils.constants as C
|
| 15 |
from DeepDeformationMapRegistration.data_generator import DataGeneratorManager
|
| 16 |
from DeepDeformationMapRegistration.utils.misc import try_mkdir
|
| 17 |
+
from DeepDeformationMapRegistration.utils.nifti_utils import save_nifti
|
| 18 |
from DeepDeformationMapRegistration.networks import WeaklySupervised
|
| 19 |
from DeepDeformationMapRegistration.losses import HausdorffDistanceErosion
|
| 20 |
from DeepDeformationMapRegistration.layers import UncertaintyWeighting
|