Skip to content

Commit 6c01665

Browse files
committed
added test and some missing files in last commit
1 parent 9336dee commit 6c01665

File tree

12 files changed

+38
-0
lines changed

12 files changed

+38
-0
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Next Release
22
============
33

4+
* ENH: New miscelaneous interfaces: SplitROIs, MergeROIs to enable parallel processing of very large images.
45
* ENH: Updated FSL interfaces: BEDPOSTX and XFibres, former interfaces are still available with the prefix `Old`.
56
* ENH: New FSL interface: EpiReg
67
* ENH: New Freesurfer interface: Tkregister2 (for conversion of fsl style matrices to freesurfer format)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import os
5+
from shutil import rmtree
6+
from tempfile import mkdtemp
7+
from nipype.testing import (assert_equal, example_data)
8+
9+
10+
def test_split_and_merge():
11+
import numpy as np
12+
import nibabel as nb
13+
import os.path as op
14+
from nipype.algorithms.misc import split_rois, merge_rois
15+
tmpdir = mkdtemp()
16+
17+
in_mask = example_data('tpms_msk.nii.gz')
18+
dwfile = op.join(tmpdir, 'dwi.nii.gz')
19+
mskdata = nb.load(in_mask).get_data()
20+
aff = nb.load(in_mask).get_affine()
21+
22+
dwshape = (mskdata.shape[0], mskdata.shape[1], mskdata.shape[2], 6)
23+
dwdata = np.random.normal(size=dwshape)
24+
25+
os.chdir(tmpdir)
26+
nb.Nifti1Image(dwdata.astype(np.float32),
27+
aff, None).to_filename(dwfile)
28+
29+
resdw, resmsk, resid = split_rois(dwfile, in_mask, roishape=(20, 20, 2))
30+
merged = merge_rois(resdw, resid, in_mask)
31+
dwmerged = nb.load(merged).get_data()
32+
33+
dwmasked = np.zeros_like(dwdata)
34+
dwmasked = dwdata * mskdata[:, :, :, np.newaxis]
35+
rmtree(tmpdir)
36+
37+
yield assert_equal, np.allclose(dwmasked, dwmerged), True

nipype/testing/data/roi01.nii

Whitespace-only changes.

nipype/testing/data/roi01_idx.npz

Whitespace-only changes.

nipype/testing/data/roi02.nii

Whitespace-only changes.

nipype/testing/data/roi02_idx.npz

Whitespace-only changes.

nipype/testing/data/roi03.nii

Whitespace-only changes.

nipype/testing/data/roi03_idx.npz

Whitespace-only changes.

nipype/testing/data/roi04.nii

Whitespace-only changes.

nipype/testing/data/roi04_idx.npz

Whitespace-only changes.

0 commit comments

Comments
 (0)