Sunday, June 27, 2021

Lymphatic System

This post is a little different than my usual blog posts. This is related to Human Physiology and I am not an expert in this topic and this post is purely written to get some domain knowledge as an effort to start research in Lymphoma and Positron Emission Tomography(PET) analysis.

Although I have some idea about human anatomy from Biology class in high school, the lymphatic system was not as much focused as the Cardiovascular system in high school biology. It’s interesting that apart from the Cardiovascular system, another circulatory system with a totally different function runs parallel to the blood vessels.

So, what does the Lymphatic System do?

Lymphatic System has three primary functions.

  • Fighting infections
  • Draining excess fluid
  • Lipid absorption

The lymphatic system carries the defense cells known as Lymphocytes in a watery(clear/milky/yellowish) fluid called Lymph. The blood leaves behind waste products and proteins and fluids when it circulates through the body. The excess fluid is drained through capillaries and then into the lymphatic system where it is filtered and the clean fluid is returned to the blood. LS also absorbs lipids from the intestine and transports them to the blood.

The lymphatic system consists of lymph nodes, lymph vessels, and lymph capillaries running parallel to veins and arteries throughout the body. Lymph vessels and lymph capillaries collect the fluid from different parts of the body. The fluid left by the blood in different parts of the body, in between the cells, contain bacteria and toxins which are taken to the lymph nodes and filtered. Such filtered fluid is then enriched with the defense cells and is sent back to different parts of the body.

No central Pump Unlike cardiovascular system, the lymphatic system is not a closed system and it does not have a central pump. Lymph nodes are equipped with valves to permit the one-way flow of the fluid only. As there is no central pump like the heart, the movement of fluid is facilitated by the movement of muscles. Thus, for the proper functioning of the lymphatic system, we need proper physical exercise. Besides, the function of the lymphatic system is aided by breathing, pulsation in the arteries, and often done through external compression techniques such as manual drainage therapy compressing bandaging, etc. Sometimes, due to the failure of the lymphatic functions, the fluid can not be drained and a condition called lymphoedema is observed. Lymphoedema is an inflammation of tissues due to the accumulation of excess fluid when the lymphatic system fails to drain the fluid. Lymphostatis, lymphangitis is also caused due to the malfunctioning of the Lymphatic system.

Lymphoma Yes, all this domain knowledge I was trying to acquire was for the study of Lymphoma. Simply speaking it is a cancer of Lymph nodes of Lymph cells. Lymphoma is a type of cancer where the lymphocytes change and grow out of control. There are different types of Lymphoma, but I will be studying and writing notes on Diffuse Large B-Cell Lymphoma(DLBCL) some other day.

Friday, December 21, 2018

2. Spectral Clustering - Basic Concepts

This is the second part of the multiple blogs on Spectral Clustering. Following are the links to all the parts of this series.

1.  Spectral Clustering - Intro
2.  Spectral Clustering - Basic Ideas
3.

2. Spectral Clustering  - Basic Concepts


The data can be represented in different ways. Tabular data and graph data are common ways to represent the data.

Tabular data: The data is organized into tables. Each table having a specific format arranged in fixed number of columns.  
Graph Data: Graph representation of the data involves organization of data in the form of nodes and edges. Where nodes store the information or the property while the edges represent the relationship between the nodes.

Graph

A graph consists of a set of nodes(V) and a set of edges(E) to represent the relation between the nodes.



 Fig 1. Example graph with 5 vertices and 5 edges



G = {V, E}
V = {v1, v2, v3, v4, v5, v6, …}
E = {e1, e2, e3, e4, e5, …}

Where V is a set of vertices and E is a set of edges.


Common Terminologies

The common terminologies and concepts which will be applicable in spectral clustering are,

Adjacency Matrix(W):  A graph can be represented as a two-dimensional array of size V x V, where V is a number of vertices. Both rows and columns of the adjacency are labeled by the vertices hence making it a square matrix and symmetric. The element (wij) of the adjacency matrix indicate whether the two vertices are adjacent (connected by a common edge.) or not. The example graph shown in fig 1. can be represented as an Adjacency Matrix as below.

Fig 2. Adjacency Matrix for the example graph in fig 1

Degree of a vertex(di): Degree of a vertex is the number of edges that touch the vertex. For example, in the example graph above. The degree of vertex v1 is 2. The degree of a vertex is the sum of the elements of a row or a column of an adjacency matrix corresponding to the vertex.

di = w11 + w12 + w13+ w14 …….



Fig 3. Degree of vertices of the example graph shown above.

Degree Matrix(D): A degree matrix is a diagonal matrix with the information about the degree of the vertices. The size of the matrix is also VxV.

Fig. 4 Degree Matrix


