Hi,
I am trying to deploy an algorithm that inputs DICOM files following 02_production.ipynb
from fastbook
However, I got stucked trying to upload the image when using:
btn_upload = widgets.FileUpload()
btn_upload
img = PILDicom.create(btn_upload.data[-1])
I got the following error:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-65-dea520106493> in <module>
----> 1 img = PILDicom.create(btn_upload.data[-1])
<ipython-input-64-95a902c2b184> in create(cls, fn, mode)
4 def create(cls, fn:(Path,str), mode=None)->None:
5 "Open a `DICOM file` from path `fn` and load it as a `PIL Image`"
----> 6 im = Image.fromarray(dcmread(fn).pixel_array)
7 im.load()
8 im = im._new(im.im)
~/DeepLearning/fastai2/fastai2/medical/imaging.py in dcmread(fn, force)
30 def dcmread(fn:Path, force = False):
31 "Open a `DICOM` file"
---> 32 return pydicom.dcmread(str(fn), force)
33
34 # Cell
~/anaconda3/envs/fastai2/lib/python3.7/site-packages/pydicom/filereader.py in dcmread(fp, defer_size, stop_before_pixels, force, specific_tags)
844 except Exception:
845 logger.debug("Reading file '{0}'".format(fp))
--> 846 fp = open(fp, 'rb')
847
848 if config.debugging:
OSError: [Errno 36] File name too long: 'b\'\\ [...]
I see that PILDicom.create
only accepts Path
to the file to import it correctly so I guess I have to add bytes
to the PILDicom class. However, I am not sure how to do it. Any hints?