Vepy23 / tugas-khusus

MIT License
0 stars 0 forks source link

Pembacaan file nrrd #3

Open Vepy23 opened 1 year ago

Vepy23 commented 1 year ago

Pembacaan file nrrd dari hasil segmentasi yang dilakukan oleh penulis (https://wiki.cancerimagingarchive.net/display/Public/PROSTATE-DIAGNOSIS#327725498004a7544e04a10a36cf7ed85def9d0) image

Berikut code yang digunakan import numpy as np import nrrd

List of file names

file_names = [ "nrrd/ProstateDx-01-0006_T2W_TSE_AX.nrrd", "nrrd/ProstateDx-01-0014_T2W_TSE_AX.nrrd", "nrrd/ProstateDx-01-0019_T2W_TSE_AX.nrrd", "nrrd/ProstateDx-01-0021_T2W_TSE_AX.nrrd", "nrrd/ProstateDx-01-0048_T2W_TSE_AX.nrrd" ]

for file_path in file_names:

Read the NRRD file

nrrd_data, metadata = nrrd.read(file_path)

# Get the voxel data
voxel_data = nrrd_data.astype(np.float32)

# Print the shape of the voxel data
print("File:", file_path)
print("Voxel data shape:", voxel_data.shape)
print()

# Access and print additional metadata if needed
print("Metadata:", metadata)
print ()

Hasilnya adalah sebagai berikut File: nrrd/ProstateDx-01-0006_T2W_TSE_AX.nrrd Voxel data shape: (400, 400, 32)

Metadata: OrderedDict([('type', 'short'), ('dimension', 3), ('space', 'left-posterior-superior'), ('sizes', array([400, 400, 32])), ('space directions', array([[ 0.40000001, 0. , 0. ], [ 0. , 0.39257384, 0.07671889], [ 0. , -0.57539209, 2.94430586]])), ('kinds', ['domain', 'domain', 'domain']), ('endian', 'little'), ('encoding', 'gzip'), ('space origin', array([-73.67883301, -72.62834167, -79.06616211]))])

File: nrrd/ProstateDx-01-0014_T2W_TSE_AX.nrrd Voxel data shape: (400, 400, 36)

Metadata: OrderedDict([('type', 'short'), ('dimension', 3), ('space', 'left-posterior-superior'), ('sizes', array([400, 400, 36])), ('space directions', array([[0.40000001, 0. , 0. ], [0. , 0.40000001, 0. ], [0. , 0. , 3. ]])), ('kinds', ['domain', 'domain', 'domain']), ('endian', 'little'), ('encoding', 'gzip'), ('space origin', array([ -64.08048248, -102.79594421, -55.74714279]))])

File: nrrd/ProstateDx-01-0019_T2W_TSE_AX.nrrd Voxel data shape: (400, 400, 32)

Metadata: OrderedDict([('type', 'short'), ('dimension', 3), ('space', 'left-posterior-superior'), ('sizes', array([400, 400, 32])), ('space directions', array([[ 0.39986203, 0.00389186, 0.00975736], [-0.00434163, 0.39954568, 0.01855808], [-0.07174283, -0.13993188, 2.99587596]])), ('kinds', ['domain', 'domain', 'domain']), ('endian', 'little'), ('encoding', 'gzip'), ('space origin', array([-86.57762146, -58.75457764, -44.43187714]))])

File: nrrd/ProstateDx-01-0021_T2W_TSE_AX.nrrd Voxel data shape: (400, 400, 32)

Metadata: OrderedDict([('type', 'short'), ('dimension', 3), ('space', 'left-posterior-superior'), ('sizes', array([400, 400, 32])), ('space directions', array([[ 0.40000001, 0. , 0. ], [ 0. , 0.39197112, 0.07974109], [ 0. , -0.5980578 , 2.9397817 ]])), ('kinds', ['domain', 'domain', 'domain']), ('endian', 'little'), ('encoding', 'gzip'), ('space origin', array([ -87.08752441, -76.52446747, -105.66570282]))])

File: nrrd/ProstateDx-01-0048_T2W_TSE_AX.nrrd Voxel data shape: (400, 400, 36)

Metadata: OrderedDict([('type', 'short'), ('dimension', 3), ('space', 'left-posterior-superior'), ('sizes', array([400, 400, 36])), ('space directions', array([[ 3.99995357e-01, 1.92605614e-03, 1.89280009e-05], [-1.92402716e-03, 3.99350959e-01, 2.26962391e-02], [ 6.77912088e-04, -1.70220482e-01, 2.99516658e+00]])), ('kinds', ['domain', 'domain', 'domain']), ('endian', 'little'), ('encoding', 'gzip'), ('space origin', array([-84.14004517, -84.16617584, -48.19633865]))])

Vepy23 commented 1 year ago

Pembacaan citra

import numpy as np import nrrd import matplotlib.pyplot as plt

List of file names

file_names = [ "nrrd/ProstateDx-01-0006_T2W_TSE_AX.nrrd", "nrrd/ProstateDx-01-0014_T2W_TSE_AX.nrrd", "nrrd/ProstateDx-01-0019_T2W_TSE_AX.nrrd", "nrrd/ProstateDx-01-0021_T2W_TSE_AX.nrrd", "nrrd/ProstateDx-01-0048_T2W_TSE_AX.nrrd" ]

num_files = len(file_names) fig, axs = plt.subplots(1, num_files, figsize=(20, 5)) # Create subplots

for i, file_path in enumerate(file_names):

Read the NRRD file

nrrd_data, metadata = nrrd.read(file_path)

# Get the voxel data
voxel_data = nrrd_data.astype(np.float32)

# Display the image
axs[i].imshow(voxel_data[:,:,0], cmap='gray')
axs[i].set_title(file_path)

plt.tight_layout() # Adjust the spacing between subplots plt.show()

citra nrrd

Vepy23 commented 1 year ago

Tahapan selanjutnya melakukan segmentasi manual untuk ke-5 file tersebut dan ekstraksi fitur radiomik pada kedua proses segmentasi