{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Competition Goal:\n1. In this competition, you’ll predict a `patient’s severity` of decline in lung function based on a CT scan of their lungs.\n2. You’ll determine lung function based on output from a spirometer, which measures the volume of air inhaled and exhaled. \n3. The challenge is to use machine learning techniques to make a prediction with the `image`, `metadata`, and `baseline FVC` as input.","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"# Useful Terms:\n\n\n\n","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Pulmonary Fibrosis","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"![](https://www.mayoclinic.org/-/media/kcms/gbs/patient-consumer/images/2016/08/10/14/57/mcdc7_pulmonaryfibrosis-8col.jpg)\n>Pulmonary fibrosis scars and thickens the tissue around and between the air sacs (alveoli) in your lungs, as shown on the right. A normal lung with normal alveoli is shown on the left.\n\n* Pulmonary fibrosis is a lung disease that occurs when lung tissue becomes damaged and scarred. This thickened, stiff tissue makes it more difficult for your lungs to work properly. As pulmonary fibrosis worsens, you become progressively more short of breath.\n\n* The scarring associated with pulmonary fibrosis can be caused by a multitude of factors. But in most cases, doctors can't pinpoint what's causing the problem. When a cause can't be found, the condition is termed idiopathic pulmonary fibrosis.\n\n* The lung damage caused by pulmonary fibrosis can't be repaired, but medications and therapies can sometimes help ease symptoms and improve quality of life. For some people, a lung transplant might be appropriate.\n\n****On spirometry, as a restrictive lung disease, both the `FEV1` (forced expiratory volume in 1 second) and `FVC` (forced vital capacity) are reduced so the `FEV1/FVC` ratio is normal or even increased in contrast to obstructive lung disease where this ratio is reduced. The values for residual volume and total lung capacity are generally decreased in restrictive lung disease****","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"\n## Plumonary Vs Idiopathic Pulmonary Fibrosis:\n\n### Pulmonary Fibrosis:\nThe word `pulmonary` means lung and the word `fibrosis` means scar tissue— similar to scars that you may have on your skin from an old injury or surgery. So, in its simplest sense, `pulmonary fibrosis (PF)` means scarring in the lungs. Over time, the scar tissue can destroy the normal lung and make it hard for oxygen to get into your blood. Low oxygen levels (and the stiff scar tissue itself) can cause you to feel short of breath, particularly when walking and exercising. Pulmonary fibrosis isn’t just one disease. It is a family of more than 200 different lung diseases that all look very much alike. The `PF` family of lung diseases falls into an even larger group of diseases called the interstitial lung diseases (also known as `ILD`), which includes all of the diseases that have inflammation and/or scarring in the lung. Some interstitial lung diseases don’t include scar tissue. When an interstitial lung disease does include scar tissue in the lung, we call it pulmonary fibrosis.\n\n![](https://www.pulmonaryfibrosis.org/images/default-source/default-album/normal-and-impaired-gas-exchange.png?sfvrsn=c3b0918d_0)\n\n\n### Idiopathic Pulmonary Fibrosis:\n`Idiopathic Pulmonary Fibrosis (IPF)` is a scarring disease of the lungs of unknown cause. To make a diagnosis of `IPF`, your doctor will perform a thorough history to try to identify potential exposures or other diseases that might lead to scarring of the lung.\n\nIf diagnosed, over time scarring can worsen making it hard to take a deep breath. The lungs then cannot take in enough oxygen to oxygenate the blood. `IPF` is a form of interstitial lung disease, primarily involving the interstitium or the tissue and space around the air sacs of the lungs, and not directly affecting the airways or blood vessels. \n\n\nThere are various kinds of interstitial lung disease that can also be caused by inflammation and/or fibrosis. These types of `IPF` are treated a bit differently. It is important to work with your health care provider to determine if you have `IPF` or another form of interstitial lung disease.\nIf a plausible cause is found, then you do not have `IPF`. The scarring pattern of `IPF` is technically called usual interstitial pneumonia `(UIP)`. Your doctor will use detailed X-rays of your lungs called high-resolution computed tomography `(HRCT)` and sometimes a lung biopsy to look for this pattern. A diagnosis of `IPF` requires that your doctor cannot find a cause and the presence of a pattern of `UIP` on either `HRCT` or a surgical lung biopsy sample. \n\nAlthough `IPF` is still considered to be a disease of unknown cause, we do know some factors that increase the risk of getting `IPF`, including aging (`IPF` is rare before age 50), cigarette smoking, and having certain genetic predispositions.","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Symptoms:\n\n*     Shortness of breath (dyspnea)\n*     A dry cough\n*     Fatigue\n*     Unexplained weight loss\n*     Aching muscles and joints\n*     Widening and rounding of the tips of the fingers or toes (clubbing)\n","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Risk factors:\n\n*     `Age`. Although pulmonary fibrosis has been diagnosed in children and infants, the disorder is much more likely to affect middle-aged and older adults.\n*     `Sex`. Idiopathic pulmonary fibrosis is more likely to affect men than women.\n*     `Smoking`. Far more smokers and former smokers develop pulmonary fibrosis than do people who have never smoked. Pulmonary fibrosis can occur in patients with emphysema.\n*     `Certain occupations`. You have an increased risk of developing pulmonary fibrosis if you work in mining, farming or construction or if you're exposed to pollutants known to damage your lungs.\n*     `Cancer treatments`. Having radiation treatments to your chest or using certain chemotherapy drugs can increase your risk of pulmonary fibrosis.\n*     `Genetic factors`. Some types of pulmonary fibrosis run in families, and genetic factors may be a component.\n","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Diagnosis:\n\nTo diagnose your condition, your doctor may review your medical and family history, discuss your signs and symptoms, review any exposure you've had to dusts, gases and chemicals, and conduct a physical exam. During the physical exam, your doctor will use a stethoscope to listen carefully to your lungs while you breathe. He or she may also suggest one or more of the following tests.\n\n### Imaging tests:\n\n*     `Chest X-ray`. A chest X-ray shows images of your chest. This may show the scar tissue typical of pulmonary fibrosis, and it may be useful for monitoring the course of the illness and treatment. However, sometimes the chest X-ray may be normal, and further tests may be required to explain your shortness of breath.\n\n*     `Computerized tomography (CT) scan`. CT scanners use a computer to combine X-ray images taken from many different angles to produce cross-sectional images of internal structures in the body. A high-resolution CT scan can be particularly helpful in determining the extent of lung damage caused by pulmonary fibrosis. Also, some kinds of fibrosis have characteristic patterns.\n\n*     `Echocardiogram`. An echocardiogram uses sound waves to visualize the heart. It can produce still images of your heart's structures, as well as videos that show how your heart is functioning. This test can evaluate the amount of pressure occurring in the right side of your heart.\n\n### Lung function tests:\n\n*     `Pulmonary function testing`. Several types of pulmonary function tests may be conducted. In a test called spirometry, you exhale quickly and forcefully through a tube connected to a machine. The machine measures how much air your lungs can hold and how quickly you can move air in and out of your lungs. Other tests may be conducted to measure your lung volumes and diffusing capacity.\n\n*     `Pulse oximetry`. This simple test uses a small device placed on one of your fingers to measure the oxygen saturation in your blood. Oximetry can serve as a way to monitor the course of the disease.\n\n*     `Exercise stress test`. An exercise test on a treadmill or stationary bike may be used to monitor your lung function when you're active.\n\n*     `Arterial blood gas test`. In this test, your doctor tests a sample of your blood, usually taken from an artery in your wrist. The oxygen and carbon dioxide levels in the sample are then measured.\n","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Radiographic features(CT):\n\n*     [honeycombing](https://radiopaedia.org/articles/honeycombing-lungs?lang=us)\n*     [traction bronchiectasis](https://radiopaedia.org/articles/traction-bronchiectasis?lang=us)\n*     [lung architectural distortion](https://radiopaedia.org/articles/lung-architectural-distortion?lang=us)\n*     [reticulation](https://radiopaedia.org/articles/reticulation?lang=us)\n*     [interlobular septal thickening](https://radiopaedia.org/articles/interlobular-septal-thickening?lang=us): this feature is not specific for fibrosis\n\n![](https://prod-images-static.radiopaedia.org/images/5353785/8977fbdbf5f1d7ddf5cdf0d473f010_gallery.jpg)\n","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Spirometer:\n\n> Spirometry (meaning the measuring of breath) is the most common of the pulmonary function tests (PFTs). It measures lung function, specifically the amount (volume) and/or speed (flow) of air that can be inhaled and exhaled. Spirometry is helpful in assessing breathing patterns that identify conditions such as asthma, pulmonary fibrosis, cystic fibrosis, and COPD. It is also helpful as part of a system of health surveillance, in which breathing patterns are measured over time.\n> Spirometry generates pneumotachographs, which are charts that plot the volume and flow of air coming in and out of the lungs from one inhalation and one exhalation.\n\n![img](https://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Flow-volume-loop.svg/435px-Flow-volume-loop.svg.png)","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"![](https://upload.wikimedia.org/wikipedia/commons/thumb/3/39/Normal_values_for_FVC%2C_FEV1_and_FEF_25-75.png/330px-Normal_values_for_FVC%2C_FEV1_and_FEF_25-75.png)\n>Average values for forced vital capacity `(FVC)`, forced expiratory volume in 1 second `(FEV1)` and forced expiratory flow 25–75% `(FEF25–75%)`, according to a study in the United States 2007 of 3,600 subjects aged 4–80 years.[9] Y-axis is expressed in litres for FVC and FEV1, and in litres/second for FEF25–75%.","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Forced vital capacity (FVC)\n>Forced vital capacity (FVC) is the volume of air that can forcibly be blown out after full inspiration, measured in liters. FVC is the most basic maneuver in spirometry tests.","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Forced expiratory volume in 1 second (FEV1)\n>FEV1 is the volume of air that can forcibly be blown out in first 1 second, after full inspiration.[10] Average values for FEV1 in healthy people depend mainly on sex and age, according to the diagram. Values of between 80% and 120% of the average value are considered normal.[11] Predicted normal values for FEV1 can be calculated and depend on age, sex, height, mass and ethnicity as well as the research study that they are based on. ","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## FEV1/FVC ratio (FEV1%)\n\n>FEV1/FVC (FEV1%) is the ratio of FEV1 to FVC. In healthy adults this should be approximately 70–80% (declining with age).[12] In obstructive diseases (asthma, COPD, chronic bronchitis, emphysema) FEV1 is diminished because of increased airway resistance to expiratory flow; the FVC may be decreased as well, due to the premature closure of airway in expiration, just not in the same proportion as FEV1 (for instance, both FEV1 and FVC are reduced, but the former is more affected because of the increased airway resistance). This generates a reduced value (<80%, often ~45%). In restrictive diseases (such as pulmonary fibrosis) the FEV1 and FVC are both reduced proportionally and the value may be normal or even increased as a result of decreased lung compliance. ","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Forced expiratory flow (FEF)\n\n>Forced expiratory flow (FEF) is the flow (or speed) of air coming out of the lung during the middle portion of a forced expiration. It can be given at discrete times, generally defined by what fraction of the forced vital capacity (FVC) has been exhaled. The usual discrete intervals are 25%, 50% and 75% (FEF25, FEF50 and FEF75), or 25% and 50% of FVC that has been exhaled. It can also be given as a mean of the flow during an interval, also generally delimited by when specific fractions remain of FVC, usually 25–75% (FEF25–75%). Average ranges in the healthy population depend mainly on sex and age, with FEF25–75% shown in diagram at left. Values ranging from 50-60% and up to 130% of the average are considered normal.[11] Predicted normal values for FEF can be calculated and depend on age, sex, height, mass and ethnicity as well as the research study that they are based on. ","execution_count":null},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","collapsed":true,"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":false},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}