Laplacian Matrix (L): A Laplacian of a graph is given by the D – W, where D is a diagonal matrix formed from the vertex degrees and W is an adjacency matrix.

These are the basic concepts of Graph theory applicable to Spectral Clustering.
I will next write about the Spectral Clustering in the next Part of this blog series.




Thursday, December 20, 2018

1. Spectral Clustering - Intro

This is the first part of the multiple blogs on Spectral Clustering. I will write a few blogs related to basic concepts in Spectral clustering in this series. Below are the links to all the parts of this series.

1.  Spectral Clustering - Intro
2.  Spectral Clustering - Basic Ideas
3.


1. Spectral Clustering - Intro


To start with spectral clustering, let’s first see what clustering is.

Clustering is a technique used for automatically grouping the data-points into a number of clusters based on their similarity so that less similar points fall under different clusters.

Clustering is basically done by grouping the points into clusters based on some distance measure, so that the points in same cluster have a small distance from one another. However, proximity is not always the relationship between the data points. Sometimes geometrical relation is also important. Spectral clustering is based on such relationships.

How does spectral clustering fit into the world of machine learning?

Firstly, machine learning techniques are broadly classified into supervised and unsupervised (of course there is semi-supervised too, but let’s not go into that now) machine learning. To put it simply, supervised learning involves the use of labeled training data and the unsupervised learning deals with the unlabeled data.

Clustering is an unsupervised technique. Among the most popular clustering techniques, we have K-means, Gaussian Mixture Model, Expectation Maximization(EM), Spectral Clustering etc.

Yes, that where Spectral Clustering lies in the big picture. Spectral clustering is performed in Graph Data. 

In next blog, I will try to write something about the Graph Theory and Basic ideas needed before jumping into theory of Spectral clustering.

Wednesday, October 11, 2017

Detection in Image Recognition

Image recognition is very important technology and image recognition has an endless scope in every field. Image recognition techniques have been applied in different applications such as finding pedestrians on the streets, detecting moving vehicles, counting the people in public places. Application of image recognition in the medical field has also been proven significant.

Image recognition technology is usually evaluated with the detection rate which indicates how well the objects are detected. The detection rate is measured based on the test where the number of successfully detected images are counted among the images used as input for the detection algorithm.

For example, let's say we have 100 images with faces of people. Each image may have either only one face or many faces. So let's say that the total number of faces included in 100 test images is 200. If the number of faces detected by the face detection algorithm is 100, the detection rate of this algorithm 50%.  Generally speaking, the detection rate of 50 percent doesn't sound appealing but it is not always the case. For example, let's say we have a CCTV camera that detects the faces of the people passing by. Let's assume that this camera takes footage at 10 frames/second and use it for face detection. So whenever a face appears in front of the camera, the same algorithm with 50% detection rate will detect it with 99% chance of detecting it.

Although detection rate is a reasonable measure for evaluating the performance on still images, for evaluating the performance of the real-time video, detection rate per unit time is more appropriate metric.

Saturday, February 4, 2017

Machine Learning

Machine Learning

There are several keywords being used quite frequently in tech world like, Big data, Machine Learning, Information Discovery, Data Mining etc. Although Machine Learning is being practiced for a long time it has been one of the top buzz words in the tech industry in past few years.
Since data is at the center of all technologies, Machine learning is being used by scholars, enterprises of all domains. So such keywords are being used in different domains in different way but we can group them under the umbrella of Artificial Intelligence. 

Abundance of Data,
Data is being collected from everywhere for example, social network data, news articles, purchase data, consumer response data in various field, health related data, similarly various device generated data is being collected in large quantity.




A computer program is said to learn from experience E with respect to some task T and some performance measure P, if its performance on T, as measured by P, improves with experience E. -- Tom Mitchell



Machine Learning is Everywhere

Document classification
Document classification has been one of the widely used application of Machine learning  for quite some time now. Spam detection in emails has been prominent in the email service for quite a long time.  Classification of online information contained in blogs, news articles etc. and  information extraction is also an important application of Machine learning.

Stock market prediction
Although the stock market prices are said to be highly un-predictive in nature, but with the right approach and use of proper features selection has enabled various firms to leverage machine learning technique to make useful prediction of stock market prices.

Character recognition
Character recognition is another important application of Machine learning. Now the Optical character recognition is sophisticated enough to correctly identify the wide range of printed and handwritten characters which has been very useful in day-to-day life.

SNS recommendation
Similarly, recommendation systems in social networks, like Linkedin, Facebook are amazing application of Machine Learning. In social networks use of machine learning is widespread for recommending related contents to the users. Providing the relevant feed to the users is one of the most important aspects of social networks.

