Week 2
This week saw a significant amount of progress made on my DICOM image recognition software. Because I didn't devote a ton of time to explaining the actual work I've been doing in my initial blog post, we can consider this one to be a sort of summary of everything code-related that's transpired in the first two weeks of my senior project. Unfortunately, explaining what I did this week necessitates significant boring technical explanation, which nobody really wants. To save any prospective blog readers from boredom, and confusion I'll do my best to keep my explanations brief and concise.
I had planned for this Monday to be an opportunity to be super-productive and start the week off on the right foot. Unfortunately, I also had my biennial eye exam early that morning. Something you probably don't know about me is that I can't stand anything going near my eye. Watching someone put in contacts is quite possibly one of the most disgusting things I've ever heard people do on a daily basis and a grain of sand getting in my eye will drive me insane. Everything was going fine in the eye exam (no change in my prescription) until my eye pressure had to be measured. Usually, this just involves having a machine blow a quick puff of air at your eye, but my eyelids kept shutting reflexively so instead the tech resorted to the other option of sticking a probe into my eyeball. I was not thrilled, to say the least. The exam also required that I take dilating eyedrops, which was quite neat at first since it gave me the unique sensation of seeing more per square inch but stopped being thrilling when I went outside and had the sun burn out my retinas. The rest of the day was decidedly unproductive.
But enough about my irrational fear of eyeball touching, let's get down to the code.
Week 1 :
Cool stuff I've learned:
- Python has a built-in tool for finding and downloading a veritable smorgasbord of user-created packages for every possible application imaginable, and IT'S ALL FREE.
- DICOM files can actually be read extremely easily because the pydicom package allows for conversion to an array of pixel data
- the OpenCV package allows me to open images through python using the mac preview application with a single function. I DIDN'T EVEN WRITE THE CODE, IT'S A DOWNLOADABLE PACKAGE
- you can access the mac terminal through python :)
- when you download a package through terminal, there's a little faux text-based progress bar that ticks up. it's very cute
Annoying Stuff:
- it's not immediately clear that the python package download scripts on websites are meant to be entered through terminal, which could lead an inexperienced programmer to paste the script in random places with syntax errors until they luck into pasting it at the correct location.
-the current version of opency-python, a package critical for reading and modifying image files isn't compatible with my version of python, requiring me to hunt through previous versions to find one that would work.
- python has no mass comment functions like java does
Week 2:
Cool stuff I've learned:
- Apparently blurring an image significantly reduces visual noise and allows for cleaner shape detection and thresholding
- actual color information can be stored in a variety of formats determined by bit size for a range of hues and channel number for mixing (ex: 0 channels for greyscale or 3 channels for modern RGB or BGR color).
- the actual process for shape detection is resize -> gaussian blur -> threshold -> findcontours -> analysis
- contour moments can be used to determine the center of a contour, even if it's an indistinct and asymmetrical shape
- watching a program highlight contours on an image is very soothing and satisfying
- shape detection is pretty easy when each contour is aware of the number of vertices it has. The rest of the shape detection can be shored up by relying on the contour area and aspect ratio
Annoying stuff:
- the pixel data in the pixel array of the DICOM file is actually in uint16 or 16 bit, rather than uint8 or 8 bit. I was not aware of this and was thus very perplexed as to why the find contours function was telling me my image was in the wrong format
- the find contours function randomly doesn't work for certain versions of opencv-python, prompting further searching through previous incompatible versions.
- for some reason, the contours on separate shapes will randomly blend together, resulting in separate shapes being recognized as one conglomerate mass incorrectly. I don't know why this happens or how to fix it.
- each time I run the program, a separate instance of python is opened which can only be closed through the force quit menu
Now that you've finished reading everything above, you're probably wondering, does this program even do anything? Luckily, I've finally obtained some actual results to show you how my program works!
Step 1: take a DICOM scan with a tag in it. Note that the scan shown here is a phantom, basically a fake dummy scan, because I'm not sure if I can actually show scans from real people.
Anyhoo, that's all I have for this blog post. See you folks next week.
Eric, I really appreciate your writing style and your sense of audience on these blog posts. So proud of you! (Also that computer stuff seems impressive too.) On another unrelated note--I so, so, feel you on the eye aversion stuff. Hope you gave yourself a treat afterword.
ReplyDeleteHoly smokes! I really love your website design! The python thing you're doing sort of reminds me of what we did in our neural nets project, but 100x more complex. Super cool work Eric!
ReplyDeleteHey Peter,
DeleteThanks for the feedback! I agree that the work I'm doing is surprisingly similar to some of the stuff we did during the Comp Sci III machine learning unit.
Best,
Eric
This comment has been removed by the author.
ReplyDeleteYo Eric,
ReplyDeleteThis is Arlo. Pretty dang cool blog, especially all of the details with your eye examination. I can't exactly relate, but it was funny nonetheless.
This is some really epic work! I like the level of detail you are approaching this with!
ReplyDeleteI think I managed to understand the overview of what you are doing. It sounds like you are having fun and learning lots, which is exactly what these projects are for.
ReplyDelete