Ejemplo n.º 1
0
    def test_diffusion_images(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            results = convert_ge.dicom_to_nifti(
                read_dicom_directory(test_data.GE_DTI), None)
            self.assertTrue(results.get('NII_FILE') is None)
            self.assertTrue(
                isinstance(results['NII'], nibabel.nifti1.Nifti1Image))
            self.assertTrue(results.get('BVAL_FILE') is None)
            self.assertTrue(isinstance(results['BVAL'], numpy.ndarray))
            self.assertTrue(results.get('BVEC_FILE') is None)
            self.assertTrue(isinstance(results['BVEC'], numpy.ndarray))

            results = convert_ge.dicom_to_nifti(
                read_dicom_directory(test_data.GE_DTI),
                os.path.join(tmp_output_dir, 'test.nii.gz'))
            assert_compare_nifti(results['NII_FILE'],
                                 ground_thruth_filenames(test_data.GE_DTI)[0])
            self.assertTrue(
                isinstance(results['NII'], nibabel.nifti1.Nifti1Image))
            assert_compare_bval(results['BVAL_FILE'],
                                ground_thruth_filenames(test_data.GE_DTI)[2])
            self.assertTrue(isinstance(results['BVAL'], numpy.ndarray))
            assert_compare_bval(results['BVEC_FILE'],
                                ground_thruth_filenames(test_data.GE_DTI)[3])
            self.assertTrue(isinstance(results['BVEC'], numpy.ndarray))

            convert_ge.dicom_to_nifti(
                read_dicom_directory(test_data.GE_DTI_IMPLICIT),
                os.path.join(tmp_output_dir, 'test.nii.gz'))
            assert_compare_nifti(
                results['NII_FILE'],
                ground_thruth_filenames(test_data.GE_DTI_IMPLICIT)[0])
            self.assertTrue(
                isinstance(results['NII'], nibabel.nifti1.Nifti1Image))
            assert_compare_bval(
                results['BVAL_FILE'],
                ground_thruth_filenames(test_data.GE_DTI_IMPLICIT)[2])
            self.assertTrue(isinstance(results['BVAL'], numpy.ndarray))
            assert_compare_bval(
                results['BVEC_FILE'],
                ground_thruth_filenames(test_data.GE_DTI_IMPLICIT)[3])
            self.assertTrue(isinstance(results['BVEC'], numpy.ndarray))
        finally:
            shutil.rmtree(tmp_output_dir)
Ejemplo n.º 2
0
    def test_diffusion_images(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            results = convert_ge.dicom_to_nifti(read_dicom_directory(test_data.GE_DTI),
                                                None)
            self.assertTrue(results.get('NII_FILE') is None)
            self.assertTrue(isinstance(results['NII'], nibabel.nifti1.Nifti1Image))
            self.assertTrue(results.get('BVAL_FILE') is None)
            self.assertTrue(isinstance(results['BVAL'], numpy.ndarray))
            self.assertTrue(results.get('BVEC_FILE') is None)
            self.assertTrue(isinstance(results['BVEC'], numpy.ndarray))

            results = convert_ge.dicom_to_nifti(read_dicom_directory(test_data.GE_DTI),
                                                os.path.join(tmp_output_dir, 'test.nii.gz'))
            assert_compare_nifti(results['NII_FILE'],
                                        ground_thruth_filenames(test_data.GE_DTI)[0])
            self.assertTrue(isinstance(results['NII'], nibabel.nifti1.Nifti1Image))
            assert_compare_bval(results['BVAL_FILE'],
                                       ground_thruth_filenames(test_data.GE_DTI)[2])
            self.assertTrue(isinstance(results['BVAL'], numpy.ndarray))
            assert_compare_bval(results['BVEC_FILE'],
                                       ground_thruth_filenames(test_data.GE_DTI)[3])
            self.assertTrue(isinstance(results['BVEC'], numpy.ndarray))

            convert_ge.dicom_to_nifti(read_dicom_directory(test_data.GE_DTI_IMPLICIT),
                                      os.path.join(tmp_output_dir, 'test.nii.gz'))
            assert_compare_nifti(results['NII_FILE'],
                                        ground_thruth_filenames(test_data.GE_DTI_IMPLICIT)[0])
            self.assertTrue(isinstance(results['NII'], nibabel.nifti1.Nifti1Image))
            assert_compare_bval(results['BVAL_FILE'],
                                       ground_thruth_filenames(test_data.GE_DTI_IMPLICIT)[2])
            self.assertTrue(isinstance(results['BVAL'], numpy.ndarray))
            assert_compare_bval(results['BVEC_FILE'],
                                       ground_thruth_filenames(test_data.GE_DTI_IMPLICIT)[3])
            self.assertTrue(isinstance(results['BVEC'], numpy.ndarray))
        finally:
            shutil.rmtree(tmp_output_dir)