Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Knowledge Distillation
- MRI
- rest-api
- sidleup
- fastapi
- checkitout
- Inorder Traversal
- straightup
- sample rows
- thresholding
- freebooze
- scowl
- objective functions for machine learning
- Policy Gradient
- 3d medical image
- Excel
- 자료구조
- loss functions
- remove outliers
- model-free control
- pulloff
- Actor-Critic
- noise contrast estimation
- resample
- normalization
- REINFORCE
- shadowing
- clip intensity values
- non parametic softmax
- domain adaptation
Archives
- Today
- Total
Let's Run Jinyeah
[Python] MRI Resampling 본문
When to Resample?
Anytime we use two datasets with different sized voxels
Dicom Attributes to use
1. Slice Thickess
2. PixelSpacing (width, height)
Calcuate new size
out_size = [
int(np.round(original_size[0] * (original_spacing[0] / out_spacing[0]))),
int(np.round(original_size[1] * (original_spacing[1] / out_spacing[1]))),
int(np.round(original_size[2] * (original_spacing[2] / out_spacing[2])))]
How to resample with SimpleITK
def resample_img(itk_image, out_spacing=[2.0, 2.0, 2.0], is_label=False):
# resample images to 2mm spacing with simple itk
original_spacing = itk_image.GetSpacing()
original_size = itk_image.GetSize()
out_size = [
int(np.round(original_size[0] * (original_spacing[0] / out_spacing[0]))),
int(np.round(original_size[1] * (original_spacing[1] / out_spacing[1]))),
int(np.round(original_size[2] * (original_spacing[2] / out_spacing[2])))]
resample = sitk.ResampleImageFilter()
resample.SetOutputSpacing(out_spacing)
resample.SetSize(out_size)
resample.SetOutputDirection(itk_image.GetDirection())
resample.SetOutputOrigin(itk_image.GetOrigin())
resample.SetTransform(sitk.Transform())
resample.SetDefaultPixelValue(itk_image.GetPixelIDValue())
if is_label:
resample.SetInterpolator(sitk.sitkNearestNeighbor)
else:
resample.SetInterpolator(sitk.sitkBSpline)
return resample.Execute(itk_image)
How to resample with Python - Skimage resize
def interpolate(img, new_size):
new_img = resize(img, new_size, order=1, anti_aliasing=False, clip=False, preserve_range=True)
return new_img
reference
https://f-i-tushar-eee.medium.com/3d-medical-imaging-pre-processing-all-you-need-6ba981738877
'Programming > Medical Image Processing' 카테고리의 다른 글
[Python] Brain MRI Thresholding (0) | 2022.05.26 |
---|---|
Magnetic Resonance Imaging (MRI) (0) | 2022.05.13 |
Comments