Commit f2ec69c3 authored by Mo Shahdloo's avatar Mo Shahdloo
Browse files

read tests

parent cdc65f23
......@@ -8,8 +8,8 @@ import numpy as np
from core import mapVBVD
test_data_vb_broken = op.join(op.dirname(__file__), 'test_data', 'meas_MID111_sLaser_broken_FID4873.dat')
test_data_gre = op.join(op.dirname(__file__), 'test_data', 'meas_MID00058_FID12358_gre_3D.dat')
test_data_epi = op.join(op.dirname(__file__), 'test_data', 'meas_MID00053_FID12353_ep2d_QA_2mm_15ch_inplane_Grappa2_100.dat')
test_data_gre = op.join(op.dirname(__file__), 'test_data', 'meas_MID00255_FID12798_GRE_surf.dat')
test_data_epi = op.join(op.dirname(__file__), 'test_data', 'meas_MID00265_FID12808_FMRI.dat')
def test_flagRemoveOS():
......@@ -30,17 +30,17 @@ def test_flagRemoveOS():
def test_flagIgnoreSeg_flagDoAverage():
twixObj = mapVBVD(test_data_epi, quiet=False)
twixObj[1].refscan_phasecor.flagIgnoreSeg = False
twixObj[1].refscan_phasecor.flagDoAverage = False
assert np.allclose(twixObj[1].refscan_phasecor.dataSize, [86, 15, 1, 1, 36, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1])
twixObj[1].refscan_phasecor.flagDoAverage = True
assert np.allclose(twixObj[1].refscan_phasecor.dataSize, [86, 15, 1, 1, 36, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1])
twixObj[1].refscanPC.flagIgnoreSeg = False
twixObj[1].refscanPC.flagDoAverage = False
assert np.allclose(twixObj[1].refscanPC.dataSize, [86, 15, 1, 1, 36, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1])
twixObj[1].refscanPC.flagDoAverage = True
assert np.allclose(twixObj[1].refscanPC.dataSize, [86, 15, 1, 1, 36, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1])
twixObj[1].refscan_phasecor.flagIgnoreSeg = True
twixObj[1].refscan_phasecor.flagDoAverage = False
assert np.allclose(twixObj[1].refscan_phasecor.dataSize, [86, 15, 1, 1, 36, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
twixObj[1].refscan_phasecor.flagDoAverage = True
assert np.allclose(twixObj[1].refscan_phasecor.dataSize, [86, 15, 1, 1, 36, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
twixObj[1].refscanPC.flagIgnoreSeg = True
twixObj[1].refscanPC.flagDoAverage = False
assert np.allclose(twixObj[1].refscanPC.dataSize, [86, 15, 1, 1, 36, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
twixObj[1].refscanPC.flagDoAverage = True
assert np.allclose(twixObj[1].refscanPC.dataSize, [86, 15, 1, 1, 36, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
def test_flagSkipToFirstLine():
......@@ -50,5 +50,3 @@ def test_flagSkipToFirstLine():
assert np.allclose(twixObj[1].refscan.dataSize, [86, 15, 55, 1, 36, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1])
twixObj[1].refscan.flagSkipToFirstLine = True
assert np.allclose(twixObj[1].refscan.dataSize, [86, 15, 24, 1, 36, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1])
test_flagIgnoreSeg_flagDoAverage()
\ No newline at end of file
"""
Created by shahdloo
23/09/2020
"""
import os.path as op
import numpy as np
from core import mapVBVD
import h5py
test_data_gre = op.join(op.dirname(__file__), 'test_data', 'meas_MID00255_FID12798_GRE_surf.dat')
test_data_gre_mat = op.join(op.dirname(__file__), 'test_data', 'meas_MID00255_FID12798_GRE_surf.mat')
test_data_epi = op.join(op.dirname(__file__), 'test_data', 'meas_MID00265_FID12808_FMRI.dat')
test_data_epi_mat = op.join(op.dirname(__file__), 'test_data', 'meas_MID00265_FID12808_FMRI.mat')
def test_gre():
twixObj = mapVBVD(test_data_gre, quiet=False)
twixObj[1].image.squeeze = True
twixObj[1].image.flagRemoveOS = False
img_py = twixObj[1].image[:, :, :, 0, 0, 0, :]
twixObj[1].image.flagRemoveOS = True
img_py_os = twixObj[1].image[:, :, :, 0, 0, 0, :]
with h5py.File(test_data_gre_mat, 'r') as f:
base = f['img'][0, 0, :, :, :]
img_mat = (base['real'] + 1j * base['imag']).transpose()
base = f['img_os'][0, 0, :, :, :]
img_mat_os = (base['real'] + 1j * base['imag']).transpose()
assert np.allclose(img_py, img_mat)
assert np.allclose(img_py_os, img_mat_os)
def test_epi():
twixObj = mapVBVD(test_data_epi, quiet=False)
twixObj[1].image.squeeze = True
twixObj[1].image.flagRampSampRegrid = False
twixObj[1].image.flagRemoveOS = False
img_py = twixObj[1].image[:, :, :, 0, 0, 0, 0, 0, 0, 0, 0, 0, :]
twixObj[1].image.flagRemoveOS = True
img_py_os = twixObj[1].image[:, :, :, 0, 0, 0, 0, 0, 0, 0, 0, 0, :]
twixObj[1].image.flagRampSampRegrid = True
img_py_os_rg = twixObj[1].image[:, :, :, 0, 0, 0, 0, 0, 0, 0, 0, 0, :]
with h5py.File(test_data_epi_mat, 'r') as f:
base = f['img'][0, 0, 0, 0, 0, 0, 0, 0, :, :, :]
img_mat = (base['real'] + 1j * base['imag']).transpose()
base = f['img_os'][0, 0, 0, 0, 0, 0, 0, 0, :, :, :]
img_mat_os = (base['real'] + 1j * base['imag']).transpose()
base = f['img_os_rg'][0, 0, 0, 0, 0, 0, 0, 0, :, :, :]
img_mat_os_rg = (base['real'] + 1j * base['imag']).transpose()
assert np.allclose(img_py, img_mat)
assert np.allclose(img_py_os, img_mat_os)
assert np.allclose(img_py_os_rg, img_mat_os_rg, atol=1e-6, rtol=1e-6)
......@@ -5,8 +5,6 @@ from core import mapVBVD
test_data_vb = op.join(op.dirname(__file__), 'test_data', 'meas_MID311_STEAM_wref1_FID115674.dat')
test_data_ve = op.join(op.dirname(__file__), 'test_data', 'meas_MID00305_FID74175_VOI_slaser_wref1.dat')
test_data_vb_broken = op.join(op.dirname(__file__), 'test_data', 'meas_MID111_sLaser_broken_FID4873.dat')
test_data_gre = op.join(op.dirname(__file__), 'test_data', 'meas_MID00058_FID12358_gre_3D.dat')
test_data_epi = op.join(op.dirname(__file__), 'test_data', 'meas_MID00053_FID12353_ep2d_QA_2mm_15ch_inplane_Grappa2_100.dat')
def test_vb():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment