Skip to content

Commit f08f007

Browse files
committed
robustify tissue classification
1 parent 3dbfeda commit f08f007

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

nipy/neurospin/segmentation/vem.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ def vm_step_gauss(ppm, data_, mask):
2222
data_: ndarray (1d, masked data)
2323
mask: 3-element tuple of 1d ndarrays (X,Y,Z)
2424
"""
25-
ntissues = ppm.shape[3]
25+
ntissues = ppm.shape[-1]
2626
mu = np.zeros(ntissues)
2727
sigma = np.zeros(ntissues)
2828

2929
for i in range(ntissues):
30-
P = ppm[:,:,:,i][mask]
30+
#P = ppm[:,:,:,i][mask]
31+
P = ppm.T[i].T[mask]
3132
Z = P.sum()
3233
tmp = data_*P
3334
mu_ = tmp.sum()/Z
@@ -54,13 +55,13 @@ def vm_step_laplace(ppm, data_, mask):
5455
data_: ndarray (1d, masked data)
5556
mask: 3-element tuple of 1d ndarrays (X,Y,Z)
5657
"""
57-
ntissues = ppm.shape[3]
58+
ntissues = ppm.shape[-1]
5859
mu = np.zeros(ntissues)
5960
sigma = np.zeros(ntissues)
6061
ind = np.argsort(data_) # data_[ind] increasing
6162

6263
for i in range(ntissues):
63-
P = ppm[:,:,:,i][mask]
64+
P = ppm.T[i].T[mask]
6465
mu_ = wmedian(data_, P, ind)
6566
sigma_ = np.sum(np.abs(P*(data_-mu_)))/P.sum()
6667
mu[i] = mu_
@@ -95,10 +96,10 @@ def __init__(self, ppm, data, mask=None, noise='gauss',
9596

9697
# Mask data
9798
self.ppm = ppm
98-
self.ntissues = ppm.shape[3]
99+
self.ntissues = ppm.shape[-1]
99100
if mask == None:
100-
mask = np.mgrid[[slice(0,d) for d in ppm.shape[0:-1]]]
101-
mask = tuple(np.reshape(mask, [3,np.prod(ppm.shape[0:-1])]))
101+
mask = np.mgrid[[slice(0,d) for d in data.shape]]
102+
mask = tuple(np.reshape(mask, [data.ndim, np.prod(data.shape)]))
102103
self.mask = mask
103104
self.data_ = data[mask]
104105
if prior:
@@ -110,7 +111,7 @@ def __init__(self, ppm, data, mask=None, noise='gauss',
110111
# debug
111112
print('**************')
112113
print self.ref_.shape
113-
print self.data._shape
114+
print self.data_.shape
114115

115116
# Label information
116117
if labels == None:

setup.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[aliases]
2-
release = egg_info -RDb ''
2+
#release = egg_info -RDb ''
33
# Make sure the sphinx docs are built each time we do a dist.
4-
bdist = build_sphinx bdist
5-
sdist = build_sphinx sdist
4+
#bdist = build_sphinx bdist
5+
#sdist = build_sphinx sdist
66
# Make sure a zip file is created each time we build the sphinx docs
7-
build_sphinx = build_sphinx zip_help
7+
#build_sphinx = build_sphinx zip_help
88

99
[egg_info]
1010
tag_build = .dev

0 commit comments

Comments
 (0)