marksgraham / OCT-Converter

Tools for extracting the raw optical coherence tomography (OCT) and fundus data from proprietary file formats.
https://pypi.org/project/oct-converter/
MIT License
199 stars 70 forks source link

DCM extraction? #109

Closed geeegs closed 1 year ago

geeegs commented 1 year ago

Using the example, I managed to extract the FDS files OK. I wondered if there was a how-to on extracting the DCM files? I tried changing all the mentions of FDS to DCM but without any luck.

My example:

from oct_converter.readers import DCM

filepath = '/home/gegan/Downloads/fwddcmfilesfromoct/DICOMDIR'
dcm = DCM(filepath)

oct_volume = dcm.read_oct_volume()  # returns an OCT volume with additional metadata if available
oct_volume.peek(show_contours=True) # plots a montage of the volume, with layer segmentations is available
oct_volume.save('dcm_testing.avi')  # save volume as a movie
oct_volume.save('dcm_testing.png')  # save volume as a set of sequential images, dcm_testing_[1...N].png
oct_volume.save_projection('projection.png') # save 2D projection

metadata = dcm.read_all_metadata(verbose=True) # extracts all other metadata
with open("dcm_metadata.json", "w") as outfile:
    outfile.write(json.dumps(metadata, indent=4))

and the output being:

Traceback (most recent call last): File "/home/gegan/Downloads/fwddcmfilesfromoct/dcm.py", line 1, in <module> from oct_converter.readers import DCM ImportError: cannot import name 'DCM' from 'oct_converter.readers' (/usr/lib/python3.10/site-packages/oct_converter/readers/__init__.py)

I'm attempting to extract OCT images from a Zeiss Cirrus 400(?) in order to not have to go through thousands of records manually and save their scans as PDFs. I'm sure there's something obvious that I've overlooked but would appreciate any input you could afford me.

marksgraham commented 1 year ago

Hi,

Your error is becuase you should be importing Dicom rather than DCM. But note the Dicom reader available is just a thin wrapper for pydicom. There is no longer a specific reader for Zeiss' obfuscated Dicom format available in the repository.

geeegs commented 1 year ago

Thanks for your reply. I wish I understood what you meant. In short, is there no easy way for me to extract the files?

Oli4 commented 1 year ago

You need to change from oct_converter.readers import DCM to from oct_converter.readers import Dicom. This reader is a simple wrapper using pydicom. You can find the code here Support for the Zeiss Dicom format had to be removed. For some this might be a reason not to buy their devices in the future. Others might try to recover the respective code to analyze existing data.