Exemple #1
0
def test_dicom():
    i = ndar.Image('test_data/NDAR_INVXT425UFT_image03_1357865972017.zip')
    dicom_file = i.path(i.files['DICOM'][0])
    assert os.path.exists(dicom_file)
    i.clean()
    assert not os.path.exists(dicom_file)
    assert os.path.exists(i.path(i.files['DICOM'][0]))
Exemple #2
0
def test_clean():
    i = ndar.Image('test_data/06025B_mprage.nii.gz')
    tempdir = i._tempdir
    assert os.path.exists(tempdir)
    i.clean()
    assert not os.path.exists(tempdir)
    assert os.path.exists(i._tempdir)
Exemple #3
0
def test_dicom_2():
    i = ndar.Image('test_data/s1615890.zip')
    assert len(i.files['DICOM']) == 166
    for (k, v) in i.files.iteritems():
        if k != 'DICOM':
            assert not v
    assert os.path.exists(i.path('i1616037.MRDC.160'))
Exemple #4
0
def test_dicom():
    i = ndar.Image('test_data/NDAR_INVXT425UFT_image03_1357865972017.zip')
    assert i.files['DICOM'] == ['0001.dcm']
    for (k, v) in i.files.iteritems():
        if k != 'DICOM':
            assert not v
    assert os.path.exists(i.path('0001.dcm'))
Exemple #5
0
def test_nifti_1():
    i = ndar.Image('test_data/06025B_mprage.nii.gz')
    assert i.files['NIfTI-1'] == ['06025B_mprage.nii.gz']
    for (k, v) in i.files.iteritems():
        if k != 'NIfTI-1':
            assert not v
    assert os.path.exists(i.path('06025B_mprage.nii.gz'))
Exemple #6
0
def test_tempdir_noremove():
    i = ndar.Image('test_data/06025B_mprage.nii.gz')
    tempdir = i._tempdir
    i._clean_on_del = False
    del i
    assert os.path.exists(tempdir)
    shutil.rmtree(tempdir)
Exemple #7
0
def test_nifti_1():
    i = ndar.Image('test_data/06025B_mprage.nii.gz')
    nifti_1_file = i.path(i.files['NIfTI-1'][0])
    assert os.path.exists(nifti_1_file)
    i.clean()
    assert not os.path.exists(nifti_1_file)
    assert os.path.exists(i.path(i.files['NIfTI-1'][0]))
Exemple #8
0
def test_thumbnail():
    i = ndar.Image('test_data/06025B_mprage.nii.gz')
    thumbnail = i.thumbnail
    assert os.path.exists(thumbnail)
    i.clean()
    assert not os.path.exists(thumbnail)
    assert os.path.exists(i.thumbnail)
Exemple #9
0
def test_nifti_nonnifti():
    """image is not a NIfTI-1 file"""
    i = ndar.Image('test_data/NDAR_INVZU049GXV_image03_1326225820791.zip')
    nifti_1_file = i.nifti_1
    assert os.path.exists(nifti_1_file)
    i.clean()
    assert not os.path.exists(nifti_1_file)
    assert os.path.exists(i.nifti_1)
Exemple #10
0
def test_nifti_nifti():
    """image is already a NIfTI-1 file"""
    i = ndar.Image('test_data/06025B_mprage.nii.gz')
    nifti_1_file = i.nifti_1
    assert os.path.exists(nifti_1_file)
    i.clean()
    assert not os.path.exists(nifti_1_file)
    assert os.path.exists(i.nifti_1)
Exemple #11
0
def test_brik():
    i = ndar.Image('test_data/NDAR_INVZU049GXV_image03_1326225820791.zip')
    assert i.files['AFNI'] == ['20783.spgr_at+tlrc']
    for (k, v) in i.files.iteritems():
        if k != 'AFNI':
            assert not v
    assert os.path.exists(i.path(i.files['AFNI'][0] + '.HEAD'))
    assert os.path.exists(i.path(i.files['AFNI'][0] + '.BRIK'))
    assert not os.path.exists(i.path(i.files['AFNI'][0]))
def test_nifti_mcfail():
    """mri_convert failure (by way of a bad image)"""
    im = ndar.Image('test_data/bogus.mnc')
    nose.tools.assert_raises(AttributeError, lambda: im.nifti_1)
