Community Story: MammoCare – Simplifying Breast Cancer Detection

Community Story: MammoCare – Simplifying Breast Cancer Detection
Listen to this article

Silent Echo Team proudly secured 1st place out of 200+ teams at the AiCodeX Hackathon, sponsored by aiXplain and organized by M.H. Saboo Siddik College Of Engineering. Our innovative solution, MammoCare, is designed to simplify breast cancer detection and support earlier, more accurate diagnoses.

Enhancing Breast Cancer Detection by Eliminating Unwanted Artifacts like Pectoral Muscel

Breast cancer is one of the most common and serious health problems worldwide, with approximately 2.3 million new cases diagnosed each year, making it the leading cause of cancer-related deaths among women. Early detection plays a key role in improving survival rates, which is why mammograms are crucial. Studies show that mammography can reduce breast cancer mortality by up to 30% in women aged 40-74 when used for regular screening.

However, mammogram images sometimes have unwanted issues, called artifacts, that can make it harder to see important details. These artifacts, such as the pectoral muscle or noise from the imaging process, can obscure key signs of tumors or other abnormalities. For instance, the pectoral muscle can create a shadow that hides part of the breast tissue, while imaging noise may blur or distort the image.

In the fight against breast cancer, getting an accurate diagnosis is essential. This is where MammoCare comes into play. By enhancing the quality of mammogram images, MammoCare helps doctors identify tumors or abnormalities more clearly and efficiently. This can lead to earlier detection, better treatment planning, and ultimately, improved survival rates for those affected by breast cancer.

What is MammoCare?

MammoCare is a cutting-edge, AI-powered platform designed to enhance breast cancer detection by significantly improving the clarity and quality of mammogram images. Leveraging advanced AI models, including aiXplain’s GPT-4 for interactive assistance and Image Content Moderation tools, MammoCare ensures reliable, accurate, and professional results.

The Image Content Moderation feature plays a crucial role in detecting and filtering inappropriate or irrelevant visual content, making it especially valuable for platforms that deal with user-generated images. Alongside this, GPT-4 integration provides real-time support, allowing users to ask questions about mammogram analysis, diagnostic processes, and other related topics—making the platform both interactive and user-friendly.

MammoCare’s smart algorithms also tackle imaging challenges by removing unwanted artifacts such as pectoralis muscle shadows and background noise. These enhancements result in higher-quality images that enable radiologists to focus on the critical details necessary for accurate diagnoses, fostering early cancer detection and better patient outcomes. The platform’s primary feature is its ability to remove the pectoral muscle, a common artifact in mammography, from the images. The pectoral muscle often obscures the upper portion of the breast tissue, making it difficult for healthcare professionals to identify important signs of cancer. By removing such artifacts, MammoCare provides clearer and more reliable images that aid in early cancer detection.

aiXplain Models

1. GPT-4

aiXplain models: GPT-4
Set the API key for aiXplain
API_KEY = 'Your Api Key'
API_URL = 'https://models.aixplain.com/api/v1/execute/6414bd3cd09663e9225130e8'   #aiXplain model URL

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

2. Image content moderation

aiXplain models: Image content moderation
async def run_model(image_data):
    """
    Run the moderation model on the given image data asynchronously.
    
    Parameters:
        image_data: The image data to be moderated.

    Returns:
        Moderation results from the model.
    """
    # Convert the image data to JPEG and then to base64 format
    _, encoded_image = cv2.imencode('.jpg', image_data)
    image_base64 = base64.b64encode(encoded_image).decode('utf-8')

    # Define the moderation API endpoint and headers
    url = 'https://models.aixplain.com/api/v1/execute/60ddef9c8d38c51c5885e48f'
    headers = {
        'x-api-key': 'Your API Key',
        'content-type': 'application/json'
    }
    body = {
        'image': image_base64,
    }

    # Send a POST request to the moderation API
    async with aiohttp.ClientSession() as session:
        async with session.post(url, json=body, headers=headers) as response:
            results = await response.json()  # Get the initial response
            url_to_poll = results['data']     # Extract URL to poll for results
            return await poll_for_results(url_to_poll)  # Poll for results

async def poll_for_results(url_to_poll):
    """
    Poll the moderation API for results until the processing is complete.
    
    Parameters:
        url_to_poll: The URL to poll for the results.

    Returns:
        The completed moderation results.
    """
    async with aiohttp.ClientSession() as session:
        while True:
            async with session.get(url_to_poll, headers={'x-api-key': 'Your API KEY'}) as status_response:
                results = await status_response.json()  # Get the results from the API
                if results['completed']:
                    return results['data']  # Return the completed results
            await asyncio.sleep(5)  # Wait before polling again

The Role of Artifact Removal in Mammogram Analysis

Mammogram images can contain several types of artifacts, including the pectoral muscle, background noise, and sometimes motion artifacts caused by patient movement. These artifacts can interfere with the clarity of the image, making it harder to detect small tumors or abnormalities.

MammoCare tackles these challenges with precision and accuracy. The platform uses advanced algorithms to identify and remove the pectoral muscle from mammogram images. This process ensures that the critical details of the breast tissue are preserved and highlighted, making it easier for radiologists to spot early signs of cancer. By providing clearer images, MammoCare helps reduce the chances of misdiagnosis and missed detections, improving the overall quality of breast cancer screening.

