trial and error with the min_overlap 10% to 2%

This commit is contained in:
Stefan
2022-04-07 09:13:17 +02:00
parent 82c285b1b0
commit 10cdf43509
14 changed files with 350 additions and 42 deletions

30
src/sfransen/load_images.py Executable file
View File

@ -0,0 +1,30 @@
from typing import List
import SimpleITK as sitk
from sfransen.DWI_exp.helpers import *
def load_images_parrallel(
image_paths: str,
seq: str,
target_shape: List[int],
target_space = List[float]):
img_s = sitk.ReadImage(image_paths, sitk.sitkFloat32)
#resample
mri_tra_s = resample(img_s,
min_shape=target_shape,
method=sitk.sitkNearestNeighbor,
new_spacing=target_space)
#center crop
mri_tra_s = center_crop(mri_tra_s, shape=target_shape)
#normalize
if seq != 'seg':
filter = sitk.NormalizeImageFilter()
mri_tra_s = filter.Execute(mri_tra_s)
else:
filter = sitk.BinaryThresholdImageFilter()
filter.SetLowerThreshold(1.0)
mri_tra_s = filter.Execute(mri_tra_s)
return sitk.GetArrayFromImage(mri_tra_s).T