Skip to content

Commit bf0b018

Browse files
committed
RF: clear <CR> characters in test file
Whitespace changes only.
1 parent 4cafaf5 commit bf0b018

File tree

1 file changed

+78
-78
lines changed

1 file changed

+78
-78
lines changed

nibabel/nicom/tests/test_dicomwrappers.py

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import gzip
66
from hashlib import sha1
77
from decimal import Decimal
8-
from copy import copy
8+
from copy import copy
99

1010
import numpy as np
1111

@@ -379,54 +379,54 @@ class Fake(object):
379379
setattr(fake_frame, seq_name, [fake_element])
380380
frames.append(fake_frame)
381381
return frames
382-
383-
384-
def fake_shape_dependents(div_seq, sid_seq=None, sid_dim=None):
385-
""" Make a fake dictionary of data that ``image_shape`` is dependent on.
386-
387-
Parameters
388-
----------
389-
div_seq : list of tuples
390-
list of values to use for the `DimensionIndexValues` of each frame.
391-
sid_seq : list of int
392-
list of values to use for the `StackID` of each frame.
393-
sid_dim : int
394-
the index of the column in 'div_seq' to use as 'sid_seq'
395-
"""
396-
class DimIdxSeqElem(object):
397-
def __init__(self, dip=(0, 0), fgp=None):
398-
self.DimensionIndexPointer = dip
399-
if fgp is not None:
400-
self.FunctionalGroupPointer = fgp
401-
class FrmContSeqElem(object):
402-
def __init__(self, div, sid):
403-
self.DimensionIndexValues = div
404-
self.StackID = sid
405-
class PerFrmFuncGrpSeqElem(object):
406-
def __init__(self, div, sid):
407-
self.FrameContentSequence = [FrmContSeqElem(div, sid)]
408-
# if no StackID values passed in then use the values at index 'sid_dim' in
409-
# the value for DimensionIndexValues for it
410-
if sid_seq is None:
411-
if sid_dim is None:
412-
sid_dim = 0
413-
sid_seq = [div[sid_dim] for div in div_seq]
414-
# create the DimensionIndexSequence
415-
num_of_frames = len(div_seq)
416-
dim_idx_seq = [DimIdxSeqElem()] * num_of_frames
417-
# add an entry for StackID into the DimensionIndexSequence
418-
if sid_dim is not None:
419-
sid_tag = pydicom.datadict.tag_for_name('StackID')
420-
fcs_tag = pydicom.datadict.tag_for_name('FrameContentSequence')
421-
dim_idx_seq[sid_dim] = DimIdxSeqElem(sid_tag, fcs_tag)
422-
# create the PerFrameFunctionalGroupsSequence
423-
frames = [PerFrmFuncGrpSeqElem(div, sid)
424-
for div, sid in zip(div_seq, sid_seq)]
425-
return {'NumberOfFrames' : num_of_frames,
426-
'DimensionIndexSequence' : dim_idx_seq,
427-
'PerFrameFunctionalGroupsSequence' : frames}
428-
429-
382+
383+
384+
def fake_shape_dependents(div_seq, sid_seq=None, sid_dim=None):
385+
""" Make a fake dictionary of data that ``image_shape`` is dependent on.
386+
387+
Parameters
388+
----------
389+
div_seq : list of tuples
390+
list of values to use for the `DimensionIndexValues` of each frame.
391+
sid_seq : list of int
392+
list of values to use for the `StackID` of each frame.
393+
sid_dim : int
394+
the index of the column in 'div_seq' to use as 'sid_seq'
395+
"""
396+
class DimIdxSeqElem(object):
397+
def __init__(self, dip=(0, 0), fgp=None):
398+
self.DimensionIndexPointer = dip
399+
if fgp is not None:
400+
self.FunctionalGroupPointer = fgp
401+
class FrmContSeqElem(object):
402+
def __init__(self, div, sid):
403+
self.DimensionIndexValues = div
404+
self.StackID = sid
405+
class PerFrmFuncGrpSeqElem(object):
406+
def __init__(self, div, sid):
407+
self.FrameContentSequence = [FrmContSeqElem(div, sid)]
408+
# if no StackID values passed in then use the values at index 'sid_dim' in
409+
# the value for DimensionIndexValues for it
410+
if sid_seq is None:
411+
if sid_dim is None:
412+
sid_dim = 0
413+
sid_seq = [div[sid_dim] for div in div_seq]
414+
# create the DimensionIndexSequence
415+
num_of_frames = len(div_seq)
416+
dim_idx_seq = [DimIdxSeqElem()] * num_of_frames
417+
# add an entry for StackID into the DimensionIndexSequence
418+
if sid_dim is not None:
419+
sid_tag = pydicom.datadict.tag_for_name('StackID')
420+
fcs_tag = pydicom.datadict.tag_for_name('FrameContentSequence')
421+
dim_idx_seq[sid_dim] = DimIdxSeqElem(sid_tag, fcs_tag)
422+
# create the PerFrameFunctionalGroupsSequence
423+
frames = [PerFrmFuncGrpSeqElem(div, sid)
424+
for div, sid in zip(div_seq, sid_seq)]
425+
return {'NumberOfFrames' : num_of_frames,
426+
'DimensionIndexSequence' : dim_idx_seq,
427+
'PerFrameFunctionalGroupsSequence' : frames}
428+
429+
430430
class TestMultiFrameWrapper(TestCase):
431431
# Test MultiframeWrapper
432432
MINIMAL_MF = {
@@ -453,65 +453,65 @@ def test_shape(self):
453453
assert_raises(AssertionError, getattr, dw, 'image_shape')
454454
fake_mf['NumberOfFrames'] = 4
455455
# PerFrameFunctionalGroupsSequence does not match NumberOfFrames
456-
assert_raises(AssertionError, getattr, dw, 'image_shape')
457-
# check 3D shape when StackID index is 0
458-
div_seq = ((1, 1), (1, 2), (1, 3), (1, 4))
459-
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
456+
assert_raises(AssertionError, getattr, dw, 'image_shape')
457+
# check 3D shape when StackID index is 0
458+
div_seq = ((1, 1), (1, 2), (1, 3), (1, 4))
459+
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
460460
assert_equal(MFW(fake_mf).image_shape, (32, 64, 4))
461461
# Check stack number matching when StackID index is 0
462462
div_seq = ((1, 1), (1, 2), (1, 3), (2, 4))
463-
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
463+
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
464464
assert_raises(didw.WrapperError, getattr, MFW(fake_mf), 'image_shape')
465-
# Make some fake frame data for 4D when StackID index is 0
465+
# Make some fake frame data for 4D when StackID index is 0
466466
div_seq = ((1, 1, 1), (1, 2, 1), (1, 1, 2), (1, 2, 2),
467467
(1, 1, 3), (1, 2, 3))
468-
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
468+
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
469469
assert_equal(MFW(fake_mf).image_shape, (32, 64, 2, 3))
470470
# Check stack number matching for 4D when StackID index is 0
471471
div_seq = ((1, 1, 1), (1, 2, 1), (1, 1, 2), (1, 2, 2),
472472
(1, 1, 3), (2, 2, 3))
473-
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
473+
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
474474
assert_raises(didw.WrapperError, getattr, MFW(fake_mf), 'image_shape')
475475
# Check indices can be non-contiguous when StackID index is 0
476476
div_seq = ((1, 1, 1), (1, 2, 1), (1, 1, 3), (1, 2, 3))
477-
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
477+
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
478478
assert_equal(MFW(fake_mf).image_shape, (32, 64, 2, 2))
479479
# Check indices can include zero when StackID index is 0
480480
div_seq = ((1, 1, 0), (1, 2, 0), (1, 1, 3), (1, 2, 3))
481-
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
481+
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))
482482
assert_equal(MFW(fake_mf).image_shape, (32, 64, 2, 2))
483-
# check 3D shape when there is no StackID index
483+
# check 3D shape when there is no StackID index
484484
div_seq = ((1,), (2,), (3,), (4,))
485485
sid_seq = (1, 1, 1, 1)
486-
fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq))
486+
fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq))
487487
assert_equal(MFW(fake_mf).image_shape, (32, 64, 4))
488488
# check 3D stack number matching when there is no StackID index
489489
div_seq = ((1,), (2,), (3,), (4,))
490490
sid_seq = (1, 1, 1, 2)
491-
fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq))
491+
fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq))
492492
assert_raises(didw.WrapperError, getattr, MFW(fake_mf), 'image_shape')
493-
# check 4D shape when there is no StackID index
493+
# check 4D shape when there is no StackID index
494494
div_seq = ((1, 1), (2, 1), (1, 2), (2, 2), (1, 3), (2, 3))
495495
sid_seq = (1, 1, 1, 1, 1, 1)
496-
fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq))
496+
fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq))
497497
assert_equal(MFW(fake_mf).image_shape, (32, 64, 2, 3))
498498
# check 4D stack number matching when there is no StackID index
499499
div_seq = ((1, 1), (2, 1), (1, 2), (2, 2), (1, 3), (2, 3))
500500
sid_seq = (1, 1, 1, 1, 1, 2)
501-
fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq))
501+
fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq))
502502
assert_raises(didw.WrapperError, getattr, MFW(fake_mf), 'image_shape')
503-
# check 3D shape when StackID index is 1
503+
# check 3D shape when StackID index is 1
504504
div_seq = ((1, 1), (2, 1), (3, 1), (4, 1))
505-
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=1))
505+
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=1))
506506
assert_equal(MFW(fake_mf).image_shape, (32, 64, 4))
507507
# Check stack number matching when StackID index is 1
508-
div_seq = ((1, 1), (2, 1), (3, 2), (4, 1))
509-
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=1))
508+
div_seq = ((1, 1), (2, 1), (3, 2), (4, 1))
509+
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=1))
510510
assert_raises(didw.WrapperError, getattr, MFW(fake_mf), 'image_shape')
511-
# Make some fake frame data for 4D when StackID index is 1
511+
# Make some fake frame data for 4D when StackID index is 1
512512
div_seq = ((1, 1, 1), (2, 1, 1), (1, 1, 2), (2, 1, 2),
513513
(1, 1, 3), (2, 1, 3))
514-
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=1))
514+
fake_mf.update(fake_shape_dependents(div_seq, sid_dim=1))
515515
assert_equal(MFW(fake_mf).image_shape, (32, 64, 2, 3))
516516

