Skip to content

Commit ab4a143

Browse files
authored
Merge pull request #94 from OpenGATE/uncertainty_by_region
Add click for image_uncertainty_per_region
2 parents 93eb6f8 + 89dfece commit ab4a143

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

gatetools/bin/gt_image_uncertainty.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434

3535
@click.option('--sigma', default=False, is_flag=True, help='By default, uncertainty is normalized, unc = sigma/x. By using this option, the output is *not* normalized, sigma=sqrt(var) is computed.')
3636

37+
@click.option('--label','-l', help='label map filename to compute uncertainty by region')
38+
3739
@gt.add_options(gt.common_options)
38-
def gt_image_uncertainty(filenames, nevents, output, counts, by_slice, threshold, efficiency, sigma, verbose, **kwargs):
40+
def gt_image_uncertainty(filenames, nevents, output, counts, by_slice, threshold, efficiency, sigma, label, verbose, **kwargs):
3941
'''
4042
Compute relative statistical uncertainty image for a list of
4143
images. Images are summed before computing the the uncertainty.
@@ -56,6 +58,10 @@ def gt_image_uncertainty(filenames, nevents, output, counts, by_slice, threshold
5658
uncertainty. Only consider pixel values greater than threshold %
5759
of the max value in the image.
5860
61+
Option '-l' with the path to a label map will compute the
62+
uncertainty by region. Each region is represented by one label
63+
in the label map.
64+
5965
Example1:
6066
gt_image_uncertainty run.XYZ/output_*/dose-Edep.mhd -o u.mhd -N 100000000
6167
@@ -113,6 +119,9 @@ def gt_image_uncertainty(filenames, nevents, output, counts, by_slice, threshold
113119
# compute uncertainty history by hitory
114120
if by_slice:
115121
uncertainty, m, nb = gt.image_uncertainty_by_slice(filenames, sfilenames, nevents, sigma_flag, threshold)
122+
elif label is not None:
123+
label_image = itk.imread(label)
124+
uncertainty = gt.image_uncertainty_per_region(filenames, sfilenames, label_image, nevents, sigma_flag, threshold)
116125
else:
117126
uncertainty = gt.image_uncertainty(filenames, sfilenames, nevents, sigma_flag, threshold)
118127
else:

0 commit comments

Comments
 (0)