Skip to content

Commit 27675f3

Browse files
committed
[DATALAD RUNCMD] RF: .get_shape() -> .shape to address nibabel deprecation
=== Do not change lines below === { "chain": [], "cmd": "git-sedi '\\.get_shape()' .shape", "exit": 0, "extra_inputs": [], "inputs": [], "outputs": [ "doc", "src", "test" ], "pwd": "." } ^^^ Do not change lines above ^^^
1 parent 3d9fa7c commit 27675f3

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

doc/Python_Tutorial.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,25 +150,25 @@ method *split*.
150150
>>> from dcmstack.dcmmeta import NiftiWrapper
151151
>>> nw1 = NiftiWrapper.from_filename('img1.nii.gz')
152152
>>> nw2 = NiftiWrapper.from_filename('img2.nii.gz')
153-
>>> print nw1.nii_img.get_shape()
153+
>>> print nw1.nii_img.shape
154154
(384, 512, 60)
155-
>>> print nw2.nii_img.get_shape()
155+
>>> print nw2.nii_img.shape
156156
(384, 512, 60)
157157
>>> print nw1.get_meta('EchoTime')
158158
11.0
159159
>>> print nw2.get_meta('EchoTime')
160160
87.0
161161
>>> merged = NiftiWrapper.from_sequence([nw1, nw2])
162-
>>> print merged.nii_img.get_shape()
162+
>>> print merged.nii_img.shape
163163
(384, 512, 60, 2)
164164
>>> print merged.get_meta('EchoTime', index=(0,0,0,0)
165165
11.0
166166
>>> print merged.get_meta('EchoTime', index=(0,0,0,1)
167167
87.0
168168
>>> splits = list(merge.split())
169-
>>> print splits[0].nii_img.get_shape()
169+
>>> print splits[0].nii_img.shape
170170
(384, 512, 60)
171-
>>> print splits[1].nii_img.get_shape()
171+
>>> print splits[1].nii_img.shape
172172
(384, 512, 60)
173173
>>> print splits[0].get_meta('EchoTime')
174174
11.0

src/dcmstack/dcmmeta.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ def meta_valid(self, classification):
12921292
if classification == ('global', 'const'):
12931293
return True
12941294

1295-
img_shape = self.nii_img.get_shape()
1295+
img_shape = self.nii_img.shape
12961296
meta_shape = self.meta_ext.shape
12971297
if classification == ('vector', 'samples'):
12981298
return meta_shape[4:] == img_shape[4:]
@@ -1357,7 +1357,7 @@ def get_meta(self, key, index=None, default=None):
13571357
#If an index is provided check the varying values
13581358
if not index is None:
13591359
#Test if the index is valid
1360-
shape = self.nii_img.get_shape()
1360+
shape = self.nii_img.shape
13611361
if len(index) != len(shape):
13621362
raise IndexError('Incorrect number of indices.')
13631363
for dim, ind_val in enumerate(index):
@@ -1434,7 +1434,7 @@ def split(self, dim=None):
14341434
along `dim`.
14351435
14361436
'''
1437-
shape = self.nii_img.get_shape()
1437+
shape = self.nii_img.shape
14381438
data = self.nii_img.get_data()
14391439
header = self.nii_img.header
14401440
slice_dim = header.get_dim_info()[2]

src/dcmstack/dcmstack.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ def get_shape(self):
750750
num_vec_comps)
751751

752752
#Stack appears to be valid, build the shape tuple
753-
file_shape = self._files_info[0][0].nii_img.get_shape()
753+
file_shape = self._files_info[0][0].nii_img.shape
754754
vol_shape = list(file_shape)
755755
if files_per_vol > 1:
756756
vol_shape[2] = files_per_vol
@@ -777,7 +777,7 @@ def get_data(self):
777777
The stack is incomplete or invalid.
778778
'''
779779
#Create a numpy array for storing the voxel data
780-
stack_shape = self.get_shape()
780+
stack_shape = self.shape
781781
stack_shape = tuple(list(stack_shape) + ((5 - len(stack_shape)) * [1]))
782782
stack_dtype = self._files_info[0][0].nii_img.get_data_dtype()
783783
bits_stored = self._files_info[0][0].get_meta('BitsStored', default=16)
@@ -795,7 +795,7 @@ def get_data(self):
795795
if len(stack_shape) > 4:
796796
n_vols *= stack_shape[4]
797797
files_per_vol = len(self._files_info) // n_vols
798-
file_shape = self._files_info[0][0].nii_img.get_shape()
798+
file_shape = self._files_info[0][0].nii_img.shape
799799
for vec_idx in range(stack_shape[4]):
800800
for time_idx in range(stack_shape[3]):
801801
if files_per_vol == 1 and file_shape[2] != 1:
@@ -831,7 +831,7 @@ def get_affine(self):
831831
The stack is incomplete or invalid.
832832
'''
833833
#Figure out the number of three (or two) dimensional volumes
834-
shape = self.get_shape()
834+
shape = self.shape
835835
n_vols = 1
836836
if len(shape) > 3:
837837
n_vols *= shape[3]

test/test_dcmmeta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ def test_from_dicom():
11421142
meta = {'EchoTime': 40}
11431143
nw = dcmmeta.NiftiWrapper.from_dicom(src_dcm, meta)
11441144
hdr = nw.nii_img.header
1145-
eq_(nw.nii_img.get_shape(), (192, 192, 1))
1145+
eq_(nw.nii_img.shape, (192, 192, 1))
11461146
ok_(np.allclose(np.dot(np.diag([-1., -1., 1., 1.]), src_dw.get_affine()),
11471147
nw.nii_img.get_affine())
11481148
)

test/test_dcmstack.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,14 @@ def setUp(self):
365365
def test_single_slice(self):
366366
stack = dcmstack.DicomStack()
367367
stack.add_dcm(self.inputs[0])
368-
shape = stack.get_shape()
368+
shape = stack.shape
369369
eq_(shape, (192, 192, 1))
370370

371371
def test_three_dim(self):
372372
stack = dcmstack.DicomStack()
373373
stack.add_dcm(self.inputs[0])
374374
stack.add_dcm(self.inputs[1])
375-
shape = stack.get_shape()
375+
shape = stack.shape
376376
eq_(shape, (192, 192, 2))
377377

378378
def test_four_dim(self):
@@ -381,7 +381,7 @@ def test_four_dim(self):
381381
stack.add_dcm(self.inputs[1])
382382
stack.add_dcm(self.inputs[2])
383383
stack.add_dcm(self.inputs[3])
384-
shape = stack.get_shape()
384+
shape = stack.shape
385385
eq_(shape, (192, 192, 2, 2))
386386

387387
def test_five_dim(self):
@@ -390,7 +390,7 @@ def test_five_dim(self):
390390
stack.add_dcm(self.inputs[1])
391391
stack.add_dcm(self.inputs[2])
392392
stack.add_dcm(self.inputs[3])
393-
shape = stack.get_shape()
393+
shape = stack.shape
394394
eq_(shape, (192, 192, 2, 1, 2))
395395

396396
def test_allow_dummy(self):
@@ -399,7 +399,7 @@ def test_allow_dummy(self):
399399
stack = dcmstack.DicomStack(allow_dummies=True)
400400
stack.add_dcm(self.inputs[0])
401401
stack.add_dcm(self.inputs[1])
402-
shape = stack.get_shape()
402+
shape = stack.shape
403403
eq_(shape, (192, 192, 2))
404404

405405
class TestGuessDim(object):
@@ -435,7 +435,7 @@ def test_single_guess(self):
435435
for idx, in_dcm in enumerate(self.inputs):
436436
setattr(in_dcm, key, self._get_vr_ord(key, idx))
437437
stack.add_dcm(in_dcm)
438-
eq_(stack.get_shape(), (192, 192, 2, 2))
438+
eq_(stack.shape, (192, 192, 2, 2))
439439
for in_dcm in self.inputs:
440440
delattr(in_dcm, key)
441441

@@ -450,7 +450,7 @@ def test_wrong_guess_first(self):
450450
dcmstack.DicomStack.sort_guesses[-1],
451451
self._get_vr_ord(key, idx) )
452452
stack.add_dcm(in_dcm)
453-
eq_(stack.get_shape(), (192, 192, 2, 2))
453+
eq_(stack.shape, (192, 192, 2, 2))
454454

455455
class TestGetData(object):
456456
def setUp(self):
@@ -470,7 +470,7 @@ def test_single_slice(self):
470470
stack = dcmstack.DicomStack()
471471
stack.add_dcm(self.inputs[0])
472472
data = stack.get_data()
473-
eq_(data.shape, stack.get_shape())
473+
eq_(data.shape, stack.shape)
474474
eq_(sha256(data).hexdigest(),
475475
'15cfa107ca73810a1c97f1c1872a7a4a05808ba6147e039cef3f63fa08735f5d')
476476

@@ -479,7 +479,7 @@ def test_three_dim(self):
479479
stack.add_dcm(self.inputs[0])
480480
stack.add_dcm(self.inputs[1])
481481
data = stack.get_data()
482-
eq_(data.shape, stack.get_shape())
482+
eq_(data.shape, stack.shape)
483483
eq_(sha256(data).hexdigest(),
484484
'ab5225fdbedceeea3442b2c9387e1abcbf398c71f525e0017251849c3cfbf49c')
485485

@@ -490,7 +490,7 @@ def test_four_dim(self):
490490
stack.add_dcm(self.inputs[2])
491491
stack.add_dcm(self.inputs[3])
492492
data = stack.get_data()
493-
eq_(data.shape, stack.get_shape())
493+
eq_(data.shape, stack.shape)
494494
eq_(sha256(data).hexdigest(),
495495
'bb3639a6ece13dc9a11d65f1b09ab3ccaed63b22dcf0f96fb5d3dd8805cc7b8a')
496496

@@ -501,7 +501,7 @@ def test_five_dim(self):
501501
stack.add_dcm(self.inputs[2])
502502
stack.add_dcm(self.inputs[3])
503503
data = stack.get_data()
504-
eq_(data.shape, stack.get_shape())
504+
eq_(data.shape, stack.shape)
505505
eq_(sha256(data).hexdigest(),
506506
'bb3639a6ece13dc9a11d65f1b09ab3ccaed63b22dcf0f96fb5d3dd8805cc7b8a')
507507

@@ -512,7 +512,7 @@ def test_allow_dummy(self):
512512
stack.add_dcm(self.inputs[0])
513513
stack.add_dcm(self.inputs[1])
514514
data = stack.get_data()
515-
eq_(data.shape, stack.get_shape())
515+
eq_(data.shape, stack.shape)
516516
ok_(np.all(data[:, :, -1] == np.iinfo(np.int16).max))
517517
eq_(sha256(data).hexdigest(),
518518
'7d85fbcb60a5021a45df3975613dcb7ac731830e0a268590cc798dc39897c04b')

0 commit comments

Comments
 (0)