DEV Community

Cover image for Using Artificial Intelligence in Medical Imaging: A First Step Tutorial with Python Code Examples
Francisco Maria Calisto
Francisco Maria Calisto

Posted on

Using Artificial Intelligence in Medical Imaging: A First Step Tutorial with Python Code Examples

Artificial intelligence (AI) has made significant strides in the field of medical imaging, allowing doctors and other medical professionals to better diagnose and treat their patients. One key area where AI has been particularly effective is in the detection and diagnosis of diseases and conditions such as cancer and heart disease. AI algorithms are able to analyze medical images, such as X-rays, MRIs, and CT scans, and identify patterns and abnormalities that may indicate the presence of a particular condition. This can be done much more quickly and accurately than by a human alone [1, 2, 3], allowing doctors to make more informed decisions about their patients' care.

In addition to improving diagnostic accuracy, AI in medical imaging can also help reduce the workload of medical professionals. By automating some of the more routine tasks involved in analyzing medical images, doctors, and other healthcare workers can focus on more important aspects of patient care. Another essential area between both AI and medical imaging fields is Human-Computer Interaction (HCI) to study how we can achieve higher interpretability of the AI outcomes. HCI is a field of study that focuses on how humans interact with computers and other technology. It is a significant aspect of the development of AI systems for medical imaging, as it helps ensure that these systems are easy to use and understand by medical professionals. By designing AI systems with intuitive interfaces and clear instructions, developers can ensure that medical professionals are able to use them effectively and efficiently during their medical practice.

Tutorial

In this tutorial, we will explore how to use AI in medical imaging. By leveraging the power of AI algorithms, medical professionals can improve the accuracy and efficiency of their work. In this article, we will provide Python code examples that show how to use AI algorithms to analyze medical images and make more informed decisions about patient care. We will also discuss the importance of HCI in the development of AI systems for medical imaging.

The code uses the pydicom library to read a DICOM image from a file. DICOM (Digital Imaging and Communications in Medicine) is the standard format for storing and transmitting medical images. It is commonly used in hospitals and other healthcare settings.

The first step in the code is to import the pydicom library:

import pydicom
Enter fullscreen mode Exit fullscreen mode

Next, we use the dcmread() function from the pydicom library to read the DICOM image from a file:

image = pydicom.dcmread('medical_image.dcm')
Enter fullscreen mode Exit fullscreen mode

The dcmread() function takes the file path of the DICOM image as an argument, and returns the image data as a Dataset object. The Dataset object contains the pixel data for the image, as well as metadata about the image, such as its dimensions, resolution, and other information.

Once we have read the DICOM image, we can pass it to the AI algorithm for analysis:

results = AI_algorithm.analyze(image)
Enter fullscreen mode Exit fullscreen mode

The AI algorithm will use its pre-trained model to analyze the image and identify any patterns or abnormalities that may be present. The results of the analysis are returned as a Result object, which contains the findings of the algorithm.

Finally, we print the results of the analysis to the console:

print(results)
Enter fullscreen mode Exit fullscreen mode

This code provides a simple example of how to use an AI algorithm to analyze a DICOM image. In a real-world application, the results of the analysis would be used by medical professionals to make decisions about the patient's care.

Here is the final revised version of the code that uses the pydicom library to read a DICOM image:

import pydicom

# Load the DICOM image
image = pydicom.dcmread('medical_image.dcm')

# Use the AI algorithm to analyze the image
results = AI_algorithm.analyze(image)

# Print the results
print(results)
Enter fullscreen mode Exit fullscreen mode

Acknowledgments

This post is supported by the case studies of MIMBCD-UI, MIDA, and BreastScreening projects at IST from ULisboa. The three projects are strongly sponsored by FCT, a Portuguese public agency that promotes science, technology, and innovation, in all scientific domains. The genesis of this post was a research work between ISR-Lisboa and ITI, both associated laboratories of LARSyS. From these institutions, I would like to convey a special thanks to Professor Jacinto C. Nascimento and Professor Nuno Nunes for advising me during my research work.

Supporters

Our organization is a non-profit organization. However, we have many expenses across our activity. From infrastructure to service expenses, we need some money, as well as help, to support our team and projects. For the expenses, we created several channels that will mitigate this problem. Firstly, you can support us by being one of our Patreons. Second, you can support us on the Open Collective page. Thirdly, you can buy one coffee (or more) for us. Fourth, you can also support us on our Liberapay page. Last but not least, you can directly support us on PayPal. On the other hand, we also need help in the development of our projects. Therefore, if you have the knowledge we welcome you to support our projects (e.g., GitHub). Just follow our channels and repositories.

Social

We are on the top social media networks. The links are as follows. Also, you can chat with us. Just follow us to know about our work and news.

List of our social media networks and chats channels:

Facebook | Twitter | LinkedIn | Gitter | YouTube

References

[1] Francisco Maria Calisto, Nuno Nunes, Jacinto C. Nascimento, Modeling adoption of intelligent agents in medical imaging, International Journal of Human-Computer Studies, Volume 168, 2022, 102922, ISSN 1071-5819, https://doi.org/10.1016/j.ijhcs.2022.102922

[2] Francisco Maria Calisto, Carlos Santiago, Nuno Nunes, Jacinto C. Nascimento, BreastScreening-AI: Evaluating medical intelligent agents for human-AI interactions, Artificial Intelligence in Medicine, Volume 127, 2022, 102285, ISSN 0933-3657, https://doi.org/10.1016/j.artmed.2022.102285

[3] Francisco Maria Calisto, Carlos Santiago, Nuno Nunes, Jacinto C. Nascimento, Introduction of human-centric AI assistant to aid radiologists for multimodal breast image classification, International Journal of Human-Computer Studies, Volume 150, 2021, 102607, ISSN 1071-5819, https://doi.org/10.1016/j.ijhcs.2021.102607

Top comments (0)