import os
import warnings
from tempfile import mkstemp

import numpy as np

from nipy.testing import assert_true, assert_equal, assert_raises, \
    assert_array_equal, assert_array_almost_equal, funcfile, parametric

from nipy.testing.decorators import if_templates

from nipy.utils import templates, DataError

from nipy.io.api import load_image, save_image, as_image
from nipy.core.api import fromarray


gfilename = ''
gtmpfile = None
gimg = None


def load_template_img():
    return load_image(
        templates.get_filename(
            'ICBM152', '2mm', 'T1.nii.gz'))


def setup_module():
    warnings.simplefilter("ignore")
    global gfilename, gtmpfile, gimg
    try:
        gimg = load_template_img()
    except DataError:
        pass
    fd, gfilename = mkstemp(suffix='.nii.gz')
    gtmpfile = open(gfilename)


def teardown_module():