我有一个大脑的3D图像(让我们称之为闪光),它目前是263 x 256 x 185.我想将它调整为另一个图像的大小(称之为whole_brain_bravo); 256 x 256 x 176,并且(希望)使用lanczos插值重新采样(Image.ANTIALIAS).我的(失败)尝试:
from scipy import ndimage as nd
import nibabel as nib
import numpy as np
a = nib.load('flash.hdr') # nib is what I use to load the images
b = nib.load('whole_brain_bravo.hdr')
flash = a.get_data() # Access data as array (in this case memmap)
whole = b.get_data()
downed = nd.interpolation.zoom(flash, zoom=b.shape) # This obviously doesn't work
Run Code Online (Sandbox Code Playgroud)
你们有没有在3D图像上做过这种事情?
好的,我有一个来自EEG扫描的数据文件(二进制文件,data.eeg),在matlab中读取文件的代码并绘制一部分数据如下:
sr=400; % Sample Rate
Nyq_freq=sr/2; % Nyquist Frequency
fneeg=input('Filename (with path and extension) :', 's');
t=input('How many seconds in total of EEG ? : ');
ch=input('How many channels of EEG ? : ');
le=t*sr; % Length of the Recording
fid=fopen(fneeg, 'r', 'l'); % Open the file to read
EEG=fread(fid,[ch,le],'int16'); % Read Data -> EEG Matrix
fclose ('all');
plot(EEG(:,3))
Run Code Online (Sandbox Code Playgroud)
这是我尝试"翻译"
from numpy import *
from matplotlib.pylab import *
sample_rate = 400
Nyquist = sample_rate/2.
fneeg = raw_input("Filename (full path & …Run Code Online (Sandbox Code Playgroud) 我试图再次翻译一些matlab代码,我遇到了另一个泡菜.代码本身非常简单,它只是一个4节点旋转因子的演示.这是我的尝试:
from numpy import *
from matplotlib import pyplot as plt
x = zeros(4)
x[-1+1] = 0
x[0+1] = 1
x[1+1] = 1
x[2+1] = 0
z = 0 - 1j
W4 = exp(z*2*pi/4)
W0 = W4 ** 0
W1 = W4 ** 1
W2 = W4 ** 2
W3 = W4 ** 3
X = zeros(4)
X[-1+1] = (x[-1+1] + x[1+1]*W0) + W0*(x[0+1] + x[2+1]*W0)
X[0+1] = (x[-1+1] + x[1+1]*W2) + W1*(x[0+1] + x[2+1]*W2)
X[1+1] = (x[-1+1] + x[1+1]*W0) …Run Code Online (Sandbox Code Playgroud) 所以我在Ubuntu 12.04上运行了一个功能齐全的py脚本,一切都很棒.除了我不喜欢我的输入法,它会变得烦人,你会在下面看到.在我输入代码之前,我应该说代码采用.img格式的两个图像,然后对它们进行计算.这就是我所拥有的:
import os
first = raw_input("Full path to first .img file: ")
second = raw_input("Full path to second .img file: ")
print " "
if os.path.exists(first) == True:
if first.endswith('.img') == False:
print 'You did not give a .img file, try running again'
os.sys.exit()
elif os.path.exists(second) == True:
if second.endswith('.img') == False:
print 'You did not give a .img file, try running again'
os.sys.exit()
else:
print "Your path does not exist, probably a typo. Try again"
os.sys.exit()
Run Code Online (Sandbox Code Playgroud)
这就是我想要的; 我希望能够直接从终端输入python这个输入.换句话说,我希望能够在终端输入类似的东西 …