예제 #1
0
파일: loadSlicer.py 프로젝트: yf817/MPhys
def load_series(pet_paths, pct_paths):
    pet_series = {}
    pct_series = {}
    for key, value in pet_paths.items():
        pet_series[key] = ImageReg.load_series_no_write(value)
        pct_series[key] = ImageReg.load_series_no_write(pct_paths[key])
    return pet_series, pct_series
예제 #2
0
def write_nifty(pet_paths, pct_paths):
    pet_series = {}
    pct_series = {}
    for key, value in pet_paths.items():
        pet_series[key] = ImageReg.load_series(value, 'PET\\{}'.format(key))
        pct_series[key] = ImageReg.load_series(pct_paths[key], 'PlanningCT\\{}'.format(key))
    return pet_series, pct_series
예제 #3
0
파일: main0.py 프로젝트: yf817/MPhys
def main(argv=None):
    # read_dicom(".\\Patients\\HN-CHUM-001\\08-27-1885-TomoTherapy Patient Disease-00441\\1-REGCTsim-CTPET-CT-43961\\000000.dcm")
    # ImageReg.load_series(".\\Patients\\HN-CHUM-001\\08-27-1885-TomoTherapy Patient Disease-00441\\112161818-kVCT Image Set-62659\\", "pct_series")
    # ImageReg.load_series(".\\Patients\\HN-CHUM-001\\08-27-1885-PANC. avec C.A. SPHRE ORL   tte et cou  -TP-74220\\3-StandardFull-07232\\", "petct_series")
    fixed = ImageReg.image_info("pct_series.mha")
    moving = ImageReg.image_info("petct_series.mha")
    dvf = sitk.ReadImage("dvf.mhd")
    vis = ImageReg.resample_image(fixed, moving, dvf)
    print(type(vis))
    ImageReg.myshow(vis, fixed)
    print("Done Loading Patient Info")
예제 #4
0
파일: writeNifty.py 프로젝트: yf817/MPhys
def write_nifty(pet_paths, pct_paths):
    # Function that writes image series to .nii format
    pet_series = {}
    pct_series = {}
    for key, value in pet_paths.items():
        try:
            pet_series[key] = ImageReg.load_series(value, pet_outdir, key)
            pct_series[key] = ImageReg.load_series(pct_paths[key], planning_outdir, key)
        except RuntimeError:
            print("RuntimeError Ignored")
            pass
    return pet_series, pct_series
예제 #5
0
def main(argv=None):
    # read_dicom(".\\Patients\\HN-CHUM-001\\08-27-1885-TomoTherapy Patient Disease-00441\\1-REGCTsim-CTPET-CT-43961\\000000.dcm")
    # ImageReg.load_series(
    #     ".\\Patients\\HN-CHUM-001\\08-27-1885-TomoTherapy Patient Disease-00441\\112161818-kVCT Image Set-62659\\", "pct_series")
    # ImageReg.load_series(
    #     ".\\Patients\\HN-CHUM-001\\08-27-1885-PANC. avec C.A. SPHRE ORL   tte et cou  -TP-74220\\3-StandardFull-07232\\", "petct_series")
    fixed = ImageReg.image_info("pct_series.mha")
    moving = ImageReg.image_info("petct_series.mha")
    dvf = sitk.ReadImage("dvf.mhd", sitk.sitkVectorFloat64)
    small_dvf = ImageReg.resize_image(dvf, fixed)
    small_moving = ImageReg.resize_image(moving, fixed)
    transform_img = ImageReg.resample_image(small_moving, fixed, small_dvf)
    ImageReg.myshow(transform_img)
    print("Done Loading Patient Info")
예제 #6
0
파일: main.py 프로젝트: yf817/MPhys
def main(argv=None):

    # read_dicom(".\\Patients\\HN-CHUM-001\\08-27-1885-PANC. avec C.A. SPHRE ORL   tte et cou  -TP-74220\\3-StandardFull-07232\\000000.dcm")
    # ImageReg.load_series(
    #     ".\\Patients\\HN-CHUM-001\\08-27-1885-TomoTherapy Patient Disease-00441\\112161818-kVCT Image Set-62659\\", "pct_series")
    # ImageReg.load_series(
    #     ".\\Patients\\HN-CHUM-001\\08-27-1885-PANC. avec C.A. SPHRE ORL   tte et cou  -TP-74220\\3-StandardFull-07232\\", "test_series")
    fixed = ImageReg.image_info("pct_series.mha")
    moving = ImageReg.image_info("petct_series.mha")
    dvf = sitk.ReadImage("dvf.mhd", sitk.sitkVectorFloat64)
    # small_dvf = ImageReg.resize_image(dvf, fixed)
    # small_moving = ImageReg.resize_image(movsng, fixed)
    pre_def, post_def = ImageReg.get_rigid_transforms(dvf_path)
    transform = ImageReg.define_transform(pre_def, post_def, dvf)
    transform_img = ImageReg.resample_image(moving, fixed, transform)
    ImageReg.myshow(transform_img)
    print("Done Loading Patient Info")
예제 #7
0
파일: main.py 프로젝트: yf817/MPhys
from imageReg import ImageReg
from interact import Interact
import SimpleITK as sitk

# Change working directory such that it can access data
os.chdir("..")
# Print current working directory
cwd = os.getcwd()
print(cwd)
# Paths
pct_path = ".\\Patients\\HN-CHUM-001\\08-27-1885-TomoTherapy Patient Disease-00441\\112161818-kVCT Image Set-62659\\000000.dcm"
dvf_path = "E:\\Mphys\\ElastixReg\\DVF\\HN-CHUM-001\\deformationField.nii"
petct_path = ".\\Patients\\HN-CHUM-001\\08-27-1885-PANC. avec C.A. SPHRE ORL   tte et cou  -TP-74220\\3-StandardFull-07232"
struct_path = '.\\Patients\\HN-CHUM-001\\08-27-1885-TomoTherapy Patient Disease-00441\\114120634-TomoTherapy Structure Set-68567\\000000.dcm'
ReadData = ReadData()
ImageReg = ImageReg()
Interact = Interact()


def read_dicom(dicom_path):
    # Function that reads a dicom file and writes to a text file
    dataset = ReadData.read_dicom(dicom_path)
    # vector_grid = dataset.DeformableRegistrationSequence[1].DeformableRegistrationGridSequence[0].VectorGridData
    # vector_grid = np.array(vector_grid).astype(np.float64)
    #
    # with open("dvf.raw", "wb") as f:
    #     f.write(vector_grid)
    ReadData.write_dicom(dataset, "image_test")


def load_patients_array():
예제 #8
0
파일: loadSlicer.py 프로젝트: yf817/MPhys
def show_image(image_array):
    data = np.asarray(image_array).astype(np.float64)
    image = sitk.GetImageFromArray(data)
    ImageReg.myshow(image)
    sitk.WriteImage(image, "imagetest.mha")
예제 #9
0
파일: loadSlicer.py 프로젝트: yf817/MPhys
def pretransformed_pet(pet_series, pct_series):
    transformed_pet_series = {}
    for key, petvalue in pet_series.items():
        transformed_pet_series[key] = ImageReg.initial_transform(pct_series[key], petvalue)
    return transformed_pet_series
예제 #10
0
def main(argv=None):
    slice_array(planning_path, start, end)
    slice_image = sitk.ReadImage("sliced_pct.mha")
    ImageReg.myshow(slice_image)