getImages.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #basic python
  2. import os
  3. import subprocess
  4. import re
  5. import datetime
  6. import sys
  7. fhome=os.path.expanduser('~')
  8. sys.path.insert(1,fhome+'/software/src/labkeyInterface')
  9. import labkeyInterface
  10. import labkeyDatabaseBrowser
  11. def getValue(filename,tags):
  12. #extract value of tags (list of tags) from dcmdump-ed file
  13. #supply tags without braces ie. 0002,0008
  14. #rows is a list of lines from file
  15. with open(filename,"r") as f:
  16. out=f.read()
  17. lst=out.split('\n')
  18. for tag in tags.keys():
  19. tags[tag]=loadDicom.getTagValue(lst,tag)
  20. return True
  21. net=labkeyInterface.labkeyInterface()
  22. net.init(fhome+'/.labkey/network.json')
  23. db=labkeyDatabaseBrowser.labkeyDB(net)
  24. #by default uses .labkey/Remote.json configuration
  25. dicomBase='/data/dicom/database/dicom'
  26. ds=db.selectRows('IPNUMMretro/Study','lists','imageList',{})
  27. storescu='storescu'
  28. peer='onko-nix.onko-i.si'#this is actually localhost
  29. port='11112'#this is for orthanc
  30. i=0
  31. for row in ds['rows']:
  32. print("ID: {}".format(row['patientid']))
  33. f=os.path.join(dicomBase,row['study'],row['series'],row['file'])
  34. print("Instance: {} ".format(f))
  35. #add files to orthanc via PACS
  36. outText=subprocess.check_output([storescu,peer,port,f])
  37. if i==0:
  38. break
  39. i=i+1
  40. print("Done")
  41. quit()