can anyone please guide me how to do segmentation by simple thresholding on 3d mri nifti files of brain blood vessel (mra) data?
You could do either simple thresholding by selecting a threshold value from a grayscale histogram of your image, or use an automatic method such as Otsu thresholding. The coding is pretty simple in Matlab or Python, I found a quick python tutorial here.
If you prefer, you could also do thresholding in imageJ. A link to some tutorials was recently posted in the education section here.
@jmdc do you have any suggestions for doing this type of 3D segmentation in ImageJ?
Hi @mukund_shah. I believe FIJI (ImageJ) can open your NIfTI files. If you go to Image > Adjust Threshold, you can choose among the automatic thresholding algorithms (including Otsu, as @imageClarity suggested). 3D segmentation can also be done via the 3D objects counter. If you are interested, besides the tutorials posted in the education section, I do have additional tutorials about thresholding 3D images here: https://youtube.com/playlist?list=PLZqcDkddyhIK5uxaqBvHIzLIBW80-Ox-6.
thanks a lot @imageClarity and @jmdc ,I will try it .Also @imageClarity I did simple thresholdong slice by slice and i am getting segmented image by otsu but how do i save that image ,as its 512512100 image i ran for loop for 100 slices ,each i stored in a list and converted to np array which is of size 100512512 now when i reshape it to 512512100 ,the image is a tottally different image,How do i solve this?
It may help figuring out the data organization to rehape the 2D images as they are thresholded in the loop and store them in the numpy array that is 100 elements in the z dir rather than to reshaping all data at the end.
thanks for the reply,I got it,For those who view this post later i used np.dstack().
Hi @mukund_shah, if possible it would be really nice if you could share a screenshot of the segmented MRA data.
@imagingQA actually i am havung issue with that , i tried multi otsu by giving 2 classes but i am not getting desired results,i will try adaptive thresholding and if i get desired result i will share the screen shot along with the code
I just used simple thresholding technique in python,i analysed the image in 3d slicer and saw that threshold is between 20-30% of max value of pixel so i used that value here,about 20%.
@imagingQA i have uploaded the image
Just adding a question from @mukund_shah related to the tread
Hi guys i have 2 nifti images both of same size i.e 256 256 256 and one is segmented brain image and other is segmented blood vessel img,so i want to combine and make an img where there are segmented image labels along with blood vessels and i assign a new label to blood vessel to the image,How do i do this in python?
Since the arrays are the same size it should be a matter of replacing values in the segmented brain image where blood vessels have been labelled in the other image. Something like the following.
If you have labelled vessels with a 1, and you want these to be given the value of say 100 in your segmented brain image:
segmented_brain_img[segmented_vessel_img == 1] = 100