<commit_before>""" Testing reading DICOM files

"""

import numpy as np

from .. import dicomreaders as didr

from .test_dicomwrappers import (EXPECTED_AFFINE,
                                 DATA)

from nose.tools import assert_true, assert_false, \
     assert_equal, assert_raises

from numpy.testing import assert_array_equal, assert_array_almost_equal

from dipy.testing import parametric, IO_DATA_PATH


@parametric
def test_read_dwi():
    img = didr.mosaic_to_nii(DATA)
    arr = img.get_data()
    yield assert_equal(arr.shape, (128,128,48))
    yield assert_array_almost_equal(img.get_affine(), EXPECTED_AFFINE)


@parametric
def test_read_dwis():
    data, aff, bs, gs = didr.read_mosaic_dwi_dir(IO_DATA_PATH, '*.dcm.gz')
    yield assert_equal(data.ndim, 4)
    yield assert_equal(aff.shape, (4,4))
    yield assert_equal(bs.shape, (2,))
    yield assert_equal(gs.shape, (2,3))
    yield assert_raises(IOError, didr.read_mosaic_dwi_dir, 'improbable')<commit_msg>TEST - added more explicit tests for directory read<commit_after>""" Testing reading DICOM files

"""

import numpy as np

from .. import dicomreaders as didr

from .test_dicomwrappers import (EXPECTED_AFFINE,
                                 EXPECTED_PARAMS,
                                 DATA)

from nose.tools import assert_true, assert_false, \
     assert_equal, assert_raises

from numpy.testing import assert_array_equal, assert_array_almost_equal

from dipy.testing import parametric, IO_DATA_PATH


@parametric
def test_read_dwi():
    img = didr.mosaic_to_nii(DATA)
    arr = img.get_data()
    yield assert_equal(arr.shape, (128,128,48))
    yield assert_array_almost_equal(img.get_affine(), EXPECTED_AFFINE)


@parametric
def test_read_dwis():
    data, aff, bs, gs = didr.read_mosaic_dwi_dir(IO_DATA_PATH, '*.dcm.gz')
    yield assert_equal(data.ndim, 4)
    yield assert_array_almost_equal(aff, EXPECTED_AFFINE)
    yield assert_array_almost_equal(bs, (0, EXPECTED_PARAMS[0]))
    yield assert_array_almost_equal(gs,
                                    (np.zeros((3,)) + np.nan,
                                     EXPECTED_PARAMS[1]))
    yield assert_raises(IOError, didr.read_mosaic_dwi_dir, 'improbable')
    
{'fraction_non_alphanumeric': 0.09338168631006347, 'fraction_numerical': 0.012239347234814143, 'mean_word_length': 3.4228456913827654, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5811820', 'n_tokens_mistral': 789, 'n_tokens_neox': 753, 'n_words': 158}