1313import matplotlib .pyplot as plt
1414import numpy as np
1515from scipy import ndimage
16+ import pydicom
1617
1718# from totalsegmentator.libs import (
1819# download_pretrained_weights,
@@ -32,6 +33,10 @@ def __init__(self):
3233 # self.input_path = input_path
3334
3435 def __call__ (self , inference_pipeline ):
36+ # check if kernels are allowed if agatson is used
37+ if inference_pipeline .args .threshold == 'agatson' :
38+ self .reconKernelChecker (inference_pipeline .dcm )
39+
3540 # inference_pipeline.dicom_series_path = self.input_path
3641 self .output_dir = inference_pipeline .output_dir
3742 self .output_dir_segmentations = os .path .join (self .output_dir , "segmentations/" )
@@ -114,6 +119,31 @@ def aorta_seg(
114119
115120 return seg
116121
122+ def reconKernelChecker (self , dcm ):
123+ ge_kernels = ["standard" , "md stnd" ]
124+ philips_kernels = ["a" , "b" , "c" , "sa" , "sb" ]
125+ canon_kernels = ["fc08" , "fc18" ]
126+ siemens_kernels = ["b20s" , "b20f" , "b30f" , "b31s" , "b31f" , "br34f" , "b35f" , "bf37f" , "br38f" , "b41f" ,
127+ "qr40" , "qr40d" , "br36f" , "br40" , "b40f" , "br40d" , "i30f" , "i31f" , "i26f" , "i31s" ,
128+ "i40f" , "b30s" , "br36d" , "bf39f" , "b41s" , "br40f" ]
129+ toshiba_kernels = ["fc01" , "fc02" , "fc07" , "fc08" , "fc13" , "fc18" ]
130+
131+ all_kernels = ge_kernels + philips_kernels + canon_kernels + siemens_kernels + toshiba_kernels
132+
133+ conv_kernel_raw = dcm ['ConvolutionKernel' ].value
134+
135+ if isinstance (conv_kernel_raw , pydicom .multival .MultiValue ):
136+ conv_kernel = conv_kernel_raw [0 ].lower ()
137+ recon_kernel_extra = str (conv_kernel_raw )
138+ else :
139+ conv_kernel = conv_kernel_raw .lower ()
140+ recon_kernel_extra = 'n/a'
141+
142+ if conv_kernel in all_kernels :
143+ return True
144+ else :
145+ raise ValueError ('Reconstruction kernel not allowed, found: ' + conv_kernel + '\n '
146+ + 'Allowed kernels are: ' + str (all_kernels ))
117147
118148class AorticCalciumSegmentation (InferenceClass ):
119149 """Segmentaiton of aortic calcium"""
@@ -122,6 +152,7 @@ def __init__(self):
122152 super ().__init__ ()
123153
124154 def __call__ (self , inference_pipeline ):
155+
125156 # Set output dirs
126157 self .output_dir = inference_pipeline .output_dir
127158 self .output_dir_images_organs = os .path .join (self .output_dir , "images/" )
@@ -567,7 +598,7 @@ def getSmallestArraySlice(self, input_mask, margin=0):
567598 )
568599
569600 return (slice (x_start , x_end ), slice (y_start , y_end ), slice (z_start , z_end ))
570-
601+
571602
572603class AorticCalciumMetrics (InferenceClass ):
573604 """Calculate metrics for the aortic calcifications"""
0 commit comments