This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding:utf-8 | |
import cv2 | |
import os | |
import matplotlib.pyplot as plt | |
import seaborn as sb | |
import numpy as np | |
import pandas as pd | |
from PIL import Image | |
from skimage import color | |
from glob import glob |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import numpy as np | |
import SimpleITK as sitk | |
import scipy.ndimage as ndimage | |
import time | |
import sys | |
sys.path.append('../utiles') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
#该代码适用于从测试集中读取原图,进行拼接。 | |
import numpy as np | |
import torch | |
import math | |
import SimpleITK as sitk | |
def generate_test_locations(image, patch_size, stride): | |
ww,hh,dd = image.shape | |
sz = math.ceil((ww - patch_size[0]) / stride[0]) + 1 | |
sx = math.ceil((hh - patch_size[1]) / stride[1]) + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
import os | |
import re | |
def mkdir(path): | |
# 去除首位空格 | |
path=path.strip() | |
# 去除尾部 \ 符号 | |
path=path.rstrip("\\") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import torch | |
import numpy as np | |
def split_image(img, crop_size=(128,128,128)): | |
patient_image = img # (1, 240, 240, 155, 4) | |
patient_image = patient_image[0, ...] # (240, 240, 155, 4) | |
patient_image = patient_image.permute(3, 0, 1, 2) # (1, 4, 155, 240, 240) | |
patient_image = patient_image.cpu().numpy() | |
pasient_image = crop_pad(patient_image, crop_size) | |
patient_image = torch.from_numpy(pasient_image).permute(1, 0, 2, 3, 4) # (C, S, T, Y, W) |