How MammoCare Works

MammoCare is a comprehensive platform that combines both manual and algorithmic methods for mammogram image preprocessing. Here’s a closer look at how the platform works:

  1. Image preprocessing: The first step in the workflow involves standard image processing techniques such as noise reduction, contrast adjustment, and normalization. These steps help to improve the overall quality of the image and prepare it for further analysis.
    # Functions for mammogram processing
    def load_image(file_path):
        return cv2.imread(file_path, cv2.IMREAD_GRAYSCALE)
    
    def preprocess_image(image, blur_kernel_size):
        equalized_image = cv2.equalizeHist(image)
        blurred_image = cv2.GaussianBlur(equalized_image, (blur_kernel_size, blur_kernel_size), 0)
        return blurred_image
  2. Manual pectoral muscle removal: In this step, the user manually selects the region of the pectoral muscle to be removed. This is done through interactive sliders that define the start and end points of the muscle area. Once the region is selected, the muscle is removed from the image, providing a clearer view of the breast tissue.
  3. Automatic pectoral muscle removal: For users looking for a more automated process, MammoCare also provides an automatic pectoral muscle removal option. This method uses sophisticated depth-first search (DFS) algorithms and other image processing techniques to segment and remove the pectoral muscle with minimal user input.
  4. Diagnostic feedback: Once the image has been processed and the artifacts removed, the radiologist is presented with an enhanced image that is easier to analyze. The platform also highlights areas of interest, such as potential tumors or dense regions, allowing healthcare professionals to make more informed decisions about the next steps in treatment.

Manual pectoral muscle removal

The manual pectoral muscle removal feature in MammoCare allows radiologists to take an active role in refining the image. Here’s how it works:

  1. Upload image: The user uploads a mammogram image, which can be in formats such as PNG, JPG, JPEG, or DICOM (.dcm).
  2. Adjust settings: The platform provides several options to customize the processing. The user can enhance the image contrast, blur noise using a Gaussian kernel, select the side of the breast, and define the region for pectoral muscle removal.
  3. Define pectoral region: Using the interactive sliders, the user specifies the coordinates of the start and end points for the pectoral muscle removal. This ensures that only the muscle is removed while preserving the surrounding breast tissue.
  4. Preview results: The processed image is displayed alongside the original image, allowing the radiologist to compare and ensure that the muscle has been successfully removed without affecting the rest of the breast tissue.

Automatic pectoral muscle removal

For users who prefer an automated solution, MammoCare also offers an automatic pectoral muscle removal technique, which significantly reduces the amount of manual intervention required. Here’s how the automatic process works:

  1. Image processing: The uploaded image is preprocessed to improve its quality. Techniques such as noise reduction and contrast enhancement are applied to ensure that the image is clear and ready for analysis.
  2. Depth-first search algorithm: The platform uses a depth-first search (DFS) algorithm to automatically detect and segment the pectoral muscle. The algorithm identifies the muscle area and removes it, leaving behind a clearer image of the breast tissue.
  3. Region growing: The algorithm then uses region-growing techniques to fill in any gaps left after the muscle removal, ensuring that the surrounding breast tissue is intact and properly represented.

The Benefits of MammoCare

MammoCare brings several key benefits to the table, making it a valuable tool for both radiologists and healthcare providers:

  • Improved accuracy: By removing artifacts like the pectoral muscle, MammoCare helps radiologists detect early signs of breast cancer more accurately. The clearer images make it easier to identify tumors, calcifications, and other abnormalities that may otherwise be missed.
  • Faster diagnoses: With clearer images and fewer distractions, radiologists can review mammograms more quickly, leading to faster diagnoses. This not only improves workflow efficiency but also helps in making timely decisions about patient care.
  • AI-assisted diagnosis: MammoCare integrates AI to assist radiologists by providing automated insights and suggestions. This additional layer of support helps enhance decision-making and further improves diagnostic accuracy.
  • Better patient outcomes: Early detection is critical to improving survival rates in breast cancer. By providing clearer and more accurate mammogram images, MammoCare helps radiologists detect breast cancer at an earlier stage, ultimately leading to better patient outcomes.

The Future of Breast Cancer Detection

MammoCare represents a significant leap forward in the field of medical imaging. By leveraging advanced image processing techniques, it streamlines the diagnostic process for radiologists and enhances the accuracy of breast cancer detection. As technology continues to evolve, MammoCare is poised to become a vital tool in the fight against breast cancer.

With its powerful artifact removal capabilities, AI-assisted diagnosis, and user-friendly interface, MammoCare is transforming the way mammogram images are processed and analyzed. It not only improves the speed and accuracy of diagnoses but also ensures that patients receive the best possible care in a timely manner.

Technology stack

  • Programming languages: Python
  • Libraries and frameworks: OpenCV, NumPy, Streamlit, and more.

MammoCare is more than just a tool for removing artifacts from mammogram images. It’s a comprehensive solution that enhances the entire process of breast cancer detection. With its combination of manual and automated techniques, MammoCare ensures that radiologists have the clearest, most accurate images possible. By reducing diagnostic errors and supporting healthcare professionals, MammoCare is helping to shape the future of breast cancer diagnosis and treatment.