TensorFlow.org पर देखें | Google Colab में चलाएं | GitHub पर स्रोत देखें | नोटबुक डाउनलोड करें |
अवलोकन
इस ट्यूटोरियल दिखाता है कि कैसे उपयोग करने के लिए tfio.image.decode_dicom_image TensorFlow आईओ में डिकोड DICOM करने के लिए फ़ाइलों TensorFlow साथ।
सेटअप और उपयोग
DICOM छवि डाउनलोड करें
DICOM इस ट्यूटोरियल में प्रयोग किया जाता से आया है उसे एनआईएच छाती का एक्स-रे डाटासेट ।
एनआईएच छाती का एक्स-रे डाटासेट 100,000 de-पहचान एनआईएच नैदानिक केंद्र द्वारा प्रदान किया PNG प्रारूप में सीने में एक्स रे की छवियों, के होते हैं और के माध्यम से डाउनलोड किया जा सकता है इस लिंक ।
Google मेघ भी छवियों की एक DICOM संस्करण, में उपलब्ध प्रदान करता है क्लाउड संग्रह ।
इस ट्यूटोरियल में, आप से डाटासेट का एक नमूना फ़ाइल डाउनलोड करेगा GitHub रेपो
- Xiaosong Wang, Yifan Peng, Le Lu, Zhiyong Lu, Mohammadhadi Bageri, रोनाल्ड समर्स, ChestX-ray8: हॉस्पिटल-स्केल चेस्ट एक्स-रे डेटाबेस और कमजोर-पर्यवेक्षित वर्गीकरण और सामान्य थोरैक्स रोगों के स्थानीयकरण पर बेंचमार्क, IEEE CVPR, पीपी। 3462 -3471, 2017
curl -OL https://github.com/tensorflow/io/raw/master/docs/tutorials/dicom/dicom_00000001_000.dcmls -l dicom_00000001_000.dcm
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 164 0 164 0 0 600 0 --:--:-- --:--:-- --:--:-- 598
100 1024k 100 1024k 0 0 1915k 0 --:--:-- --:--:-- --:--:-- 1915k
-rw-rw-r-- 1 kbuilder kokoro 1049332 Nov 22 03:47 dicom_00000001_000.dcm
आवश्यक पैकेज स्थापित करें, और रनटाइम को पुनरारंभ करें
try:
# Use the Colab's preinstalled TensorFlow 2.x
%tensorflow_version 2.x
except:
pass
pip install tensorflow-io
डिकोड DICOM छवि
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
import tensorflow_io as tfio
image_bytes = tf.io.read_file('dicom_00000001_000.dcm')
image = tfio.image.decode_dicom_image(image_bytes, dtype=tf.uint16)
skipped = tfio.image.decode_dicom_image(image_bytes, on_error='skip', dtype=tf.uint8)
lossy_image = tfio.image.decode_dicom_image(image_bytes, scale='auto', on_error='lossy', dtype=tf.uint8)
fig, axes = plt.subplots(1,2, figsize=(10,10))
axes[0].imshow(np.squeeze(image.numpy()), cmap='gray')
axes[0].set_title('image')
axes[1].imshow(np.squeeze(lossy_image.numpy()), cmap='gray')
axes[1].set_title('lossy image');
2021-11-22 03:47:53.016507: E tensorflow/stream_executor/cuda/cuda_driver.cc:271] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected

DICOM मेटाडेटा को डिकोड करें और टैग के साथ काम करें
decode_dicom_data टैग जानकारी डीकोड। dicom_tags ताकि आप DICOM जैसे टैग का उपयोग कर सकते हैं, मरीज की उम्र और सेक्स के रूप में उपयोगी जानकारी शामिल है dicom_tags.PatientsAge और dicom_tags.PatientsSex । tensorflow_io pydicom dicom पैकेज से समान टैग नोटेशन उधार लेता है।
tag_id = tfio.image.dicom_tags.PatientsAge
tag_value = tfio.image.decode_dicom_data(image_bytes,tag_id)
print(tag_value)
tf.Tensor(b'58', shape=(), dtype=string)
print(f"PatientsAge : {tag_value.numpy().decode('UTF-8')}")
PatientsAge : 58
tag_id = tfio.image.dicom_tags.PatientsSex
tag_value = tfio.image.decode_dicom_data(image_bytes,tag_id)
print(f"PatientsSex : {tag_value.numpy().decode('UTF-8')}")
PatientsSex : M
TensorFlow.org पर देखें
Google Colab में चलाएं
GitHub पर स्रोत देखें
नोटबुक डाउनलोड करें