{"id":10607,"date":"2024-09-05T04:07:17","date_gmt":"2024-09-05T04:07:17","guid":{"rendered":"https:\/\/www.aihello.com\/resources\/?p=10607"},"modified":"2026-09-23T02:53:50","modified_gmt":"2026-09-23T02:53:50","slug":"a-quickstart-guide-to-using-medical-imagery-for-machine-learning","status":"publish","type":"post","link":"https:\/\/www.aihello.com\/resources\/blog\/a-quickstart-guide-to-using-medical-imagery-for-machine-learning\/","title":{"rendered":"A QuickStart Guide to Using Medical Imagery for Machine\u00a0Learning"},"content":{"rendered":"<div class=\"wp-block-group ah-reading-guide ah-compact-toc\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\"><style>\n.ah-reading-guide{max-width:820px;margin:0 auto;color:#26364a;font-size:18px;line-height:1.8;counter-reset:ah-section}.ah-reading-guide *{box-sizing:border-box}.ah-reading-guide p{margin:0 0 22px;line-height:1.8}.ah-reading-guide strong{color:#142d48}.ah-reading-guide h2{position:relative;margin:56px 0 24px;padding-top:24px;border-top:1px solid #dce7ef;font-size:29px;line-height:1.35;letter-spacing:-.4px;color:#142d48}.ah-reading-guide h2.ah-numbered{padding-left:54px;counter-increment:ah-section}.ah-reading-guide h2.ah-numbered:before{content:counter(ah-section,decimal-leading-zero);position:absolute;left:0;top:26px;display:flex;align-items:center;justify-content:center;width:38px;height:38px;background:#eaf4fc;color:#216faf;border-radius:10px;font-size:15px;font-weight:700;letter-spacing:0}.ah-reading-guide h3{position:relative;margin:34px 0 16px;font-size:23px;line-height:1.4;color:#163f65}.ah-reading-guide h4{position:relative;margin:28px 0 14px;font-size:20px;line-height:1.45;color:#163f65}.ah-reading-guide .ah-lead{margin:0 0 28px;padding:24px 28px;border-left:4px solid #2479ba;border-radius:0 12px 12px 0;background:#eef6fc;font-size:20px;line-height:1.75}.ah-reading-guide .ah-callout,.ah-reading-guide .ah-formula{margin:28px 0;padding:24px 26px;border:1px solid #d7e5f1;border-left:4px solid #2479ba;border-radius:0 12px 12px 0;background:#f5f9fd}.ah-reading-guide .ah-formula{font-size:20px;font-weight:600;font-variant-numeric:tabular-nums;line-height:1.9;overflow-wrap:anywhere}.ah-reading-guide ul,.ah-reading-guide ol{margin:24px 0 30px;padding-left:28px}.ah-reading-guide li{margin:0 0 12px;padding-left:7px;line-height:1.75}.ah-reading-guide li::marker{color:#2479ba;font-weight:700}.ah-reading-guide ol.ah-steps{list-style:none;counter-reset:ah-step;padding:0;display:grid;gap:14px}.ah-reading-guide ol.ah-steps>li{position:relative;counter-increment:ah-step;margin:0;padding:22px 24px 22px 64px;border:1px solid #dbe7f1;border-radius:12px;background:#f6fafd}.ah-reading-guide ol.ah-steps>li:before{content:counter(ah-step);position:absolute;top:23px;left:20px;display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:50%;background:#2378b9;color:white;font-size:14px;font-weight:700}.ah-reading-guide ul.ah-cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;padding:0;list-style:none}.ah-reading-guide ul.ah-cards>li{margin:0;padding:20px 22px;border:1px solid #dbe8f2;background:#f7fbfe;border-radius:12px;font-size:17px;line-height:1.7}.ah-reading-guide ul.ah-cards>li:last-child:nth-child(odd){grid-column:1\/-1}.ah-reading-guide .ah-cards>li>strong:first-child{display:block;margin-bottom:8px;color:#19598d}.ah-reading-guide .ah-step-panel{margin:22px 0;padding:24px 28px;border-left:4px solid #2479ba;border-radius:0 12px 12px 0;background:#f5f9fd}.ah-reading-guide .ah-step-panel h3{margin-top:0}.ah-reading-guide .ah-step-panel p:last-child{margin-bottom:0}.ah-reading-guide figure{max-width:100%;margin:30px 0}.ah-reading-guide figure.wp-block-image{padding:7px;border:1px solid #e0e8ef;border-radius:12px;background:white;box-shadow:0 5px 18px rgba(20,45,72,.06)}.ah-reading-guide img{max-width:100%;height:auto}.ah-reading-guide figure.wp-block-image img{display:block;border-radius:6px}.ah-reading-guide figcaption{font-size:14px;line-height:1.5;color:#587086;margin-top:10px}.ah-reading-guide figure.wp-block-table{overflow-x:auto;border:1px solid #d8e5ef;border-radius:10px}.ah-reading-guide table{width:100%;border-collapse:collapse;font-size:16px;line-height:1.6}.ah-reading-guide th,.ah-reading-guide td{padding:14px 16px;border:1px solid #d8e5ef;text-align:left;vertical-align:top}.ah-reading-guide th{background:#eaf4fc;color:#163f65;font-weight:700}.ah-reading-guide tbody tr:nth-child(even){background:#f6f9fc}.ah-reading-guide blockquote{margin:30px 0;padding:22px 26px;border-left:4px solid #2479ba;background:#f3f8fc;border-radius:0 10px 10px 0}.ah-reading-guide #ez-toc-container{width:100%;margin:32px 0 42px;padding:22px 24px;border:1px solid #cbdfee;border-top:4px solid #2479ba;border-radius:12px;background:#f7fbfe;box-shadow:none}.ah-reading-guide #ez-toc-container .ez-toc-title{margin:0;font-size:20px;font-weight:700;color:#163f65;line-height:1.5}.ah-reading-guide #ez-toc-container .ez-toc-title-container{margin-bottom:14px}.ah-reading-guide #ez-toc-container ul.ez-toc-list-level-1{display:block;column-count:2;column-gap:26px;padding:0;margin:0}.ah-reading-guide #ez-toc-container ul.ez-toc-list-level-1>li{break-inside:avoid;padding:11px 0;margin:0;border-bottom:1px solid #dce7ef;line-height:1.5;font-size:16px}.ah-reading-guide #ez-toc-container ul ul{margin:7px 0 0;padding-left:18px}.ah-reading-guide #ez-toc-container li li{padding:0;margin:5px 0;font-size:14px}.ah-reading-guide #ez-toc-container a{color:#19598d;text-decoration:none}.ah-reading-guide #ez-toc-container a:hover{text-decoration:underline}.ah-reading-guide #ez-toc-container a:focus-visible{outline:3px solid #2479ba;outline-offset:4px;border-radius:3px}.ah-reading-guide :is(h2,h3,h4)>.ez-toc-section{position:absolute;top:-100px;left:0}.ah-reading-guide :is(h2,h3,h4)>.ez-toc-section-end{position:absolute;top:0;left:0}.ah-reading-guide [id]{scroll-margin-top:100px}.ah-reading-guide .gspb_container{min-width:0}@media(max-width:700px){.ah-reading-guide{font-size:17px}.ah-reading-guide h2{font-size:25px;margin-top:44px}.ah-reading-guide h2.ah-numbered{padding-left:43px}.ah-reading-guide h2.ah-numbered:before{width:30px;height:30px;font-size:13px}.ah-reading-guide h3{font-size:21px}.ah-reading-guide ul.ah-cards{grid-template-columns:1fr}.ah-reading-guide .ah-lead,.ah-reading-guide .ah-callout,.ah-reading-guide .ah-formula,.ah-reading-guide .ah-step-panel{padding:20px}.ah-reading-guide .ah-lead,.ah-reading-guide .ah-formula{font-size:18px}.ah-reading-guide #ez-toc-container{padding:18px}.ah-reading-guide #ez-toc-container ul.ez-toc-list-level-1{column-count:1}}@media(prefers-reduced-motion:reduce){.ah-reading-guide [data-aos]{opacity:1!important;visibility:visible!important;transform:none!important;transition:none!important;animation:none!important}}\n\n.ah-reading-guide .ah-process-heading{padding-left:48px;min-height:36px}.ah-reading-guide .ah-process-heading:before{position:absolute;left:0;top:0;width:34px;height:34px;display:flex;align-items:center;justify-content:center;border-radius:9px;background:#eaf4fc;color:#216faf;font-size:15px;font-weight:700}.ah-reading-guide .ah-process-1:before{content:\"01\"}.ah-reading-guide .ah-process-2:before{content:\"02\"}.ah-reading-guide .ah-process-3:before{content:\"03\"}.ah-reading-guide .ah-process-4:before{content:\"04\"}.ah-reading-guide .ah-process-5:before{content:\"05\"}.ah-reading-guide .ah-process-6:before{content:\"06\"}.ah-reading-guide .ah-process-7:before{content:\"07\"}.ah-reading-guide .ah-process-8:before{content:\"08\"}.ah-reading-guide .ah-process-9:before{content:\"09\"}\n.ah-reading-guide .ah-definition{padding:20px 24px;margin:14px 0;border:1px solid #dbe7f1;border-radius:12px;background:#f8fbfe}.ah-reading-guide .ah-definition strong{color:#163f65}\n.ah-reading-guide .ah-long-form-list>li{margin-bottom:28px}.ah-reading-guide .ah-long-form-list>li>strong:first-child{display:block;font-size:22px;line-height:1.4;margin-bottom:16px}.ah-reading-guide .ah-long-form-list li img{display:block;margin:22px auto}.ah-reading-guide .ah-formula-comparison{font-variant-numeric:tabular-nums}\n.ah-reading-guide h5,.ah-reading-guide h6{font-size:18px;line-height:1.5;color:#163f65;margin:26px 0 14px;font-weight:700}\n.ah-reading-guide h2.ah-instruction-heading{font-size:21px;margin:24px 0 18px;padding-top:18px}.ah-reading-guide h2.ah-instruction-heading:before{top:18px}\n.ah-reading-guide ul.ah-stacked-cards{list-style:none;padding:0}.ah-reading-guide .ah-stacked-cards>li{margin:14px 0;padding:20px 24px;border:1px solid #dbe7f1;border-radius:12px;background:#f8fbfe}\n.ah-reading-guide .ah-minor-label{font-weight:700;color:#1e4e64;font-size:18px;margin:20px 0 8px;}\n.ah-reading-guide h3.ah-do,.ah-reading-guide h3.ah-dont{font-size:21px;padding:18px 22px;border-radius:0 10px 10px 0}.ah-reading-guide h3.ah-do{border-left:4px solid #20877e;background:#f0faf8}.ah-reading-guide h3.ah-dont{border-left:4px solid #ae6340;background:#fff7f0}\n.ah-reading-guide p.ah-fact-row{margin:6px 0;padding:12px 18px;background:#f4f8fc;border-left:3px solid #c7dcf0;border-radius:0 8px 8px 0;font-size:17px;line-height:1.65}.ah-reading-guide p.ah-cta a{display:inline-block;padding:12px 20px;border-radius:9px;background:#135faa;color:#fff;text-decoration:none;font-weight:700}.ah-reading-guide p.ah-cta a:hover{background:#104d89}.ah-reading-guide .ah-agency-summary td:first-child{width:38%;color:#184b75}\n.ah-reading-guide details.ah-original-index{padding:16px 20px;border:1px solid #dce7f0;border-radius:10px;margin:24px 0;background:#f8fafc}.ah-reading-guide details.ah-original-index summary{cursor:pointer;font-size:18px;font-weight:700;color:#244f74}.ah-reading-guide details.ah-original-index>ol{margin-top:18px}\n.ah-reading-guide ul.ah-cycle-cards{grid-template-columns:repeat(3,minmax(0,1fr));gap:22px}.ah-reading-guide ul.ah-cycle-cards>li{position:relative;text-align:center;display:flex;align-items:center;justify-content:center;min-height:110px;font-weight:700;color:#20567d}.ah-reading-guide ul.ah-cycle-cards>li:last-child:nth-child(odd){grid-column:auto}.ah-reading-guide ul.ah-cycle-cards>li:not(:last-child)::after{content:\"\u203a\";position:absolute;right:-19px;top:50%;transform:translateY(-50%);font-size:28px;color:#3785b4}@media(max-width:700px){.ah-reading-guide ul.ah-cycle-cards{grid-template-columns:1fr}.ah-reading-guide ul.ah-cycle-cards>li:not(:last-child)::after{right:50%;top:auto;bottom:-25px;transform:rotate(90deg)}}\n.ah-reading-guide .ah-process-10::before{content:\"10\"}\n.ah-reading-guide pre.wp-block-code{background:#122238;color:#eff6ff;border:1px solid #29415f;border-radius:12px;padding:22px 24px;margin:24px 0;overflow-x:auto;font-size:15px;line-height:1.7;white-space:pre;tab-size:4}.ah-reading-guide pre.wp-block-code code{background:transparent;color:inherit;padding:0;white-space:pre;font-family:Consolas,Monaco,monospace}.ah-reading-guide p code{background:#edf3fa;color:#204d78;border-radius:4px;padding:2px 5px}\n.ah-reading-guide ol.ah-steps.ah-start-2{counter-reset:ah-step 1}\n.ah-reading-guide ol.ah-steps.ah-start-3{counter-reset:ah-step 2}\n.ah-reading-guide ol.ah-steps.ah-start-4{counter-reset:ah-step 3}\n.ah-reading-guide ol.ah-steps.ah-start-5{counter-reset:ah-step 4}\n.ah-reading-guide ol.ah-steps.ah-start-6{counter-reset:ah-step 5}\n.ah-reading-guide ol.ah-steps.ah-start-7{counter-reset:ah-step 6}\n.ah-reading-guide ol.ah-steps.ah-start-8{counter-reset:ah-step 7}\n.ah-reading-guide ol.ah-steps.ah-start-9{counter-reset:ah-step 8}\n.ah-reading-guide ol.ah-steps.ah-start-10{counter-reset:ah-step 9}\n.ah-reading-guide ol.ah-steps.ah-start-11{counter-reset:ah-step 10}\n.ah-reading-guide ol.ah-steps.ah-start-12{counter-reset:ah-step 11}\n.ah-reading-guide #ez-toc-container nav{max-height:460px;overflow-y:auto;padding-right:8px}.ah-reading-guide figure.ah-comparison-wide{max-height:650px;overflow:auto;border:1px solid #dae4ee;border-radius:12px}.ah-reading-guide .ah-comparison-wide table{min-width:760px;font-size:15px}.ah-reading-guide .ah-comparison-wide thead th{position:sticky;top:0;background:#183f65;color:#fff;z-index:1}.ah-reading-guide figure.ah-agency-summary tbody th{width:30%;background:#edf4fa;color:#244764;font-weight:700}\n.ah-reading-guide #ez-toc-container a.ez-toc-link::before{content:none!important;display:none!important}\n.ah-reading-guide .ah-comparison-wide thead th,.ah-reading-guide .ah-comparison-wide thead th *{color:#fff!important}\n.ah-reading-guide .ah-equation{display:block;margin:16px 0;padding:16px 20px;border-left:4px solid #2378b9;background:#edf4fa;border-radius:8px;font-size:20px;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}\n.ah-reading-guide .ah-feature-comparison thead th:nth-child(1){width:18%}.ah-reading-guide .ah-feature-comparison thead th:nth-child(2){width:12%;white-space:nowrap}.ah-reading-guide .ah-feature-comparison thead th:nth-child(3){width:48%}.ah-reading-guide .ah-feature-comparison thead th:nth-child(4){width:22%}\n.ah-reading-guide.ah-compact-toc #ez-toc-container ul.ez-toc-list>li>ul>li>ul{display:none}.ah-reading-guide h4.ah-do{color:#276044!important}.ah-reading-guide h4.ah-dont{color:#855218!important}.ah-reading-guide p.ah-tool-bullet{margin:.45em 0!important;padding:.6em 1em;border-radius:8px;background:#f4f7fa;line-height:1.65}\n.ah-reading-guide .ah-glossary-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px;margin:30px 0}.ah-reading-guide .ah-glossary-entry{background:#f7f9fc;border:1px solid #dce5ef;border-radius:12px;padding:22px;height:100%;box-sizing:border-box}.ah-reading-guide .ah-glossary-entry h2{font-size:21px!important;margin:0 0 14px!important;line-height:1.4!important;border:0;padding:0}.ah-reading-guide .ah-glossary-entry p{font-size:16px!important;line-height:1.7!important;margin:0!important}@media(max-width:650px){.ah-reading-guide .ah-glossary-grid{grid-template-columns:1fr}}\n.ah-reading-guide .ah-glossary-grid{display:block}.ah-reading-guide .ah-glossary-grid>.wp-block-group__inner-container{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px;align-items:stretch}.ah-reading-guide .ah-glossary-entry{height:auto!important;margin:0!important;min-width:0}.ah-reading-guide .ah-glossary-grid>.wp-block-group__inner-container>.wp-block-greenshift-blocks-container{display:flex;min-width:0}.ah-reading-guide .ah-glossary-grid>.wp-block-group__inner-container>.wp-block-greenshift-blocks-container>.ah-glossary-entry{flex:1}@media(max-width:650px){.ah-reading-guide .ah-glossary-grid>.wp-block-group__inner-container{grid-template-columns:1fr}}\n.ah-reading-guide ol.ah-steps.ah-feature-grid{grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:700px){.ah-reading-guide ol.ah-steps.ah-feature-grid{grid-template-columns:1fr}}\n.ah-reading-guide pre.wp-block-preformatted{background:#122238;color:#eff6ff;border:1px solid #29415f;border-radius:12px;padding:22px 24px;margin:24px 0;overflow-x:auto;font-size:15px;line-height:1.7;white-space:pre;tab-size:4;font-family:Consolas,Monaco,monospace}.ah-reading-guide pre.wp-block-preformatted code{background:transparent;color:inherit;padding:0;white-space:pre;font:inherit}.ah-reading-guide .ah-output-sample{max-height:360px;overflow:auto;padding:24px;border:1px solid #d7e5f1;border-radius:12px;background:#f5f9fd;font-size:16px;line-height:1.8}\n.ah-reading-guide pre.wp-block-preformatted,.ah-reading-guide pre.wp-block-preformatted code{white-space:pre!important;text-align:left!important}.ah-reading-guide pre br{display:initial!important}.ah-reading-guide pre.ah-code-long{max-height:620px;overflow:auto;white-space:pre!important;text-align:left!important}<\/style><noscript><style>.ah-reading-guide [data-aos]{opacity:1!important;visibility:visible!important;transform:none!important}<\/style><\/noscript><p class=\"ah-lead wp-block-paragraph\">Automating an extremely important sector like Health Care with the power of <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2020\/04\/5770b06cdf39b-300x140.jpeg\"  data-excerpt=\"AiHello: Your AI e-commerce solution to automate Amazon &amp; eBay sales. Leverage machine learning for smart pricing, optimized keywords, and accurate sales forecasts.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/welcome\/\">Machine Learning<\/a> can bring a very great and positive impact to the world.<\/p><p class=\"wp-block-paragraph\">In this article, let <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2022\/06\/selling-on-amazon-mexico-300x225.jpg\"  data-excerpt=\"Mexico&#039;s eCommerce boom presents huge opportunities for Amazon sellers. This guide explores the thriving Mexican online market, Amazon.mx&#039;s growth, and key considerations for successfully selling your products to millions of Mexican consumers. Learn how to navigate logistics, expand your reach, and capitalize on this expanding market.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/how-to-launch-an-amazon-mexico-business\/\">us<\/a> study how medical datasets work, how we can pre-process them and get them ready for machine learning models as well as explore some models and techniques that are known to work very well with such data.<\/p><figure class=\"wp-block-image size-large\"><img decoding=\"async\" title=\"how to calculate fba fulfillment fees | how can i earn money from amazon | can you make money selling books on amazon\" src=\"https:\/\/i.ibb.co\/mG5gYxg\/1-k-UNT34-OLvi7pb-Y0u-KKntw.jpg\" \/><\/figure><h2 id=\"basic-terms-dataset-overview\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Basic_Terms_Dataset_Overview\"><\/span>Basic Terms &amp; Dataset&nbsp;Overview<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"ah-definition wp-block-paragraph\">Medical imagery such as that of captured by a CT\/MRI is capable of providing us the full 3D structure of the body part by combining all the 2D images or \u2018<strong>slices<\/strong>\u2019 given to us as output by them. Usually in medical datasets provided to us, we are given a bunch of the same slices to work on in special image formats.<\/p><p class=\"wp-block-paragraph\">Two more of the most basic terms one must know-<\/p><div class=\"wp-block-greenshift-blocks-container gspb_container gspb_container-gsbp-f10607-1\" id=\"gspb_container-id-gsbp-f10607-1\" data-aos=\"fade\" data-aos-easing=\"ease\" data-aos-duration=\"500\" data-aos-once=\"true\"><ul class=\"wp-block-list ah-cards\"><li><strong>Study ID<\/strong>: A unique identifier for the procedure done on each patient or subject. Each study ID might have multiple series and series IDs associated to it.<\/li><li><strong>Series ID: <\/strong>Subsets of images within a study ID, so that images can be organised further based on some common properties [e.g. a common plane\/view used (explained below)].<\/li><\/ul><\/div><h3 id=\"planes-views-used\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"PlanesViews_Used\"><\/span>Planes\/Views Used<span class=\"ez-toc-section-end\"><\/span><\/h3><p class=\"wp-block-paragraph\">These 2D slices can be acquired along three primary anatomical planes:<\/p><div class=\"wp-block-greenshift-blocks-container gspb_container gspb_container-gsbp-f10607-2\" id=\"gspb_container-id-gsbp-f10607-2\" data-aos=\"fade\" data-aos-easing=\"ease\" data-aos-duration=\"500\" data-aos-once=\"true\"><ul class=\"wp-block-list ah-cards\"><li><strong>Axial<\/strong> (top to bottom)<\/li><li><strong>Sagittal <\/strong>(left to right)<\/li><li><strong>Coronal <\/strong>(front to back)<\/li><\/ul><\/div><p class=\"wp-block-paragraph\">and hence, they would also need to be stacked differently in their respective plane to form the 3D image.<\/p><figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" title=\"how to sell products on amazon | are amazon lightning deals worth it | how to rename ad group in amazon ppc advertising&apos;\" src=\"https:\/\/i.ibb.co\/QYrsCk3\/1-y-V8u-H3idwu-IAYKUPK3v-YA.png\" style=\"width:432px;height:auto\" \/><\/figure><h3 id=\"contrast-mechanisms\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Contrast_Mechanisms\"><\/span>Contrast Mechanisms<span class=\"ez-toc-section-end\"><\/span><\/h3><p>Medical scanners can adjust how different parts of the body appear in images by changing their brightness intensity or contrast to make certain areas stand out. These mechanisms that decide which parts would be darker and which ones would be lighter are standardised and also given names (e.g. in in MR scans, we have <strong>T1<\/strong>-weighted images where bones appear lighter along with <strong>T2<\/strong>-weighted images where bones appear darker).<\/p><figure class=\"wp-block-image size-large\"><img decoding=\"async\" title=\"how increase sales on amazon | how to list products internationally | how to find ranking on amazon\" src=\"https:\/\/i.ibb.co\/Y7Y4gqH\/1-Ko-MJW-3y-AS9-Vv-HR-0aabdw.png\" alt=\"\" \/><\/figure><h4 id=\"file-formats\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"File_Formats\"><\/span>File Formats<span class=\"ez-toc-section-end\"><\/span><\/h4><p class=\"wp-block-paragraph\">There are various special image formats that are need to be dealt with while working with such a data, like-<\/p><h3 id=\"dicom\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"DICOM\"><\/span><strong>DICOM<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3><p class=\"ah-definition wp-block-paragraph\">DICOM stands for Digital Imaging and Communications in Medicine. It\u2019s a crucial standard in medical imaging and uses \u2018<strong>.dcm<\/strong>\u2019 as its extension. This format also has a bunch of metadata attached to it telling about the patient, scanner used, plane of the image, scanning mechanism used etc.&nbsp;<\/p><p class=\"ah-step-panel wp-block-paragraph\">A Python library called \u2018<strong>PyDICOM<\/strong>\u2019 is used to perform operations with these files. Let us try to use it to read a DICOM and access its metadata-<\/p><pre class=\"wp-block-code\"><code>import pydicom# Read DICOM filedcm = pydicom.dcmread(\"sample_dicom.dcm\")# Access metadataprint(f\"Patient Name: {dcm.PatientName}\")print(f\"Modality: {dcm.Modality}\")<\/code><\/pre><p class=\"ah-step-panel wp-block-paragraph\">We can also convert the DICOM to a PNG\/JPG to view it easily-<\/p><pre class=\"wp-block-code ah-code-long\"><code>import pydicomimport numpy as npfrom PIL import Imagedef dicom_to_image(dicom_file, output_file):    # Read the DICOM file    dicom = pydicom.dcmread(dicom_file)        # Get pixel array    pixel_array = dicom.pixel_array        # Rescale pixel values to 0-255    pixel_array = pixel_array - np.min(pixel_array)    pixel_array = pixel_array \/ np.max(pixel_array)    pixel_array = (pixel_array * 255).astype(np.uint8)        # Create PIL Image    image = Image.fromarray(pixel_array)        # Save as PNG or JPG    image.save(output_file)    print(f\"Image saved as {output_file}\")# Usagedicom_file = \"sample_dicom.dcm\"output_file = \"output_image.png\"  # or \"output_image.jpg\" for JPGdicom_to_image(dicom_file, output_file)<\/code><\/pre><h3 id=\"nifti\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"NifTI\"><\/span><strong>NifTI<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3><p>The NifTI (Neuroimaging Informatics Technology Initiative) file format is a standard way of storing brain imaging data. It was created to make it easier for researchers and doctors to share and analyze brain scans. Although, now it is commonly used for other scans as well. The extension that this format uses is \u2018<strong>.nii<\/strong>\u2019 or also \u2018<strong>.nii.gz<\/strong>\u2019 when it\u2019s compressed.<\/p><p class=\"wp-block-paragraph\">It is also a common practice to convert your 2D DICOM slices into a single 3D NifTI file. This file can then be viewed using specialised softwares for this domain.<\/p><p class=\"ah-step-panel wp-block-paragraph\">The Python library \u2018<strong>Nibabel\u2019<\/strong> is used to deal with this format, let\u2019s try to use it-<\/p><pre class=\"wp-block-code\"><code>import nibabel as nib# Load NIfTI fileimg = nib.load('sample_nifti.nii')# Get image data as numpy arraydata = img.get_fdata()# Access header informationprint(f\"Image shape: {img.shape}\")print(f\"Data type: {img.get_data_dtype()}\")# Get affine transformation matrixaffine = img.affineprint(f\"Affine matrix:\\n{affine}\")<\/code><\/pre><p class=\"ah-step-panel wp-block-paragraph\">Let\u2019s also try to convert DICOM files of the same series into a NifTI file so we can visualise it later using a software-<\/p><pre class=\"wp-block-code ah-code-long\"><code>import osimport pydicomimport nibabel as nibimport numpy as npfrom collections import defaultdictdef dicom_series_to_nifti(dicom_folder, output_file):    # Read all DICOM files in the folder    dicom_files = &#091;pydicom.dcmread(os.path.join(dicom_folder, f))                    for f in os.listdir(dicom_folder)                    if f.endswith('.dcm')]        # Sort files by Instance Number    dicom_files.sort(key=lambda x: int(x.InstanceNumber))        # Extract pixel data and create 3D volume    pixel_arrays = &#091;dcm.pixel_array for dcm in dicom_files]    volume = np.stack(pixel_arrays, axis=-1)        # Get affine matrix    first_slice = dicom_files&#091;0]    pixel_spacing = first_slice.PixelSpacing    slice_thickness = first_slice.SliceThickness    image_position = first_slice.ImagePositionPatient        affine = np.eye(4)    affine&#091;0, 0] = pixel_spacing&#091;0]    affine&#091;1, 1] = pixel_spacing&#091;1]    affine&#091;2, 2] = slice_thickness    affine&#091;:3, 3] = image_position        # Create NIfTI image and save    nifti_image = nib.Nifti1Image(volume, affine)    nib.save(nifti_image, output_file)# Usagedicom_folder = 'dicom_series_folder'output_file = 'output.nii.gz'dicom_series_to_nifti(dicom_folder, output_file)<\/code><\/pre><p class=\"wp-block-paragraph\">These are the 2 most popular format but other than them, many more such as <strong>MetaImage Header Archive (.mha)<\/strong> are also in use.<\/p><h4 id=\"visualisation-softwares\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Visualisation_Softwares\"><\/span>Visualisation Softwares<span class=\"ez-toc-section-end\"><\/span><\/h4><p class=\"wp-block-paragraph\">There are various special softwares that exist specially to deal with medical imagery\u200a\u2014\u200abe it simply viewing them, segmenting them or analysing them.<\/p><p class=\"wp-block-paragraph\">Some popular softwares include-<\/p><div class=\"wp-block-greenshift-blocks-container gspb_container gspb_container-gsbp-f10607-3\" id=\"gspb_container-id-gsbp-f10607-3\" data-aos=\"fade\" data-aos-easing=\"ease\" data-aos-duration=\"500\" data-aos-once=\"true\"><ul class=\"wp-block-list ah-cards\"><li><strong>ITK-SNAP<\/strong>: A platform to create segment structures for 3D medical images<\/li><li><strong>3D Slicer<\/strong>: An open-source platform for medical image informatics, image processing, and three-dimensional visualization<\/li><li><strong>OsiriX<\/strong>: A DICOM viewer for medical imaging, popular among radiologists<\/li><\/ul><\/div><h2 id=\"popular-tools-models-and-techniques\" class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Popular_Tools_Models_and_Techniques\"><\/span>Popular Tools, Models and Techniques<span class=\"ez-toc-section-end\"><\/span><\/h2><h3 id=\"study-level-cropping\" class=\"wp-block-heading ah-process-heading ah-process-1\"><span class=\"ez-toc-section\" id=\"Study-Level_Cropping\"><\/span>Study-Level Cropping<span class=\"ez-toc-section-end\"><\/span><\/h3><p class=\"wp-block-paragraph\">One of the most important things while training a model using medical data is to understand the exact problem\/disease\/condition we are dealing with and read up about it. Many times only a certain region-of-interest is of use to us within the scans that we have due to the nature of the problem.<\/p><p class=\"ah-definition wp-block-paragraph\">The crops of these region-of-interests from base scans are called study-level crops. A model works much better if trained on these correct crops instead of the full scan.<\/p><p class=\"wp-block-paragraph\">Mostly, automating this process of study-level-cropping over an entire dataset requires training a <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2023\/08\/how-to-reduce-acos-on-amazon-the-ultimate-guide-300x169.jpg\"  data-excerpt=\"Amazon PPC costs soaring? Learn expert strategies to reduce your ACoS. Discover prioritization, segmentation, dayparting, and ad analysis tips.\" href=\"https:\/\/www.aihello.com\/resources\/blog\/lower-acos-amazon\/\">segmentation<\/a> model which can segment out parts-of-interest from the scans from which we can map out the bounding box that we need.<\/p><h3 id=\"totalsegmentator\" class=\"wp-block-heading ah-process-heading ah-process-2\"><span class=\"ez-toc-section\" id=\"TotalSegmentator\"><\/span>TotalSegmentator<span class=\"ez-toc-section-end\"><\/span><\/h3><p class=\"ah-definition wp-block-paragraph\">TotalSegmentator is a <a  data-ilj-link-preview=\"true\"  data-featured-image=\"https:\/\/www.aihello.com\/resources\/wp-content\/uploads\/2022\/06\/amazon-brand-analytics-guide-300x200.jpg\"  data-excerpt=\"Master Amazon sales! Discover how Amazon Brand Analytics empowers sellers to stand out, optimize products,\" href=\"https:\/\/www.aihello.com\/resources\/blog\/amazon-brand-analytics-a-complete-guide-2026\/\">tool<\/a> also available as a Python library based on a nnU-Net which is trained on a bunch of medical data that allows users to segment all major body parts in CT scans and now\u200a\u2014\u200aMRI scans automatically with just a call.<\/p><p class=\"wp-block-paragraph\">It has various modes that can be used, its default modes are capable to segment all the parts but other than them, it has specialized ones for different categories of parts as well. Let\u2019s try to use to it to segment out a few DICOM MRI axial slices of lumbar spine that we have-<\/p><pre class=\"wp-block-code ah-code-long\"><code>import osimport numpy as npimport nibabel as nibimport SimpleITK as sitkimport matplotlib.pyplot as pltfrom totalsegmentator.python_api import totalsegmentatordef convert_dicom_to_nifti(dicom_directory, nifti_output_path):    \"\"\"    Convert DICOM series to NIfTI format.        Args:    dicom_directory (str): Path to the directory containing DICOM files.    nifti_output_path (str): Path where the NIfTI file will be saved.    \"\"\"    reader = sitk.ImageSeriesReader()    series_ids = reader.GetGDCMSeriesIDs(dicom_directory)        if not series_ids:        raise ValueError(\"No DICOM series found in the specified directory.\")        dicom_files = reader.GetGDCMSeriesFileNames(dicom_directory, series_ids&#091;0])    reader.SetFileNames(dicom_files)    image = reader.Execute()        sitk.WriteImage(image, nifti_output_path)    print(f\"Converted DICOM to NIfTI: {nifti_output_path}\")def segment_and_visualize(nifti_file, segmentation_output_dir, visualization_output_dir):    \"\"\"    Perform segmentation on a NIfTI file and visualize the results.        Args:    nifti_file (str): Path to the input NIfTI file.    segmentation_output_dir (str): Directory to store segmentation results.    visualization_output_dir (str): Directory to store visualization images.    \"\"\"    # Perform segmentation    totalsegmentator(nifti_file, segmentation_output_dir, task=\"total_mr\", verbose=True)        # Create visualization directory    os.makedirs(visualization_output_dir, exist_ok=True)        # Visualize original slices    visualize_slices(nifti_file,                      output_path=os.path.join(visualization_output_dir, \"original_slices.png\"))        # Visualize vertebrae segmentation    vertebrae_segmentation = os.path.join(segmentation_output_dir, \"vertebrae.nii.gz\")    visualize_slices(nifti_file,                      segmentation_path=vertebrae_segmentation,                     output_path=os.path.join(visualization_output_dir, \"vertebrae_segmentation.png\"))def visualize_slices(image_path, segmentation_path=None, output_path=None, num_slices=9):    \"\"\"    Visualize multiple slices of a 3D image with optional segmentation overlay.        Args:    image_path (str): Path to the NIfTI image file.    segmentation_path (str, optional): Path to the segmentation NIfTI file.    output_path (str, optional): Path to save the visualization.    num_slices (int): Number of slices to visualize.    \"\"\"    image_data = nib.load(image_path).get_fdata()        if segmentation_path:        segmentation_data = nib.load(segmentation_path).get_fdata()        total_slices = image_data.shape&#091;2]    slice_indices = np.linspace(0, total_slices-1, num_slices, dtype=int)        fig, axes = plt.subplots(3, 3, figsize=(15, 15))    for i, ax in enumerate(axes.flat):        if i &lt; num_slices:            slice_num = slice_indices&#091;i]            ax.imshow(image_data&#091;:, :, slice_num].T, cmap='gray')            if segmentation_path:                ax.imshow(segmentation_data&#091;:, :, slice_num].T, alpha=0.5, cmap='jet')            ax.set_title(f'Slice {slice_num}')            ax.axis('off')        plt.tight_layout()        if output_path:        plt.savefig(output_path)        plt.close(fig)        print(f\"Saved visualization to {output_path}\")    else:        plt.show()# Main executionif __name__ == \"__main__\":    # Define paths    dicom_directory = \"sample_dicom_slices_folder\"    nifti_file = \"mri_scan.nii.gz\"    segmentation_output_dir = \"segmentation_results\"    visualization_output_dir = \"visualizations\"    # Convert DICOM to NIfTI    convert_dicom_to_nifti(dicom_directory, nifti_file)    # Perform segmentation and visualization    segment_and_visualize(nifti_file, segmentation_output_dir, visualization_output_dir)<\/code><\/pre><p class=\"wp-block-paragraph\">Let us see the original slices as well as the segmented slices-<\/p><div class=\"wp-block-greenshift-blocks-container gspb_container gspb_container-gsbp-f10607-4\" id=\"gspb_container-id-gsbp-f10607-4\" data-aos=\"fade\" data-aos-easing=\"ease\" data-aos-duration=\"500\" data-aos-once=\"true\"><figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" title=\"how to report fake amazon reviews | what is a+ content | is amazon advertising worth it\" src=\"https:\/\/i.ibb.co\/H7PKLMW\/original-slices.png\" alt=\"\" style=\"width:650px;height:auto\" \/><figcaption class=\"wp-element-caption\">Original slices<\/figcaption><\/figure><\/div><figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" title=\"how to sell books through amazon | what strategies do top companies use to rival amazon | does amazon divide ppc budget between keywords based on search volume\" src=\"https:\/\/i.ibb.co\/7X4khqQ\/vertebrae-multiple-slices.png\" alt=\"\" style=\"width:655px;height:auto\" \/><figcaption class=\"wp-element-caption\">Segmented slices from TotalSegmentator<\/figcaption><\/figure><h3 id=\"maxvit-unet\" class=\"wp-block-heading ah-process-heading ah-process-3\"><span class=\"ez-toc-section\" id=\"MaxViT-UNet\"><\/span>MaxViT-UNet<span class=\"ez-toc-section-end\"><\/span><\/h3><p class=\"ah-definition wp-block-paragraph\">This is an architecture that uses MaxViT (Multi-Axis Vision Transformer) as its backbone which is a model that combines features of both a ViT as well as a convolution model. Along with this, the UNet part allows for precise localization mechanisms\u200a\u2014\u200amaking it good for medical segmentation.<\/p><p class=\"wp-block-paragraph\">This research paper titled \u2018<a href=\"https:\/\/arxiv.org\/abs\/2305.08396\" rel=\"noreferrer noopener\" target=\"_blank\">MaxViT-UNet: Multi-Axis Attention for Medical Image Segmentation<\/a>\u2019 also shows its prowess in the task.<\/p><figure class=\"wp-block-image size-large\"><img decoding=\"async\" title=\"how to sell on amazon australia | how to sell amazon prime | how to run google ads for amazon products\" src=\"https:\/\/i.ibb.co\/NxSBbj8\/1-Hsf-X3-Jn-X3-Dp-Ms-Nv-Ns-Df-Wtg.png\" alt=\"\" \/><\/figure><h3 id=\"2-5d-cnn\" class=\"wp-block-heading ah-process-heading ah-process-4\"><span class=\"ez-toc-section\" id=\"25D_CNN\"><\/span>2.5D CNN<span class=\"ez-toc-section-end\"><\/span><\/h3><p class=\"wp-block-paragraph\">This architecture bridges the gap between 2D and 3D but there\u2019s actually nothing \u20182.5D\u2019 about the model itself.<\/p><p class=\"wp-block-paragraph\">What\u2019s 2.5D is the data that we input into it \u2013 a common practice is to stack adjacent slices or select \u2018n\u2019 number of equivalent slices from a series and stack them together to give depth to the data and hence, also making it 3D without it actually being 3D.<\/p><p class=\"wp-block-paragraph\">In case, we are using study-level crops to create a 2.5D image, we can even stack a segmentation mask of the actual part-of-interest on it in case the crops are also capturing noise, this can make the model even better.<\/p><figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" title=\"what is a good click through rate on amazon | how to improve click-through rate amazon | how to list products internationally\" src=\"https:\/\/i.ibb.co\/cC7hXfk\/1-LDsn-W7-ATyo-MZB4bt-Lnk-Cs-Q.jpg\" alt=\"\" style=\"width:884px;height:auto\" \/><\/figure><h3 id=\"multi-view-cnn\" class=\"wp-block-heading ah-process-heading ah-process-5\"><span class=\"ez-toc-section\" id=\"Multi-View_CNN\"><\/span><strong>Multi-View CNN<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3><p class=\"ah-definition wp-block-paragraph\">If our data provides us with different views, then we can use all of them through a Multi-View CNN or MVCNN which allows for different input streams. All the input streams process the different views seperately, hence capturing all of their information efficiently.<\/p><p>Once the data has gone through the different streams, the information is combined or fused. For the fusion process, we have a lot of options that we can consider\u200a\u2014\u200aall of them having different strength and weaknesses (e.g. if the different views have some sort of sequence that we\u2019d like to capture, we can use a LSTM or GRU layer, otherwise we can also use a simple concat function).<\/p><figure class=\"wp-block-image size-large\"><img decoding=\"async\" title=\"what is pdp on amazon | what is a good sales conversion rate on amazon | how to use advertising reports in amazon to improve\" src=\"https:\/\/i.ibb.co\/pz7YNHK\/1-i-Nm8apuo-Agdwouv-KXGY-d-A.png\" alt=\"\" \/><\/figure><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Transform healthcare with ML! Dive into medical datasets, from CT\/MRI basics and file formats (DICOM, NifTI) to preprocessing for robust AI model training.<\/p>\n","protected":false},"author":30,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_gspb_post_css":".gspb_container-id-gsbp-f10607-1,.gspb_container-id-gsbp-f10607-2,.gspb_container-id-gsbp-f10607-3,.gspb_container-id-gsbp-f10607-4{flex-direction:column;box-sizing:border-box}#gspb_container-id-gsbp-f10607-1.gspb_container>p:last-of-type,#gspb_container-id-gsbp-f10607-2.gspb_container>p:last-of-type,#gspb_container-id-gsbp-f10607-3.gspb_container>p:last-of-type,#gspb_container-id-gsbp-f10607-4.gspb_container>p:last-of-type{margin-bottom:0}#gspb_container-id-gsbp-f10607-1.gspb_container.aos-animate,#gspb_container-id-gsbp-f10607-1.gspb_container[data-gs-aos],#gspb_container-id-gsbp-f10607-2.gspb_container.aos-animate,#gspb_container-id-gsbp-f10607-2.gspb_container[data-gs-aos],#gspb_container-id-gsbp-f10607-3.gspb_container.aos-animate,#gspb_container-id-gsbp-f10607-3.gspb_container[data-gs-aos],#gspb_container-id-gsbp-f10607-4.gspb_container.aos-animate,#gspb_container-id-gsbp-f10607-4.gspb_container[data-gs-aos]{opacity:1;transform:translateZ(0)}#gspb_container-id-gsbp-f10607-1.gspb_container,#gspb_container-id-gsbp-f10607-2.gspb_container,#gspb_container-id-gsbp-f10607-3.gspb_container,#gspb_container-id-gsbp-f10607-4.gspb_container{position:relative;transition-duration:.5s;transition-timing-function:var(--gs-root-animation-easing, cubic-bezier(0.42, 0, 0.58, 1));opacity:var(--gs-root-animation-opacity, 0);transition-property:opacity,transform,filter;box-sizing:border-box}","footnotes":""},"categories":[103,86,182,85],"tags":[178,1227,1228],"republish_tag":[],"class_list":["post-10607","post","type-post","status-publish","format-standard","hentry","category-machine-learning","category-product-marketing","category-product-updates","category-tips","tag-machine-learning","tag-ml","tag-ml-2026"],"_links":{"self":[{"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/posts\/10607","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/users\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/comments?post=10607"}],"version-history":[{"count":2,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/posts\/10607\/revisions"}],"predecessor-version":[{"id":14258,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/posts\/10607\/revisions\/14258"}],"wp:attachment":[{"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/media?parent=10607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/categories?post=10607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/tags?post=10607"},{"taxonomy":"republish_tag","embeddable":true,"href":"https:\/\/www.aihello.com\/resources\/wp-json\/wp\/v2\/republish_tag?post=10607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}