-
Notifications
You must be signed in to change notification settings - Fork 17
Simple Soma Detection
FelixChihTing edited this page Apr 1, 2021
·
1 revision
ero5
is the binary image after thresholding at 5% followed by erosion.
- step 1: label regions by
skimage.measure.label()
- step 2: filter out smaller regions by
skimage.measure.regionprops()
- step 3: print out possible number of soma.
ReLab, NumLab = skimage.measure.label(ero5, return_num=True)
print('number of labels = ',NumLab)
props = skimage.measure.regionprops(ReLab)
CNumLab = NumLab
for x in range(NumLab):
D = props[x].equivalent_diameter
if D < 10:
CNumLab-=1
print('Possible number of somas is',str(CNumLab))
Specify the radius
and the resolution (mip
) of the corresponding subvolume to be labeled. Note that different resolution will lead to different number of known cells listed in voxs
.
dir = "s3://open-neurodata/brainlit/brain1"
dir_segments = "s3://open-neurodata/brainlit/brain1_segments"
mip = 1; radius = 150; v_id = 0
voxs = [];
ngl_sess = NeuroglancerSession(mip=mip, url=dir, url_segments=dir_segments)
for seg_id in range(1000):
try:
vox = ngl_sess._get_voxel(seg_id, v_id)
voxs.append(vox)
except:
pass
Because the bounding box bbox
for the subvolume is known, we can check the total number of known cells in the subvolume.
Nbbox = [10342,6265,4751,10643,6566,5052]
KnoSomNum = 0
for vox in voxs:
if vox[0] > Nbbox[0] and vox[0] < Nbbox[3]:
if vox[1] > Nbbox[1] and vox[1] < Nbbox[4]:
if vox[2] > Nbbox[2] and vox[2] < Nbbox[5]:
KnoSomNum +=1
print('Known number of soma within the subvolume is',str(KnoSomNum))