def open_volume_file(filepath):
<EOL>if not op.exists(filepath):<EOL><INDENT>raise IOError('<STR_LIT>'.format(filepath))<EOL><DEDENT>def open_nifti_file(filepath):<EOL><INDENT>return NiftiImage(filepath)<EOL><DEDENT>def open_mhd_file(filepath):<EOL><INDENT>return MedicalImage(filepath)<EOL>vol_data, hdr_data = load_raw_data_with_mhd(filepath)<EOL>return vol_data, hdr_data<EOL><DEDENT>def open_mha_file(filepath):<EOL><INDENT>raise NotImplementedError('<STR_LIT>')<EOL><DEDENT>def _load_file(filepath, loader):<EOL><INDENT>return loader(filepath)<EOL><DEDENT>filext_loader = {<EOL>'<STR_LIT>': open_nifti_file,<EOL>'<STR_LIT>': open_mhd_file,<EOL>'<STR_LIT>': open_mha_file,<EOL>}<EOL>ext = get_extension(filepath)<EOL>loader = None<EOL>for e in filext_loader:<EOL><INDENT>if ext in e:<EOL><INDENT>loader = filext_loader[e]<EOL><DEDENT><DEDENT>if loader is None:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(filepath))<EOL><DEDENT>return _load_file(filepath, loader)<EOL>
Open a volumetric file using the tools following the file extension.

    Parameters
    ----------
    filepath: str
        Path to a volume file

    Returns
    -------
    volume_data: np.ndarray
        Volume data

    pixdim: 1xN np.ndarray
        Vector with the description of the voxels physical size (usually in mm) for each volume dimension.

    Raises
    ------
    IOError
        In case the file is not found.