Skip to content

Commit 10c50ec

Browse files
skip primary and original image type check for the aaa pipeline
1 parent b0d69bd commit 10c50ec

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

bin/C2C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def SpinePipelineBuilder(path, args):
8282
def AxialCropperPipelineBuilder(path, args):
8383
pipeline = InferencePipeline(
8484
[
85-
io.DicomToNifti(path),
85+
io.DicomToNifti(path, "aaa"),
8686
spine.SpineSegmentation(args.spine_model),
8787
orientation.ToCanonical(),
8888
spine.AxialCropper(lower_level="L5", upper_level="L1", save=True),

comp2comp/io/io.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ def __call__(self, inference_pipeline) -> Dict[str, Path]:
7171
class DicomToNifti(InferenceClass):
7272
"""Convert dicom files to NIfTI files."""
7373

74-
def __init__(self, input_path: Union[str, Path], save=True):
74+
def __init__(self, input_path: Union[str, Path], pipeline_name=None, save=True):
7575
super().__init__()
7676
self.input_path = Path(input_path)
7777
self.save = save
78+
self.pipeline_name = pipeline_name
7879

7980
def __call__(self, inference_pipeline):
8081
if os.path.exists(
@@ -114,24 +115,27 @@ def __call__(self, inference_pipeline):
114115
return {}
115116

116117

117-
def series_selector(dicom_path):
118+
def series_selector(dicom_path, pipeline_name=None):
118119
ds = pydicom.filereader.dcmread(dicom_path)
119120
image_type_list = list(ds.ImageType)
120-
if not any("primary" in s.lower() for s in image_type_list):
121-
raise ValueError("Not primary image type")
122-
if not any("original" in s.lower() for s in image_type_list):
123-
raise ValueError("Not original image type")
121+
if pipeline_name and (pipeline_name != "aaa"):
122+
if not any("primary" in s.lower() for s in image_type_list):
123+
raise ValueError("Not primary image type")
124+
if not any("original" in s.lower() for s in image_type_list):
125+
raise ValueError("Not original image type")
126+
else:
127+
print(f"Skipping primary and original image type check for the {pipeline_name} pipeline.")
124128
# if any("gsi" in s.lower() for s in image_type_list):
125129
# raise ValueError("GSI image type")
126130
if ds.ImageOrientationPatient != [1, 0, 0, 0, 1, 0]:
127131
raise ValueError("Image orientation is not axial")
128132
return ds
129133

130134

131-
def dicom_series_to_nifti(input_path, output_file, reorient_nifti):
135+
def dicom_series_to_nifti(input_path, output_file, reorient_nifti, pipeline_name=None):
132136
reader = sitk.ImageSeriesReader()
133137
dicom_names = reader.GetGDCMSeriesFileNames(str(input_path))
134-
ds = series_selector(dicom_names[0])
138+
ds = series_selector(dicom_names[0], pipeline_name=pipeline_name)
135139
reader.SetFileNames(dicom_names)
136140
image = reader.Execute()
137141
sitk.WriteImage(image, output_file)

0 commit comments

Comments
 (0)