MiWORD of the Day Is…Cosine Distance!

            Today we will talk about a way to measure distance, but not about how far away two objects are. Instead, cosine distance, or cosine similarity, is a measure of how similar two non-zero vectors are in terms of orientation, or to put it simply, the direction to which they point. Mathematically, the cosine similarity between two 2-D vectors is equal to the cosine of the angle between them, which can also be calculated using their dot product and magnitudes, as shown on the right. Two vectors pointing in the same direction will have a cosine similarity of 1; two vectors perpendicular to each other will have a similarity of 0; two vectors pointing in opposite direction will have a similarity of -1. Cosine distance is equal to (1 – cosine similarity). In this case, two vectors will have a cosine distance between 0 to 2: 0 when they are pointing in the same direction, and 2 when they are pointing in opposite direction. Cosine similarity and distance essentially measure the same thing, but the distance will convert any negative values to positive.

           Cosine distance and similarity also apply to higher dimensions, which makes them useful in analyzing images, texts, and other forms of data. In machine learning, we can use an algorithm to process a dataset of information and store each object as an array of multidimensional vectors, where each vector represents a feature. Then, we can use cosine similarity to compare how similar each pair of vectors are between the two objects and come up with an overall similarity score. In this case, two identical objects will have a similarity score of 1. In higher dimensions, we can rely on the computer to do the calculations for us. For example, we have the distance.cosine function in the SciPy package in Python will compute the cosine distance between two vector arrays in one go.

Here are two examples of how you can use cosine distance in a conversation:

Serious:  “I copied an entire essay for my assignment and this online plagiarizing checker says my similarity score is only 1! Time to hand it in.” “It says a COSINE similarity of 1. Please go back and write it yourself…”

Less serious: *during a police car chase* “Check how far are we from the suspect’s car!” “Well, assuming that he doesn’t turn, the distance between us will always be zero. Remember from your math class? Two vectors pointing in the same direction will always have a cosine distance of zero…”

… I’ll see you in the blogosphere.

Jenny Du

MiWord of the Day Is… Fourier Transform!

Ok, a what Transform now??

In the early 1800s, Jean-Baptiste Joseph Fourier, a French mathematician and physicist, introduced the transform in his study of heat transfer. The idea seemed preposterous to many mathematicians at the time, but it has now become an important cornerstone in mathematics.

So, what exactly is the Fourier Transform? The Fourier Transform is a mathematical transform that decomposes a function into its sine and cosine components. It decomposes a function depending on space or time into a function depending on spatial or temporal frequency.

Before diving into the mathematical intricacies of the Fourier Transform, it is important to understand the intuition and the key idea behind it. The main idea of the Fourier Transform can be explained simply using the metaphor of creating a milkshake.

Imagine you have a milkshake. It is hard to look at a milkshake and understand it directly; answering questions such as “What gives this shake its nutty flavour?” or “What is the sugar content of this shake?” are harder to answer when we are simply given the milkshake. Instead, it is easier to answer these questions by understanding the recipe and the individual ingredients that make up the shake. So, how exactly does the Fourier Transform fit in here? Given a milkshake, the Fourier Transform allows us to find its recipe to determine how it was created; it is able to present the individual ingredients and the proportions at which they were combined to make the shake. This brings up the questions of how does the Fourier transform determine the milkshake “recipe” and why would we even use this transform to get the “recipe”? To answer the former question, we are able to determine the recipe of the milkshake by running it through filters that then extract each individual ingredient that makes up the shake. The reason we use the Fourier Transform to get the “recipe” is that recipes of milkshakes are much easier to analyze, compare, and modify than working with the actual milkshake itself. We can create new milkshakes by analyzing and modifying the recipe of an existing milkshake. Finally, after deconstructing the milkshake into its recipe and ingredients and analyzing them, we can simply blend the ingredients back to get the milkshake.

Extending this metaphor to signals, the Fourier Transform essentially takes a signal and finds the recipe that made it. It provides a specific viewpoint: “What if any signal could be represented as the sum of simple sine waves?”.

By providing a method to decompose a function into its sine and cosine components, we can analyze the function more easily and create modifications as needed for the task at hand.

 A common application of the Fourier Transform is in sound editing. If sound waves can be separated into their “ingredients” (i.e., the base and treble frequencies), we can modify this sound depending on our requirements. We can boost the frequencies we care about while hiding the frequencies that cause disturbances in the original sound. Similarly, there are many other applications of the Fourier Transform such as image compression, communication, and image restoration.

