thanks for the code.

imageName = flair_path

```
maskName = seg_path
image = sitk.ReadImage(imageName)
stats = sitk.LabelShapeStatisticsImageFilter()
mask = mask = sitk.ReadImage(maskName)
stats.Execute(mask)
try:
centroid = stats.GetCentroid(1)
z.update({'cent_ncr_x':centroid[0],'cent_ncr_y':centroid[1],'cent_ncr_z':centroid[2]})
centroid_ed= stats.GetCentroid(2)
z.update({'cent_ed_x':centroid_ed[0],'cent_ed_y':centroid_ed[1],'cent_ed_z':centroid_ed[2]})
centroid_at= stats.GetCentroid(4)
z.update({'cent_at_x':centroid_at[0],'cent_at_y':centroid_at[1],'cent_at_z':centroid_at[2]})
background_label = 0
print('Multiple labels treated as a single label and its centroid:')
stats.Execute(mask!=background_label)
for label in range(1, stats.GetNumberOfLabels()+1):
centroidofwb=stats.GetCentroid(label)
print("centroidofwb",centroidofwb)
print(f'label{label}: centroid {stats.GetCentroid(label)}')
z.update({'cent_wb_x':centroidofwb[0],'cent_wb_y':centroidofwb[1],'cent_wb_z':centroidofwb[2]})
```

there are three labels in 3d image, 1,2 and 4 now to get centroid of roi including 1,2,4 i have used your code. is it fine?