Hi All,
I have a set of midpoints (from labelled tumours within a set of scans [512x512x512 voxels]). I'm just trying to create a sphere with a radius of 10 voxels at each midpoint. To do this, I'm using raster_geometry.sphere and defining the position as the midpoint/512 (i.e. position = midpoint/ 512 , raster_geometry.sphere(512, 10, positon) )
When I'm doing this, however, the volume of the sphere changes. Is there something I don't understand about raster_geometry?
from logzero import logger as logging
from lama import common
import numpy as np
import SimpleITK as sitk
import raster_geometry as rg
for i, img_path in enumerate(scan_paths):
logging.info(img_path)
logging.info(tumour_paths[i])
m_loader = common.LoadImage(tumour_paths[i])
mask = m_loader.img
m_array = sitk.GetArrayFromImage(mask)
s = ndimage.find_objects(m_array)[-1]
midpoint = [(np.mean([s[0].start, s[0].stop]))/512,
(np.mean([s[1].start, s[1].stop]))/512,
(np.mean([s[2].start, s[2].stop]))/512]
print("Original Midpoint", [i*512 for i in midpoint])
print("Modified midpoint", midpoint)
arr = rg.sphere(512, 10, midpoint).astype(np.int_)
print(np.count_nonzero(arr))
print(np.sum(arr))
Example Output:
[I 220525 17:37:58 radiomics_normaliser:86] E:\220204_BQ_dataset\220521_BQ_norm\imgs\200721_MPTLVo3_GFSeeds_4T1R_4T1R_D7_C1_002.nrrd
[I 220525 17:37:58 radiomics_normaliser:87] E:\220204_BQ_dataset\220521_BQ_norm\tumour_respaced\200721_MPTLVo3_GFSeeds_4T1R_4T1R_D7_C1_002.nrrd
Original Midpoint [260.5, 252.5, 162.0]
Modified midpoint [0.5087890625, 0.4931640625, 0.31640625]
4160
4160
[I 220525 17:38:14 radiomics_normaliser:86] E:\220204_BQ_dataset\220521_BQ_norm\imgs\200721_MPTLVo3_GFseeds_4T1R_4T1R_D7_C1_003.nrrd
[I 220525 17:38:14 radiomics_normaliser:87] E:\220204_BQ_dataset\220521_BQ_norm\tumour_respaced\200721_MPTLVo3_GFseeds_4T1R_4T1R_D7_C1_003.nrrd
Original Midpoint [219.5, 234.5, 165.5]
Modified midpoint [0.4287109375, 0.4580078125, 0.3232421875]
4165
4165
Hi All,
I have a set of midpoints (from labelled tumours within a set of scans [512x512x512 voxels]). I'm just trying to create a sphere with a radius of 10 voxels at each midpoint. To do this, I'm using raster_geometry.sphere and defining the position as the midpoint/512 (i.e. position = midpoint/ 512 , raster_geometry.sphere(512, 10, positon) )
When I'm doing this, however, the volume of the sphere changes. Is there something I don't understand about raster_geometry?
Example Output: