def save_in_hdf5(self, hdf5_group):
        """
        Saves the configuration group in the given hdf5_group.
        :type hdf5_group: h5py.Group
        """

        f = hdf5_group
        # save general information
        general_information = f.create_group('general_information')
        # integration parameters:
        general_information.attrs['integration_unit'] = self.integration_unit
        if self.integration_rad_points:
            general_information.attrs['integration_num_points'] = self.integration_rad_points
        else:
            general_information.attrs['integration_num_points'] = 0

        # cake parameters:
        general_information.attrs['auto_integrate_cake'] = self.auto_integrate_cake
        general_information.attrs['cake_azimuth_points'] = self.cake_azimuth_points
        if self.cake_azimuth_range is None:
            general_information.attrs['cake_azimuth_range'] = "None"
        else:
            general_information.attrs['cake_azimuth_range'] = self.cake_azimuth_range

        # mask parameters
        general_information.attrs['use_mask'] = self.use_mask
        general_information.attrs['transparent_mask'] = self.transparent_mask

        # auto save parameters
        general_information.attrs['auto_save_integrated_pattern'] = self.auto_save_integrated_pattern
        formats = [n.encode('ascii', 'ignore') for n in self.integrated_patterns_file_formats]
        general_information.create_dataset('integrated_patterns_file_formats', (len(formats), 1), 'S10', formats)

        # save working directories
        working_directories_gp = f.create_group('working_directories')
        try:
            for key in self.working_directories:
                working_directories_gp.attrs[key] = self.working_directories[key]
        except TypeError:
            self.working_directories = {'calibration': '', 'mask': '', 'image': '', 'pattern': '', 'overlay': '',
                                        'phase': '', 'batch': ''}
            for key in self.working_directories:
                working_directories_gp.attrs[key] = self.working_directories[key]

        # save image model
        image_group = f.create_group('image_model')
        image_group.attrs['auto_process'] = self.img_model.autoprocess
        image_group.attrs['factor'] = self.img_model.factor
        image_group.attrs['has_background'] = self.img_model.has_background()
        image_group.attrs['background_filename'] = self.img_model.background_filename
        image_group.attrs['background_offset'] = self.img_model.background_offset
        image_group.attrs['background_scaling'] = self.img_model.background_scaling
        if self.img_model.has_background():
            background_data = self.img_model.untransformed_background_data
            image_group.create_dataset('background_data', background_data.shape, 'f', background_data)

        image_group.attrs['series_max'] = self.img_model.series_max
        image_group.attrs['series_pos'] = self.img_model.series_pos

        # image corrections
        corrections_group = image_group.create_group('corrections')
        corrections_group.attrs['has_corrections'] = self.img_model.has_corrections()
        for correction, correction_object in self.img_model.img_corrections.corrections.items():
            if correction in ['cbn', 'oiadac']:
                correction_data = correction_object.get_data()
                imcd = corrections_group.create_dataset(correction, correction_data.shape, 'f', correction_data)
                for param, value in correction_object.get_params().items():
                    imcd.attrs[param] = value
            elif correction == 'transfer':
                params = correction_object.get_params()
                transfer_group = corrections_group.create_group('transfer')
                original_data = params['original_data']
                response_data = params['response_data']
                original_ds = transfer_group.create_dataset('original_data', original_data.shape, 'f', original_data)
                original_ds.attrs['filename'] = params['original_filename']
                response_ds = transfer_group.create_dataset('response_data', response_data.shape, 'f', response_data)
                response_ds.attrs['filename'] = params['response_filename']

        # the actual image
        image_group.attrs['filename'] = self.img_model.filename
        current_raw_image = self.img_model.untransformed_raw_img_data

        raw_image_data = image_group.create_dataset('raw_image_data', current_raw_image.shape, dtype='f')
        raw_image_data[...] = current_raw_image

        # image transformations
        transformations_group = image_group.create_group('image_transformations')
        for ind, transformation in enumerate(self.img_model.get_transformations_string_list()):
            transformations_group.attrs[str(ind)] = transformation

        # save roi data
        if self.roi is not None:
            image_group.attrs['has_roi'] = True
            image_group.create_dataset('roi', (4,), 'i8', tuple(self.roi))
        else:
            image_group.attrs['has_roi'] = False

        # save mask model
        mask_group = f.create_group('mask')
        current_mask = self.mask_model.get_mask()
        mask_data = mask_group.create_dataset('data', current_mask.shape, dtype=bool)
        mask_data[...] = current_mask

        # save detector information
        detector_group = f.create_group('detector')
        detector_mode = self.calibration_model.detector_mode
        detector_group.attrs['detector_mode'] = detector_mode.value
        if detector_mode == DetectorModes.PREDEFINED:
            detector_group.attrs['detector_name'] = self.calibration_model.detector.name
        elif detector_mode == DetectorModes.NEXUS:
            detector_group.attrs['nexus_filename'] =self.calibration_model.detector.filename

        # save calibration model
        calibration_group = f.create_group('calibration_model')
        calibration_filename = self.calibration_model.filename
        if calibration_filename.endswith('.poni'):
            base_filename, ext = self.calibration_model.filename.rsplit('.', 1)
        else:
            base_filename = self.calibration_model.filename
            ext = 'poni'
        calibration_group.attrs['calibration_filename'] = base_filename + '.' + ext
        pyfai_param, fit2d_param = self.calibration_model.get_calibration_parameter()
        pfp = calibration_group.create_group('pyfai_parameters')
        for key in pyfai_param:
            try:
                pfp.attrs[key] = pyfai_param[key]
            except TypeError:
                pfp.attrs[key] = ''
        calibration_group.attrs['correct_solid_angle'] = self.correct_solid_angle
        if self.calibration_model.distortion_spline_filename is not None:
            calibration_group.attrs['distortion_spline_filename'] = self.calibration_model.distortion_spline_filename

        # save background pattern and pattern model
        background_pattern_group = f.create_group('background_pattern')
        try:
            background_pattern_x = self.pattern_model.background_pattern.original_x
            background_pattern_y = self.pattern_model.background_pattern.original_y
        except (TypeError, AttributeError):
            background_pattern_x = None
            background_pattern_y = None
        if background_pattern_x is not None and background_pattern_y is not None:
            background_pattern_group.attrs['has_background_pattern'] = True
            bgx = background_pattern_group.create_dataset('x', background_pattern_x.shape, dtype='f')
            bgy = background_pattern_group.create_dataset('y', background_pattern_y.shape, dtype='f')
            bgx[...] = background_pattern_x
            bgy[...] = background_pattern_y
        else:
            background_pattern_group.attrs['has_background_pattern'] = False

        pattern_group = f.create_group('pattern')
        try:
            pattern_x = self.pattern_model.pattern.original_x
            pattern_y = self.pattern_model.pattern.original_y
        except (TypeError, AttributeError):
            pattern_x = None
            pattern_y = None
        if pattern_x is not None and pattern_y is not None:
            px = pattern_group.create_dataset('x', pattern_x.shape, dtype='f')
            py = pattern_group.create_dataset('y', pattern_y.shape, dtype='f')
            px[...] = pattern_x
            py[...] = pattern_y
        pattern_group.attrs['pattern_filename'] = self.pattern_model.pattern_filename
        pattern_group.attrs['unit'] = self.pattern_model.unit
        pattern_group.attrs['file_iteration_mode'] = self.pattern_model.file_iteration_mode
        if self.pattern_model.pattern.auto_background_subtraction:
            pattern_group.attrs['auto_background_subtraction'] = True
            auto_background_group = pattern_group.create_group('auto_background_settings')
            auto_background_group.attrs['smoothing'] = \
                self.pattern_model.pattern.auto_background_subtraction_parameters[0]
            auto_background_group.attrs['iterations'] = \
                self.pattern_model.pattern.auto_background_subtraction_parameters[1]
            auto_background_group.attrs['poly_order'] = \
                self.pattern_model.pattern.auto_background_subtraction_parameters[2]
            auto_background_group.attrs['x_start'] = self.pattern_model.pattern.auto_background_subtraction_roi[0]
            auto_background_group.attrs['x_end'] = self.pattern_model.pattern.auto_background_subtraction_roi[1]
        else:
            pattern_group.attrs['auto_background_subtraction'] = False