Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for i,file in enumerate(files):
- path="C:/Users/rogge/Desktop/MRIs/Whole/%s" % str(i+2)
- if not os.path.isdir(path):
- os.makedirs(path)
- path1=path+"/Axial"
- path2=path+"/Coronal"
- path3=path+"/Sagittal"
- if not os.path.isdir(path1):
- os.makedirs(path1)
- if not os.path.isdir(path2):
- os.makedirs(path2)
- if not os.path.isdir(path3):
- os.makedirs(path3)
- paths=[path3,path2,path1]
- img=nb.load(file)
- data=img.get_data()
- for z in range(len(data.shape)):
- plane=data.shape[z]
- tpath=paths[z]
- if z==0:
- for y in range(plane):
- temp=data[y,:,:]
- x=plt.figure(figsize=(10,10))
- x=plt.imshow(temp.T,cmap="gray",origin="lower")
- plt.savefig(tpath+'/%s.png' % y, bbox_inches='tight')
- plt.close('all')
- elif z==1:
- for y in range(plane):
- temp=data[:,y,:]
- x=plt.figure(figsize=(10,10))
- x=plt.imshow(temp.T,cmap="gray",origin="lower")
- plt.savefig(tpath+'/%s.png' % y, bbox_inches='tight')
- plt.close('all')
- elif z==2:
- for y in range(plane):
- temp=data[:,:,y]
- x=plt.figure(figsize=(10,10))
- x=plt.imshow(temp.T,cmap="gray",origin="lower")
- plt.savefig(tpath+'/%s.png' % y, bbox_inches='tight')
- plt.close('all')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement