Giter Site home page Giter Site logo

stephanfward / ai-mri-analysis-dicom Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 8 KB

Slicing logic can be beneficial for preprocessing DICOM images, especially in medical imaging tasks where certain sections of the image may contain more relevant information than others.

License: MIT License

ai-mri-analysis-dicom's Introduction

AI MRI Analysis DICOM

Slicing logic can be beneficial for preprocessing DICOM images, especially in medical imaging tasks where certain sections of the image may contain more relevant information than others. Here's a Jupyter Notebook example on performing such processes.

import pydicom
import numpy as np 
from PIL import Image

def preprocess_image(dicom_file):
  # Read the DICOM file
  dicom_data = pydicom.dcmread(dicom_file)

  # Extract pixel data
  pixel_array = dicom_data.pixel_array

  # Perform slicing to extract relevant sections of the image
  sliced_image = slice_image(pixel_array, slice_position=(100, 100), slice_size=(128, 128))

  # Perform additional preprocessing steps if needed
  processed_image = resize_image(sliced_image, target_size=(256, 256))

return processed_image

def slice_image(image, slice_position, slice_size):
  # Slice the image around the specified position and size
  x_start, y_start = slice_position
  x_end, y_end = x_start + slice_size[0], y_start + slice_size[1]
  sliced_image = image[x_start:x_end, y_start:y_end]
return sliced_image

def resize_image(image, target_size):
  # Resize the image to the target size
  img = Image.fromarray(image)
  resized_image = img.resize(target_size, resample=Image.BICUBIC)
  resized_array = np.array(resized_image)
return resized_array

Example usage:

dicom_file = 'path/to/your/dicom/file.dcm' processed_image = preprocess_image(dicom_file)

Example usage:

dicom_file = 'path/to/your/dicom/file.dcm' processed_image = preprocess_image(dicom_file) You can then further process the processed_image as needed for your application

ai-mri-analysis-dicom's People

Contributors

stephanfward avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.