517517
def test_iop(self):
@@ -629,9 +629,9 @@ def test_data_fake(self):
629629
assert_raises(didw.WrapperError, dw.get_data)
630630
# Make shape and indices
631631
fake_mf['Rows'] = 2
632-
fake_mf['Columns'] = 3
633-
dim_idxs = ((1, 1), (1, 2), (1, 3), (1, 4))
634-
fake_mf.update(fake_shape_dependents(dim_idxs, sid_dim=0))
632+
fake_mf['Columns'] = 3
633+
dim_idxs = ((1, 1), (1, 2), (1, 3), (1, 4))
634+
fake_mf.update(fake_shape_dependents(dim_idxs, sid_dim=0))
635635
assert_equal(MFW(fake_mf).image_shape, (2, 3, 4))
636636
# Still fails - no data
637637
assert_raises(didw.WrapperError, dw.get_data)
@@ -646,9 +646,9 @@ def test_data_fake(self):
646646
fake_mf['RescaleSlope'] = 2.0
647647
fake_mf['RescaleIntercept'] = -1
648648
assert_array_equal(MFW(fake_mf).get_data(), data * 2.0 - 1)
649-
# Check slice sorting
650-
dim_idxs = ((1, 4), (1, 2), (1, 3), (1, 1))
651-
fake_mf.update(fake_shape_dependents(dim_idxs, sid_dim=0))
649+
# Check slice sorting
650+
dim_idxs = ((1, 4), (1, 2), (1, 3), (1, 1))
651+
fake_mf.update(fake_shape_dependents(dim_idxs, sid_dim=0))
652652
sorted_data = data[..., [3, 1, 2, 0]]
653653
fake_mf['pixel_array'] = np.rollaxis(sorted_data, 2)
654654
assert_array_equal(MFW(fake_mf).get_data(), data * 2.0 - 1)
@@ -670,7 +670,7 @@ def test_data_fake(self):
670670
[1, 2, 1, 2],
671671
[1, 3, 1, 2],
672672
[1, 1, 1, 2]]
673-
fake_mf.update(fake_shape_dependents(dim_idxs, sid_dim=0))
673+
fake_mf.update(fake_shape_dependents(dim_idxs, sid_dim=0))
674674
shape = (2, 3, 4, 2, 2)
675675
data = np.arange(np.prod(shape)).reshape(shape)
676676
sorted_data = data.reshape(shape[:2] + (-1,), order='F')

0 commit comments

Comments
 (0)