forked from marksgraham/OCT-Converter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdicom.py
More file actions
27 lines (21 loc) · 816 Bytes
/
Copy pathdicom.py
File metadata and controls
27 lines (21 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from pathlib import Path
from oct_converter.image_types import OCTVolumeWithMetaData
class Dicom(object):
def __init__(self, filepath):
self.filepath = Path(filepath)
if not self.filepath.exists():
raise FileNotFoundError(self.filepath)
def read_oct_volume(self):
"""Reads OCT data.
Returns:
obj:OCTVolumeWithMetaData
"""
import pydicom
dicom_data = pydicom.dcmread(self.filepath)
if dicom_data.Manufacturer.startswith("Carl Zeiss Meditec"):
raise ValueError(
"This appears to be a Zeiss DCM. You may need to read with the ZEISSDCM class."
)
pixel_data = dicom_data.pixel_array
oct_volume = OCTVolumeWithMetaData(volume=pixel_data)
return oct_volume