This is incredible! An idea that the mathematics community was skeptical of, now has applications to a variety of real-world applications.

Now, for the fun part, using Fourier Transform in a sentence by the end of the day:

Example 1:

Koby: “This 1000 puzzle is insanely difficult. How are we ever going to end up with the final puzzle picture?”

Eng: “Don’t worry! We can think of the puzzle pieces as being created by taking the ‘Fourier transform’ of the puzzle picture. All we have to do now is take the ‘inverse Fourier Transform’ and then we should be done!”

Koby: “Now when you put it that way…. Let’s do it!”

Example 2: 

Grace: “Hey Rohan! What’s the difference between a first-year and fourth-year computer science student?

Rohan: “… what?”

Grace: “A Fouri-y-e-a-r Transform”

Rohan: “…. (╯°□°)╯︵ ┻━┻ ”

I’ll see you in the blogosphere…

Parinita Edke

The MiDATA Word of the Day is…”clyster”

Holy mother of pearl! Do you remember when the first Pokémon games came out on the Game Boy? Never heard of Pokémon? Get up to speed by watching this short video. Or even better! Try out one of the games in the series, and let me know how that goes!

The name of the Pokémon in this picture is Cloyster. You may remember it from Pokémon Red or Blue. But! Cloyster, in fact, has nothing to do with clysters.

In olden days, clyster meant a bunch of persons, animals or things gathered in a close body. Now, it is better known as a cluster.

You yourself must identify with at least one group of people. What makes you human; your roles, qualities, or actions make you unique. But at the same time, you fall into a group of others with the same characteristics.

You yourself fall into multiple groups (or clusters). This could be your friend circle or perhaps people you connect with on a particular topic. At the end of the day, you belong to these groups. But is there a way we can determine that you, in fact, belong?

Take for example Jack and Rose from the Titanic. Did Jack and Rose belong together?

If you take a look at the plot to the right, Jack and Rose clearly do not belong together. They belong to two separate groups (clusters) of people. Thus, they do not belong together. Case closed!

But perhaps it is a matter of perspective? Let’s take a step back…

Woah! Now, you could now say that they’re close enough, they might as well be together! Compared to the largest group, they are more similar than they are different. And so, they should be together!

For the last time, we may have been looking at this completely wrong! From the very beginning, what are we measuring on the x-axis and on the y-axis of our graph?

Say it was muscle mass and height. That alone shouldn’t tell us if Rose and Jack belong together! And yet, that is exactly what we could have done. But if not those, then what..?

Now for the fun part (see the rules here), using clyster in a sentence by the end of the day:

Serious: Did you see the huge star clysters last night? I heard each one contained anywhere from 10,000 to several million stars…

Less serious: *At a seafood restaurant by the beach* Excuse me, waiter! I’d like one of your freshest clysters, please. – “I’m sorry. We’re all out!”

…I’ll see you in the blogosphere.

Stanley Hua

Today’s MiWORD of the day is… Lasso!

Wait… Lasso? Isn’t a lasso that lariat or loop-like rope that cowboys use? Or perhaps you may be thinking about that tool in Photoshop that’s used for selecting free-form segments!

Well… technically neither is wrong! However, in statistics and machine learning, Lasso stands for something completely different: least absolute shrinkage and selection operator. This term was coined by Dr. Robert Tibshirani in 1996 (who was a UofT professor at that time!).

Okay… that’s cool and all, but what the heck does that actually mean? And what does it do?

Lasso is a type of regression analysis method, meaning it tries to estimate the relationship between predictor variables and outcomes. It’s typically used to perform feature selection or regularization.

Regularization is a way of reducing overfitting of a model, ie. it removes some of the “noise” and randomness of the data. On the other hand, feature selection is a form of dimension reduction. Out of all the predictor variables in a dataset, it will select the few that contribute the most to the outcome variable to include in a predictive model.

Lasso works by applying a fixed upper bound to the sum of absolute values of the coefficient of the predictors in a model. To ensure that this sum is within the upper bound, the algorithm will shrink some of the coefficients, particularly it shrinks the coefficients of predictors that are less important to the outcome. The predictors whose coefficients are shrunk to zero are not included at all in the final predictive model.

Lasso has applications in a variety of different fields! It’s used in finance, economics, physics, mathematics, and if you haven’t guessed already… medical imaging! As the state-of-the-art feature selection technique, Lasso is used a lot in turning large radiomic datasets into easily interpretable predictive models that help researchers study, treat, and diagnose diseases.

