Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. for i,file in enumerate(files):
  2. path="C:/Users/rogge/Desktop/MRIs/Whole/%s" % str(i+2)
  3. if not os.path.isdir(path):
  4. os.makedirs(path)
  5. path1=path+"/Axial"
  6. path2=path+"/Coronal"
  7. path3=path+"/Sagittal"
  8. if not os.path.isdir(path1):
  9. os.makedirs(path1)
  10. if not os.path.isdir(path2):
  11. os.makedirs(path2)
  12. if not os.path.isdir(path3):
  13. os.makedirs(path3)
  14.  
  15. paths=[path3,path2,path1]
  16. img=nb.load(file)
  17. data=img.get_data()
  18. for z in range(len(data.shape)):
  19. plane=data.shape[z]
  20. tpath=paths[z]
  21. if z==0:
  22. for y in range(plane):
  23. temp=data[y,:,:]
  24. x=plt.figure(figsize=(10,10))
  25. x=plt.imshow(temp.T,cmap="gray",origin="lower")
  26. plt.savefig(tpath+'/%s.png' % y, bbox_inches='tight')
  27. plt.close('all')
  28. elif z==1:
  29. for y in range(plane):
  30. temp=data[:,y,:]
  31. x=plt.figure(figsize=(10,10))
  32. x=plt.imshow(temp.T,cmap="gray",origin="lower")
  33. plt.savefig(tpath+'/%s.png' % y, bbox_inches='tight')
  34. plt.close('all')
  35. elif z==2:
  36. for y in range(plane):
  37. temp=data[:,:,y]
  38. x=plt.figure(figsize=(10,10))
  39. x=plt.imshow(temp.T,cmap="gray",origin="lower")
  40. plt.savefig(tpath+'/%s.png' % y, bbox_inches='tight')
  41. plt.close('all')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement