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
193 stars 70 forks source link

Reading E2E, memory error #91

Closed marksgraham closed 1 year ago

marksgraham commented 1 year ago

The files look to contain angiography to me. They get picked up as fundus images, but the image_header produced here doesn't seem right - the values of height and width are huge, causing a memory error when the reader tries to read a chunk of size width*height: https://github.com/marksgraham/OCT-Converter/blob/155df23327065214013036055a4d91d791998f8b/oct_converter/readers/e2e.py#L335-L345

Discussed in https://github.com/marksgraham/OCT-Converter/discussions/90

Originally posted by **micceo** February 19, 2023 Hi again! You're never to old to learn something new, first time out with python here. So some cut and paste in my try to read an e2e, used the example. I got an error. X:\m1>my-e2e.py ``` Traceback (most recent call last): File "X:\m1\my-e2e.py", line 13, in file.read_fundus_image() File "C:\prg\dev\Python\Python311\Lib\site-packages\oct_converter\readers\e2e.py", line 342, in read_fundus_image raw_volume = np.frombuffer(f.read(count), dtype=np.uint8) ^^^^^^^^^^^^^ ``` The my-eye.py from the example. ``` from oct_converter.readers import E2E filepath = "x:\m1\EMRorder20230217.e2e" file = E2E(filepath) oct_volumes = ( file.read_oct_volume() ) # returns a list of all OCT volumes with additional metadata if available for volume in oct_volumes: volume.peek(show_contours=True) # plots a montage of the volume volume.save("{}_{}.avi".format(volume.volume_id, volume.laterality)) fundus_images = ( file.read_fundus_image() ) # returns a list of all fundus images with additional metadata if available for image in fundus_images: image.save("{}+{}.png".format(image.image_id, image.laterality)) ``` The file I'm trying to read comes from a HEYEX2 (Heidelberg), 351368 bytes, EMRorder20230217.e2e Here is the first rows from that file. ``` 43 4D 44 62 00 00 00 00 00 00 00 00 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4D 44 62 4D 44 69 72 00 00 00 00 00 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 58 00 00 00 C8 00 00 00 DC 9D 78 56 4D 44 62 44 69 72 00 00 00 00 00 00 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 58 00 00 00 00 00 00 00 F2 7A 56 34 8C 00 00 00 8C 58 00 00 83 00 00 00 00 00 00 00 11 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 00 09 00 00 00 D2 9C 65 87 B8 00 00 00 4B 59 00 00 ``` Anyone available to get me on the right track here? Thanks in advance!