Now onto the fun part, using Lasso in a sentence by the end of the day! (see rules here)

Serious: This predictive model I got using Lasso has amazing accuracy for detecting the presence of a tumour!

Less serious: I went to my professor’s office hours for some help on how to use Lasso, but out of nowhere he pulled out a rope!

See you in the blogosphere!

Jessica Xu

MiWord of the Day Is… dimensionality reduction!

Guess what?

You are looking at a real person, not a painting! This is one of the great works by a talented artist Alexa Meade, who paints on 3D objects but creates a 2D painting illusion. Similarly in the world of statistics and machine learning, dimensionality reduction means what it sounds like: reduce the problem to a lower dimension. But only this time, not an illusion.

Imagine a 1x1x1 data point living inside a 2x2x2 feature space. If I ask you to calculate the data density, you will get ½ for 1D, ¼ for 2D and 1/8 for 3D. This simple example illustrates that the data points become sparser in higher dimensional feature space. To address this problem, we need some dimensional reduction tools to eliminate the boring dimensions (dimensions that do not give much information on the characteristics of the data).

There are mainly two approaches when it comes to dimension reduction. One is to select a subset of features (feature selection), the other is to construct some new features to describe the data in fewer dimensions (feature extraction).

Let us consider an example to illustrate the difference. Suppose you are asked to come up features to predict the university acceptance rate of your local high school.

You may discard the “grade in middle school” for its many missing values; discard “date of birth” and “student name” as they are not playing much role in applying university; discard “weight > 50kg” as everyone has the same value; discard “grade in GPA” as it can be calculated. If you have been through a similar process, congratulations! You just performed a dimension reduction by feature selection.

What you have done is removing the features with many missing values, the least correlated features, the features with low variance and one of the highly correlated. The idea behind feature selection is that the data might contain some redundant or irrelevant features and can be removed without losing too much loss information.

Now, instead of selecting a subset of features, you might try to construct some new features from the old ones. For example, you might create a new feature named “school grade” based on the full history of the academic features. If you have been through a thought process like this, you just performed a dimensional reduction by feature extraction

If you would like to do a linear combination, principal component analysis (PCA) is the tool for you. In PCA, variables are linearly combined into a new set of variables, known as the principal components. One way to do so is to give a weighted linear combination of “grade in score”, “grade in middle school” and “recommend letter” …

Now let us use “dimensionality reduction” in a sentence.

Serious: There are too many features in this dataset, and the testing accuracy seems too low. Let us apply dimensional reduction techniques to reduce overfit of our model…

Less serious:

Mom: “How was your trip to Tokyo?”

Me: “Great! Let me just send you a dimensionality reduction version of Tokyo.”

Mom: “A what Tokyo?”

Me: “Well, I mean … photos of Tokyo.”

I’ll see you in the blogosphere…

Jacky Wang

MiWORD of the day is… Mop-top!

Ahhh, the mop-top! I sigh not because I miss the hairdo but because I miss my hair – all of it. In the mid-60s this hair style was made famous by The Beatles. Don’t know who they are (shame on you!) have a listen here for instruction.


Well the mop-top was made popular because the 4 guys who sported the hairdo were crazy successful musicians from England. Their recording company, Electrical Musical Industries (EMI), was also very happy and successful because of the overwhelming record sales (music was sold to listeners on vinyl records back then).


So, what does any of this have to do with medical imaging? Lots actually. The money generated by record sales enabled the EMI basic science researchers (another division of the company) to work in a prosperous cash-rich environment. One of those researchers was Sir Godfrey Hounsfield, an electrical and computer engineer. 


In 1967, he started his work on what would soon become the first CT scanner. By directing x-ray beams through the body at 1 degree angles, with a detector rotating in tandem on the other side, he was able to measure the attenuation of x-rays. These values were then analysed using a mathematical algorithm and a computer to yield a 2-D image of the interior of the body. The production of CT scanners by EMI started in the early 1970s and their monopoly ended by 1975 when companies like DISCO (not even kidding) and GE entered the arena.


Interestingly, in the 1960s Dr Allan Cormack of South Africa had also independently showed similar results to Housfield. In the end, Cormack was cited for his math analysis that led to the CT scan and Housfield for its practical development. They shared the Nobel prize in Physics and Medicine in 1979. Cool.

Now for the fun part (see the rules here), using mop-top in a sentence by the end of the day:

Serious: Who would have thought the success of the mop-top Fab Four would be instrumental in the development of the CT scanner?

