# Is there a way to get the dicom slice index number of the slice which contains the ROI?

**URL:** <https://discourse.itk.org/t/is-there-a-way-to-get-the-dicom-slice-index-number-of-the-slice-which-contains-the-roi/5637>\
**Category:** Uncategorized\
**Created:** [January 19, 2023, 6:58pm UTC](https://discourse.itk.org/t/is-there-a-way-to-get-the-dicom-slice-index-number-of-the-slice-which-contains-the-roi/5637 "2023-01-19T18:58:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DushiFdo](https://discourse.itk.org/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@DushiFdo](https://discourse.itk.org/u/DushiFdo)\
**Post date:** [January 19, 2023, 6:58pm UTC](https://discourse.itk.org/t/is-there-a-way-to-get-the-dicom-slice-index-number-of-the-slice-which-contains-the-roi/5637/1 "2023-01-19T18:58:05Z")

</div>

Hello, I am working with 3D Dicom images. I would like to get the index of the slices which contains the liver region (ROI) as some slices do not show liver or full black. Is it possible to do it in sitk?

---

<div class="post-metadata">

**Author:** ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)\
**Post date:** [January 20, 2023, 2:27pm UTC](https://discourse.itk.org/t/is-there-a-way-to-get-the-dicom-slice-index-number-of-the-slice-which-contains-the-roi/5637/2 "2023-01-20T14:27:30Z")

</div>

Hello @DushiFdo,

Yes it is possible to get the indexes:

```auto
label_shape_filter = sitk.LabelShapeStatisticsImageFilter()
label_shape_filter.Execute(roi_mask)
# The bounding box's first three entries are the starting index and last three entries the size
bounding_box = label_shape_filter.GetBoundingBox(roi_value)
start_z_index = bounding_box[2]
end_z_index = bounding_box[2] + bounding_box[5]

```
