-
Notifications
You must be signed in to change notification settings - Fork 1
/
m.py
44 lines (35 loc) · 1.56 KB
/
m.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from genericpath import exists
import nilearn.plotting as plot
import nilearn.image as I
import os,gzip,io
import nibabel as nib
path="C:/users/administrator/desktop/nii"
path2="C:/users/administrator/desktop/nii/out/"
for i in os.listdir(path):
if(".nii.gz" in i):
pass
else:
if(".nii" in i):
img = nib.load(path+"/"+i)
data = img.get_fdata()
print(data)
import imageio
X=0
for s in data:
import numpy
aleph=numpy.array(s,dtype=numpy.int8)
X=X+1
t=1000
if(not exists("c:/inetpub/wwwroot/stat/"+"_"+i+str(X)+"/")):
os.mkdir("c:/inetpub/wwwroot/stat/"+"_"+i+str(X)+"/")
if(not exists("c:/inetpub/wwwroot/out/"+"_"+i+str(X)+"/")):
# os.mkdir("c:/inetpub/wwwroot/stat/"+"_"+i+str(X)+"/")
os.mkdir("c:/inetpub/wwwroot/out/"+"_"+i+str(X)+"/")
# os.mkdir("c:/inetpub/wwwroot/stat/")
for h in I.iter_img(img):
t=t+1
# img is now an in-memory 3D img
plot.plot_stat_map(h, threshold=3, display_mode="z", cut_coords=1,
colorbar=True,output_file="c:/inetpub/wwwroot/stat/"+"_"+i+str(X)+"/"+str(t))
plot.plot_img(img=h,colorbar=True,output_file="c:/inetpub/wwwroot/out/"+"_"+i+str(X)+"/"+str(t))
# plot.plot_img(aleph)