Less serious: Hey Bob, I went for my head CT scan today and something weird happened. I went in bald and came out with a mop-top! Is that normal?…

Listen to With a Little Help from My Friends from The Beatles to decompress and…

…I’ll see you in the blogosphere.

Pascal Tyrrell


MiWORD of the day is… Piezoelectric!

Ah, the super villain Livewire. Not sure she was all that much of a challenge for Superman but there you have it: electricity, spandex, and crazy hair. The perfect foe. I wonder if she will make an appearance in the latest Supergirl TV series?


So, today the MiWORD of the day is piezoelectric. Sounds like a fancy name for a downtown pizzaria – but it’s not. Way back before Roentgen discovered x-rays, Pierre and Jacques Curie in 1877 discovered a phenomenon that occurs when crystals are mechanically distorted by external pressure so that an electrical potential develops between the crystal surfaces: the piezoelectric effect. The term was coined by the brothers from the Greek for “pressure-electricity”. So basically, certain crystals (which include quartz, topaz, tourmaline…) can convert electrical to mechanical energy and vice versa.


Why is this important you ask? Well, because this discovery lead to the development of microphones, earphones, and most importantly for us – ultrasound. Based on the physics of sound and not light, ultrasound captures images by manipulating and analyzing sound waves, very high-frequency sound waves as they bounce off surfaces and echo back to the sender. The idea of getting some kind of image from sound waves was first thought of after the sinking of the Titanic in 1912: detecting submerged icebergs with sound reflection.



A little later, in Austria, two brothers Karl and Friedreich Dussik (do you see a trend here?) transmitted sound waves through a patient’s head in 1937. This and then the development of the SONAR (sound navigation and ranging) in WWII was the ground work needed to launch the field of ultrasonography. It would take, however, 20 years after WWII for ultrasonography to become a commercial reality.







Not only is ultrasound one the oldest medical imaging technologies but it is also an important tool for visualizing soft tissue structures in medical diagnosis, follow up of disease processes and pregnancies. Cool.

 


 


 

 





Now for the fun part (see the rules here), using piezoelectric in a sentence by the end of the day:

Serious: Mom went for her ultrasound today. Told me that I am going to have a little baby sister! She had to wait a while to have her scan because the piezoelectric transducer was on the fritz – again.


Less serious: Hey Bob, do you remember a pizza place on Electric Avenue in Calgary? Piezoelectric something or other? All closed down now. What a shame…




Listen to Electric Avenue from Eddy Grant to decompress and…

…I’ll see you in the blogosphere.

Pascal Tyrrell

MiWord of the Day Is… UBO?!!!

I must mean UFO or Unidentified Flying Object? You remember the movie Close Encounters of the Thrid Kind? Spielberg’s massive hit in 1977 following his release of the original Jaws. Back in those days UFO sightings were often in the news (or tabloids anyway) and this movie hit the sweet spot. It even helped launch the toy “Simon” which as it turns out was very similar to the multicolored, note-playing alien saucers featured in the movie – coincidence?


So, what the heck is UBO? Well, as it turns out the human body exhibits a variety of anatomical details in the ever so important Magnetic Resonance Imaging (MRI) scan that we have all learned to love (see our series on MRI and Carotid Stenosis). The majority of patients have similar anatomical features on imaging but some fall outside these normative patterns. When radiologists come across findings that are difficult  to interpret they will often refer to them as “Unidentified Bright Objects”. The challenge, of course, is that the radiologist needs to decide whether to label the anatomy in the image an “UBO” – essentially an image artifact – or “disease”.


This is where the rubber meets the road. Interpretation of MRI scans is work done by people, and, as with all jobs, the quality of performance varies. Therefore, the accuracy of the MRI exam is heavily dependent on the quality of the radiologists who interpret them. It is for this reason that the training a radiologist receives is crucial to his/her success. In addition, there is an important relationship that exists between the radiologist and the primary care physician as they have to balance indications of abnormality in MRI scans with the information provided by other techniques such as the clinical exam. A successful diagnosis relies on a good team effort. 


Go Team!




Now for the fun part (see the rules here), using UBO in a sentence by the end of the day:

Serious: Went for my MRI today. Told me that the UBO on imaging was just an artifact. Nothing to worry about. Phew!

Less serious: Hey Bob, did you hear on the news the report of another UBO hovering over farmer John’s field last night?  Or was that UFO? I always get those two mixed up…




Listen to UB [4] 0’s Red Red Wine to decompress and…




…I’ll see you in the blogosphere.




