I'm trying to process new files in given folder with pyinotify watchdog with this code:
import pyinotify
import pydicom as pyd
class EventHandler(pyinotify.ProcessEvent):
def process_IN_CREATE(self, event):
if not event.dir:
print("Got new file: ", event.pathname)
img = pyd.dcmread(event.pathname)
pix = img.pixel_array
wm = pyinotify.WatchManager()
mask = pyinotify.IN_CREATE
loop = asyncio.get_event_loop()
notifier = pyinotify.AsyncioNotifier(wm, loop, default_proc_fun=EventHandler())
wdd = wm.add_watch('/home/Dicom/work', mask, rec=True, auto_add=True)
try:
loop.run_forever()
except:
print('\nshutting down...')
loop.stop()
notifier.stop()
And got the following error:
AttributeError: "Amount of pixel data 5045478 does not match the expected data 19633600."
The file is not corrupted. The first number in the error may be greater or lower, about 30-90% of expected (19633600). It looks like it has not enough time to read pixel data.