Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
qurit-frizi authored Jul 16, 2024
1 parent bfdd5e7 commit 747524c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions nifti2rt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import SimpleITK as sitk
from SimpleITK import GetArrayFromImage, sitkNearestNeighbor, Image
import numpy as np
from torch import nn
from rt_utils import RTStructBuilder

def debug_output(seg: sitk.Image, seg_path: str, uid:str, dicom_path: str):
mask_from_sitkImage_zyx = np.transpose(sitk.GetArrayFromImage(seg), (2, 1, 0))
mask_from_sitkImage_xzy = np.transpose(mask_from_sitkImage_zyx, axes=(2, 0, 1))
mask_from_sitkImage_xyz = np.transpose(mask_from_sitkImage_xzy, (2, 1, 0))
mask_from_sitkImage_int64 = mask_from_sitkImage_xyz
mask_from_sitkImage_bool = mask_from_sitkImage_int64.astype(bool)
# Create new RT Struct. Requires the DICOM series path for the RT Struct.
rtstruct = RTStructBuilder.create_new(dicom_series_path = dicom_path)
# Add the 3D mask as an ROI setting the color, description, and name
rtstruct.add_roi(
mask=mask_from_sitkImage_bool,
color=[255, 0, 255],
name="your ROI!"
)

rtstruct.save(os.path.join(OUTPUT_DIR, uid+'_tmtv-rt-struct'))

0 comments on commit 747524c

Please sign in to comment.