Skip to content

Commit

Permalink
demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mkazmier committed Feb 27, 2020
1 parent 6e4a93a commit f4ca619
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 322 deletions.
13 changes: 12 additions & 1 deletion imgtools/examples/radcure_simple.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from argparse import ArgumentParser

from ..pipeline import Pipeline
from ..ops import Resample
from ..io import ImageDirectoryLoader, read_dicom_series, read_dicom_rtstruct


class RADCUREPipeline(Pipeline):
def __init__(self, root_directory="/cluster/projects/radiomics/RADCURE_images/", spacing=(1., 1., 1.)):
def __init__(self, root_directory="/cluster/projects/radiomics/RADCURE_images/", output_directory="./processed" spacing=(1., 1., 1.)):
self.root_directory = root_directory
self.image_loader = ImageDirectoryLoader(self.root_directory, index_by="parent", subdir_path="*/ImageSet_*", reader=read_dicom_series)
self.structure_set_loader = ImageDirectoryLoader(self.root_directory, index_by="parent", subdir_path="*/structures", reader=read_dicom_rtstruct)
Expand All @@ -17,3 +19,12 @@ def process_one_case(self, key):
mask = structure_set.to_mask(image, roi_names="GTV")
self.image_writer.add(key, image)
self.mask_writer.add(key, mask)


if __name__ == "__main__":
parser = ArgumentParser("Example RADCURE processing pipeline.")
parser.add_argument("root_directory", type=str)
parser.add_argument("output_directory", type=str)
parser.add_argument("--spacing", nargs=3, type=float, default=(1., 1., 1.))
pipeline = RADCUREPipeline(args.root_directory, output_directory=args.output_directory, spacing=args.spacing)
pipeline.run()
272 changes: 0 additions & 272 deletions imgtools/io.py

This file was deleted.

2 changes: 1 addition & 1 deletion imgtools/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .common import *
from .readers import *
from .loaders import *
from .writers import *
2 changes: 2 additions & 0 deletions imgtools/io/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def _generate_paths(self):
if self.subdir_path:
path = os.path.join(path, self.subdir_path)
path = glob.glob(path)[0]
if os.path.isdir(path):
path = os.path.join(path, "")
key = self._extract_key_from_path(path)
paths[key] = path
return paths
Expand Down
12 changes: 1 addition & 11 deletions imgtools/io/writers.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import os
import glob
import re
from typing import Optional
from collections import namedtuple
from itertools import chain

import numpy as np
import pandas as pd
import SimpleITK as sitk
from pydicom import dcmread
from pydicom.misc import is_dicom

from .image import physical_point_to_index
from .segmentation import StructureSet
from .utils.imageutils import image_to_array
from ..utils import image_to_array


class ImageFileWriter:
Expand Down
Loading

0 comments on commit f4ca619

Please sign in to comment.