Robotics
Robotics is another field where machine learning is widely used which involves various decision making and computer vision. Imitation learning techniques have been very important part of robotics. Machine learning has made robotics an integral part of various domains like medicine, Transportation, and manufacturing industry.

Random Jungles


After a long time, I thought I should continue blogging again and started this blog to share my experience with machine learning, which you might have guessed from the blog name, inspired by popular machine learning algorithm(Random Forests). Although I will be writing about data science most of the time, But this blog isn’t much formal so there will be some gossips about my personal experiences too. The blogs I share  will be mostly based on what I know about Machine learning so might not be explanatory enough. Please feel free to suggest any additional information through comments.
I also Imported Andorid related blogs from my old blog(Technoguff). I will continue writing about Android too whenever I am free.

Saturday, July 25, 2015

Navigation View - Support Design Library

In our previous tutorial about Navigation Drawer we saw how to create a navigation drawer using RecyclerView. Before Support Design Library was introduced we had to create navigation drawer using RecyclerView or ListView. We saw in two part series of the tutorial, how much work needed to create a Navigation drawer. It included the setting up adapter, creating different view types and implementing our own listener for selecting Menus.





NavigationView from Design Support Library comes really handy when we want to add Navigation Drawer to our app. Let's create a Navigation Drawer using NavigationView like the screenshot below.




Let's create an Android project with Blank Activity template and add a Toolbar, We will be using Toolbar instead of Actionbar so in values/styles.xml use theme with NoActionbar. Set toolbar as the actionbar of Mainactivity. So MainActivity.java looks like this.



public class MainActivity extends AppCompatActivity {

    private Toolbar mToolbar;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        
        mToolbar = (Toolbar)findViewById(R.id.appBar);
        setSupportActionBar(mToolbar);
    }


}


Since we will be using NavigationView from Design Support Library, let's at that to the dependencies. Open build.gradle file from app module and add following lines.
OR you can just select the project and hit f4 to open the Project Structure dialog and select dependencies tab , click plus icon at the bottom select library dependency and search recyclerview and select the following library from the list to include it.


    compile 'com.android.support:design:22.2.1'





Best thing about NavigationView is that we don't have to create layouts for each menu item as it uses our existing menu system. if you already have created new android project, let's add a menu called menu_nav_drawer.xml.


<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/menu_inbox"
        android:orderInCategory="100"
        android:title="@string/inbox"
        android:icon="@drawable/inbox"
        app:showAsAction="never" />
    <item
        android:id="@+id/menu_send"
        android:orderInCategory="200"
        android:title="@string/send"
        android:icon="@drawable/send"
        app:showAsAction="never" />

</menu>



We just created two menu items, Inbox and Send, If you need icons for them, please download from here.

Next, we create layout for Main activity, in change activity_main.xml as below.


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".MainActivity">

    <android.support.v7.widget.Toolbar
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/abc_action_bar_default_height_material"
        android:background="#00bbff"/>



    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawerLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/appBar">
        <!--Content-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">


            <TextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="@string/app_name" />

        </LinearLayout>

        <!-- Navigation Drawer-->
        <android.support.design.widget.NavigationView
            android:id="@+id/navigationView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:menu="@menu/menu_nav_drawer"
            android:layout_gravity="left"/>

    </android.support.v4.widget.DrawerLayout>

</RelativeLayout>

Here, we are using a LinearLayout for our content with a TextView in it. And for Navigation drawer we are using NavigationView.

In navigation we can set up the menu using menu attribute.  We assigned the menu that we created in XML.


            app:menu="@menu/menu_nav_drawer"


Now if you run the project you will see navigation drawer is all set with menu titles and icons





Now Let's add the ActionbarDrawerToggle to add nice icons.


        mDrawerLayout = (DrawerLayout)findViewById(R.id.drawerLayout);


        ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.open, R.string.close);

        mDrawerLayout.setDrawerListener(drawerToggle);
        drawerToggle.syncState();



Now finally let's add Listener to the menu items.


             mNavigationView.setNavigationItemSelectedListener(
                        new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(MenuItem menuItem) {
                if (menuItem.getItemId() == R.id.menu_inbox) {
                    Toast.makeText(MainActivity.this, 
                                  "Selected Inbox", 
                                  Toast.LENGTH_SHORT).show();
                    mDrawerLayout.closeDrawer(mNavigationView);
                }
                return false;
            }
        });



Finally add a header view. For that just create a layout and use addHeaderView method on NavigationView.



       View view = getLayoutInflater().inflate(R.layout.layout_drawer_header, 
                   mNavigationView, false);

        mNavigationView.addHeaderView(view);






We saw how Support Design Library made it very easy to create a navigation drawer.