Hi,

Is there a possibility to select nearest neighbor voxels in an MRI based on the label-map. For-example I have the voxels based on some label. then I need to find nearest neighbour voxels that dont belong to voxels identified through label.

I found this

import numpy

volume = array(‘Volume’)

label = array(‘Volume-label’)

points = numpy.where( label == 1 ) # or use another label number depending on what you segmented

values = volume[points] # this will be a list of the label values

values.mean() # should match the mean value of LabelStatistics calculation as a double-check

numpy.savetxt(‘values.txt’, values)

with above I can have voxel values defined by the label-map. how can I get voxel values in the nearest neighbor using these voxel values as reference.