def convert_dcm2nii(input_dir, output_dir, filename):
<EOL>if not op.exists(input_dir):<EOL><INDENT>raise IOError('<STR_LIT>'.format(input_dir))<EOL><DEDENT>if not op.exists(output_dir):<EOL><INDENT>raise IOError('<STR_LIT>'.format(output_dir))<EOL><DEDENT>tmpdir = tempfile.TemporaryDirectory(prefix='<STR_LIT>')<EOL>arguments = '<STR_LIT>'.format(tmpdir.name)<EOL>try:<EOL><INDENT>call_out = call_dcm2nii(input_dir, arguments)<EOL><DEDENT>except:<EOL><INDENT>raise<EOL><DEDENT>else:<EOL><INDENT>log.info('<STR_LIT>'.format(input_dir))<EOL>filenames  = glob(op.join(tmpdir.name, '<STR_LIT>'))<EOL>cleaned_filenames = remove_dcm2nii_underprocessed(filenames)<EOL>filepaths = []<EOL>for srcpath in cleaned_filenames:<EOL><INDENT>dstpath = op.join(output_dir, filename)<EOL>realpath = copy_w_plus(srcpath, dstpath)<EOL>filepaths.append(realpath)<EOL>basename = op.basename(remove_ext(srcpath))<EOL>aux_files = set(glob(op.join(tmpdir.name, '<STR_LIT>'     .format(basename)))) -set(glob(op.join(tmpdir.name, '<STR_LIT>'.format(basename))))<EOL>for aux_file in aux_files:<EOL><INDENT>aux_dstpath = copy_w_ext(aux_file, output_dir, remove_ext(op.basename(realpath)))<EOL>filepaths.append(aux_dstpath)<EOL><DEDENT><DEDENT>return filepaths<EOL><DEDENT>
Call MRICron's `dcm2nii` to convert the DICOM files inside `input_dir`
    to Nifti and save the Nifti file in `output_dir` with a `filename` prefix.

    Parameters
    ----------
    input_dir: str
        Path to the folder that contains the DICOM files

    output_dir: str
        Path to the folder where to save the NifTI file

    filename: str
        Output file basename

    Returns
    -------
    filepaths: list of str
        List of file paths created in `output_dir`.