Pascal Tyrrell

MiWord of the Day Is… Magnet!

Who hasn’t thought of having Magneto’s powers? No? Maybe you should watch this Magneto trailer for a refresher. 


Ok, now that we all want to be Magneto (secretly at least) what is it that is so appealing with having the power of magnetism? Bill Nye the Science Guy explains it very well in this clip. Have a gander.


In a nutshell, magnetism is a physical phenomena that consists of a field of energy created by “magnets” that attracts or repels other objects. Magnets come in two major flavors: permanent magnets made of materials (such as iron) and electromagnets – the strongest and most widely used in medical imaging. 


Interestingly, it is the sum of the magnetic fields of individual electrons that is responsible for all the fun (see quantum mechanics). In the case of electromagnetism the electric current in a wire produces a magnetic field in the same direction of the current. In the case of a permanent magnet it is the magnetic fields of the naturally occurring electrically charged particles of the atoms that make up the material (iron for example) that are responsible. However, for there to exist a force strong enough to attract or repel another object all of its magnetic ions must have their magnetic fields aligned and contributing to the net magnetization. This is how you can magnetize a needle when stroking it in a uniform directional way with a permanent magnet.





Magnetism is to MRI what radiation is to X-rays. The strength of magnets is measured in gauss and Tesla units. There are 10,000 gauss to a Tesla and the earth’s magnetic field is one half of a gauss. Today most clinical MRIs use superconducting magnets whose strength range up to 4 Tesla! Experimental MRIs can run up to 10 Tesla. Now that is more Magneto’s speed.


The powerful magnets allow for better spacial resolution allowing for better sensitivity of the image. However, all this magnetic strength comes at a cost: the production of chemical shift artifacts – ghosts of things that are not really there. This is why we have radiologists to make sense of it all.


OK. Now you are asking what the heck. Magneto in the X-Men movie was able to rip out the iron from a human so why doesn’t an MRI? Great question. Iron found in the human body is mostly found as ferritin (a type of iron oxide) and is NOT magnetic. The iron in hemoglobin is also NOT magnetic. Bummer. So how does Magneto do it? Well either the movie is not scientifically correct (now that would be a shocker) or possibly he could be drawing on magnetite (another iron oxide) that is magnetic and has been found in trace amounts in the blood and brain. It is so little though that it does not cause any concern for MRI. Oh well, so much for Magneto…

Now for the fun part (see the rules here), using magnet in a sentence by the end of the day:

Serious: Hey Bob, did you know that early MRI machines used permanent magnets?

Less serious: Went for my MRI today. Told them I was worried the MRI would rip all the iron out of my blood like in X-Men. They didn’t even know who Magneto was. Whaaaat?!!

OK, listen to Magnetic by Traphik to decompress and I’ll see you in the blogosphere…

Pascal Tyrrell










MiWord of the Day Is… Xeroradiography!

Who hasn’t done some creative photocopying at some point in their lives? I certainly do NOT condone this type of activity (very naughty) but would you believe me if I were to tell you that for a long while mammography made use of photocopy technology? Yes, I realize this sounds a little funny. Let me explain.


In the 1970s medicine made the association between heavy exposure to radiation for TB and thyroid treatments and the appearance of breast cancer three decades later. A reevaluation of the effects of radiation ensued and a call for ways to minimize exposure to ionizing radiation was made to the industry.


One of the first to answer that call was the radiologist John Wolfe from Detroit Receiving Hospital who in 1966 reported on the advantages of coupling photocopy technology with mammography. Xerox corporation jumped on the idea and developed a commercial unit in 1971 and “xeroradiography” was born! Basically, film from traditional x-ray imaging (yes back then they still used film!) was replaced with a selenium coated aluminum plate that was prepared for the exposure by being electrically charged. The result was that only a short burst of radiation (shorter exposure time means lower dose of radiation) was required to produce a very high quality image.






These xerox mammograms dominated the industry for over 20 years until new technology was developed more recently that provided even finer images with even less radiation. Cool.




Now for the fun part (see the rules here), using Xeroradiography in a sentence by the end of the day:


Serious: Hey Bob, did you know that mammograms produced using xeroradiography were blue? 


Less serious: My friend Jane was scheduled for a mammography. Having heard of xeroradiography reading the MiVIP blog she decided to DIY at her office. Problem was the print kept coming out black and white instead of blue from the Xerox machine…




OK, watch the Copy Cat trailer to decompress (or not?!!!) and I’ll see you in the blogosphere…




Pascal Tyrrell