def test_nifti_nonnifti():
    """image is not a NIfTI-1 file"""
    im = ndar.Image('test_data/NDAR_INVZU049GXV_image03_1326225820791.zip')
    assert os.path.exists(im.nifti_1)
def test_nifti_unzipped_nifti():
    """image is already an uncompressed NIfTI-1 file"""
    im = ndar.Image('test_data/a.nii')
    assert im.nifti_1 == im.path(im.files['NIfTI-1'][0])
Exemple #15
0
def test_afni_dicom():
    """image is DICOM"""
    im = ndar.Image('test_data/s1615890.zip')
    assert os.path.exists('%s.BRIK' % im.afni)
    assert os.path.exists('%s.HEAD' % im.afni)
Exemple #16
0
def test_afni_minc():
    """image is a MINC file"""
    im = ndar.Image('test_data/a.mnc')
    assert os.path.exists('%s.BRIK' % im.afni)
    assert os.path.exists('%s.HEAD' % im.afni)
def test_thumbnail_slicerfail():
    """slicer failure (by way of a bad image)"""
    im = ndar.Image('test_data/bogus.nii.gz')
    nose.tools.assert_raises(AttributeError, lambda: im.thumbnail)
def test_nifti_nifti():
    """image is already a NIfTI-1 file"""
    im = ndar.Image('test_data/06025B_mprage.nii.gz')
    assert im.nifti_1 == im.path(im.files['NIfTI-1'][0])
Exemple #19
0
def test_afni_fail():
    """conversion failure (by way of a bad image)"""
    im = ndar.Image('test_data/bogus.mnc')
    nose.tools.assert_raises(AttributeError, lambda: im.afni)
Exemple #20
0
def test_tempdir_remove():
    i = ndar.Image('test_data/06025B_mprage.nii.gz')
    tempdir = i._tempdir
    del i
    assert not os.path.exists(tempdir)
def test_nrrd_dicom():
    """image is DICOM"""
    im = ndar.Image('test_data/s1615890.zip')
    assert os.path.exists(im.nrrd)
Exemple #22
0
def test_bad_file():
    nose.tools.assert_raises(
        Exception, lambda: ndar.Image('test_data/bogus', check_existence=True))
    i = ndar.Image('test_data/bogus')
    assert not i.exists()
    nose.tools.assert_raises(Exception, lambda: i.files)
def test_nifti_nifti_gz():
    """image is a gzipped NIfTI-1 file"""
    im = ndar.Image('test_data/06025B_mprage.nii.gz')
    assert im.nifti_1_gz == im.path(im.files['NIfTI-1'][0])
Exemple #24
0
def test_afni_afni():
    """image is already an AFNI file"""
    im = ndar.Image('test_data/NDAR_INVZU049GXV_image03_1326225820791.zip')
    assert im.afni == im.path(im.files['AFNI'][0])
def test_nifti_unzipped_nifti_gz():
    """image is an unzipped NIfTI-1 file"""
    im = ndar.Image('test_data/a.nii')
    assert im.nifti_1_gz != im.path(im.files['NIfTI-1'][0])
    assert im.nifti_1_gz.endswith('.nii.gz')
    assert os.path.exists(im.nifti_1_gz)
Exemple #26
0
def test_afni_nifti():
    """image is a NIfTI-1 file"""
    im = ndar.Image('test_data/06025B_mprage.nii.gz')
    assert os.path.exists('%s.BRIK' % im.afni)
    assert os.path.exists('%s.HEAD' % im.afni)
def test_nrrd_nrrd():
    """image is already a NRRD file"""
    im = ndar.Image('test_data/002-12AU_t1w.nrrd')
    assert im.nrrd == im.path(im.files['NRRD'][0])
def test_thumbnail():
    im = ndar.Image('test_data/06025B_mprage.nii.gz')
    assert os.path.exists(im.thumbnail)
def test_nrrd_nonvolume():
    """image is not a volume"""
    im = ndar.Image('test_data/10_425-02_li1_146.png')
    nose.tools.assert_raises(AttributeError, lambda: im.nrrd)
def test_no_attributes():
    im = ndar.Image('test_data/s1615890.zip')
    nose.tools.assert_raises(AttributeError, lambda: im.acquisition_matrix)