def Write3DData(self, data3d, path, filetype='auto', metadata=None, progress_callback=None, sfin=True):
        """
        :param data3d: input ndarray data
        :param path: output path, to specify slice number advanced formatting options (like {:06d}) can be used
        Check function filename_format() for more details.
        :param metadata: {'voxelsize_mm': [1, 1, 1]}
        :param filetype: dcm, vtk, rawiv, image_stack
        :param progress_callback: fuction for progressbar f.e. callback(value, minimum, maximum)
        :param sfin: Use separate file for segmentation if necessary


        """

        self.orig_path = path
        path = os.path.expanduser(path)

        try:
            d3d = data3d.pop('data3d')
            metadata = data3d
            data3d = d3d
        except:
            pass

        if progress_callback is not None:
            self.progress_callback = progress_callback

        if filetype == 'auto':
            startpath, ext = os.path.splitext(path)
            filetype = ext[1:].lower()

        segmentation = None
        if metadata is not None and "segmentation" in metadata.keys():
            segmentation_path = self.__get_segmentation_path(path)
            segmentation = metadata["segmentation"]



        mtd = {'voxelsize_mm': [1, 1, 1]}
        if metadata is not None:
            mtd.update(metadata)
        metadata=mtd

        if path.find('{') >= 0:
            filetype = 'image_stack'
            # one_file_per_slice = True

    #     if one_file_per_slice:
    #         self._one_file_per_slice(self, data3d, path, filetype, metadata)
    #     else:
    #         self._all_in_one_file(self, data3d, path, filetype, metadata)
    #
    # def _all_in_one_file(self, data3d, path, filetype, metadata):

        if filetype in ['vtk', 'tiff', 'tif', "mhd", "nii", "raw"]:
            self._write_with_sitk(path, data3d, metadata)
            if sfin and segmentation is not None:
                self._write_with_sitk(segmentation_path, segmentation, metadata)
        elif filetype in ['dcm', 'DCM', 'dicom']:
            self._write_with_sitk(path, data3d, metadata)
            self._fix_sitk_bug(path, metadata)
            if sfin and segmentation is not None:
                self._write_with_sitk(segmentation_path, segmentation, metadata)
                self._fix_sitk_bug(segmentation_path, metadata)
        elif filetype in ['rawiv']:
            rawN.write(path, data3d, metadata)
        elif filetype in ['image_stack']:
            self.save_image_stack(data3d, path, metadata)
        elif filetype in ['hdf5', 'hdf', 'h5', 'he5']:
            self.save_hdf5(data3d, path, metadata)
        elif filetype in ['pkl', 'pklz']:
            from . import misc
            metadata['data3d'] = data3d
            datap = metadata

            misc.obj_to_file(datap, path)

        else:
            logger.error('Unknown filetype: "' + filetype + '"')
            raise ValueError("Unknown filetype: '" + filetype + "'")
:param data3d: input ndarray data
        :param path: output path, to specify slice number advanced formatting options (like {:06d}) can be used
        Check function filename_format() for more details.
        :param metadata: {'voxelsize_mm': [1, 1, 1]}
        :param filetype: dcm, vtk, rawiv, image_stack
        :param progress_callback: fuction for progressbar f.e. callback(value, minimum, maximum)
        :param sfin: Use separate file for segmentation if necessary