Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
588c7ef
[FSL] Updated BEDPOSTX and XFibres
oesteban Sep 10, 2014
3f677eb
fixed gradient nonlinearities implementation
oesteban Sep 10, 2014
834571c
fixed errors
oesteban Sep 11, 2014
0f1c179
fixed bug
oesteban Sep 11, 2014
68ab056
fixed XFibres
oesteban Sep 11, 2014
449452f
fix doctest of BEDPOSTX
oesteban Sep 11, 2014
dc1a4cd
tested new XFibres. new parallel workflow
oesteban Sep 11, 2014
0de90cf
preparing new workflow for parallel processing
oesteban Sep 11, 2014
9336dee
new split and merge interfaces
oesteban Sep 12, 2014
6c01665
added test and some missing files in last commit
oesteban Sep 12, 2014
f177e3f
new parallel bedpostx finished :)
oesteban Sep 12, 2014
2afca1b
new naming conventions
oesteban Oct 6, 2014
6e8c5ae
Merge branch 'master' into enh/UpdateBEDPOSTX
oesteban Oct 6, 2014
1f00894
bedpostx_parallel avoid computation of dyads uncertainty available
oesteban Oct 6, 2014
5ee0ffb
Interface Merge for large files
oesteban Oct 6, 2014
3974692
Merge branch 'enh/UpdateBEDPOSTX' of github.com:oesteban/nipype into …
oesteban Oct 6, 2014
a3a420e
fix missing comma
oesteban Oct 6, 2014
5fef712
added computation of mean f samples in bedpostx
oesteban Oct 7, 2014
edb7faf
fix missing connections
oesteban Oct 7, 2014
983cee1
fixed several bugs. tested in practice
oesteban Oct 7, 2014
310160d
Merge remote-tracking branch 'upstream/master' into fix/bedpostx
satra Oct 7, 2014
a1636f8
Merge remote-tracking branch 'upstream/master' into fix/bedpostx
satra Oct 7, 2014
c8e82c0
fix: clean up bedpostx and xfibres implementations
satra Oct 8, 2014
fbf5db1
Merge remote-tracking branch 'upstream/master' into fix/bedpostx
satra Oct 8, 2014
400050b
tst: cleaned auto tests and imports
satra Oct 8, 2014
12e7608
tst: fixed all failing tests
satra Oct 8, 2014
fce9b33
resolved conflicts
satra Oct 8, 2014
0a79223
Merge branch 'satra-fix/bedpostx' into enh/UpdateBEDPOSTX
oesteban Oct 8, 2014
f43ea3b
make check-before-commit
oesteban Oct 8, 2014
6b69b33
Merge remote-tracking branch 'upstream/master' into fix/bedpostx
satra Oct 8, 2014
23b27d9
Merge branch 'master' into fix/bedpostx
satra Oct 15, 2014
983a5ee
fix: added tests to suppress auto generation
satra Oct 15, 2014
59b6a82
fix: resolved conflict
satra Oct 15, 2014
20c5052
Merge branch 'satra-fix/bedpostx2' into enh/UpdateBEDPOSTX
oesteban Oct 16, 2014
acf5380
Merge branch 'master' into enh/UpdateBEDPOSTX
oesteban Oct 16, 2014
13c7cfa
Merge with upstream master, make specs, make check-before-commit
oesteban Oct 16, 2014
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
preparing new workflow for parallel processing
  • Loading branch information
oesteban committed Sep 11, 2014
commit 0de90cf4becee19d7c3141a3eb78f02edb3adfcd
45 changes: 33 additions & 12 deletions nipype/workflows/dmri/fsl/dti.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,40 +123,61 @@ def merge_and_mean(name='mm'):
return wf


def gen_chunks(dwi, mask, nchunks=6):
def gen_chunks(dwi, mask, nvoxels=100):
import nibabel as nb
import numpy as np
from math import sqrt, ceil

mask = nb.load(mask).get_data()
mask[mask > 0] = 1
mask[mask < 1] = 0
nzels = np.nonzero(mask)
np.savetxt('nonzeroidx.txt', nzels)

dshape = mask.shape
mask = mask.reshape(-1).astype(np.uint8)

nzels = np.nonzero(mask)
np.savez('nonzeroidx', nzels)
els = np.sum(mask)
chunkels = round(els / nchunks)

data = mask.copy()
chunkside = int(ceil(sqrt(nvoxels)))
chshape = (chunkside, chunkside, 1)
chunkels = chunkside**2
nchunks = int(ceil(els/chunkels))

data = nb.load(dwi).get_data().astype(np.float32)
data = np.squeeze(data.reshape((mask.size, -1)).take(nzels, axis=0))

out_files = []
out_masks = []

for i in xrange(chunkels):
for i in xrange(nchunks):
first = i * chunkels
last = (i+1) * chunkels + 1
last = (i+1) * chunkels
fill = 0

chunk = data[first:last, ...]
if last > els:
fill = last - els
last = els

fname = 'chunk%05d.nii.gz' % i
nb.Nifti1Image(chunk, None, None).to_filename(fname)
out_files.append(fname)
datchunk = data[first:last, ...]
mskchunk = np.ones((last-first), dtype=np.uint8)

if fill > 0:
print 'filling %d elements' % fill
mskchunk = np.hstack((mskchunk, np.zeros((fill,), dtype=np.uint8)))
datchunk = np.vstack((datchunk, np.zeros((fill,
data.shape[-1]), dtype=np.float32)))

mname = 'mask%05d.nii.gz' % i
nb.Nifti1Image(mask[first:last],
nb.Nifti1Image(mskchunk.reshape(chshape),
None, None).to_filename(mname)
out_masks.append(mname)

datashape = [s for s in chshape] + [-1]
fname = 'chunk%05d.nii.gz' % i
nb.Nifti1Image(datchunk.reshape(tuple(datashape)),
None, None).to_filename(fname)
out_files.append(fname)

return out_files, out_masks