Create a functional data object for the given file. Expects the file
        to be a valid functional data file. Expects exactly one file that has
        suffix mgh/mgz or nii/nii.gz.

        Parameters
        ----------
        filename : string
            Name of the (uploaded) file
        read_only : boolean, optional
            Optional value for the read-only property

        Returns
        -------
        FunctionalDataHandle
            Handle for created functional data object in database

def create_object(self, filename, read_only=False):
        """Create a functional data object for the given file. Expects the file
        to be a valid functional data file. Expects exactly one file that has
        suffix mgh/mgz or nii/nii.gz.

        Parameters
        ----------
        filename : string
            Name of the (uploaded) file
        read_only : boolean, optional
            Optional value for the read-only property

        Returns
        -------
        FunctionalDataHandle
            Handle for created functional data object in database
        """
        # Get the file name, i.e., last component of the given absolute path
        prop_name = os.path.basename(os.path.normpath(filename))
        # Ensure that the uploaded file has a valid suffix. Currently no tests
        # are performed to ensure that the file actually conatains any data.
        if prop_name.endswith('.nii.gz') or prop_name.endswith('.mgz') or prop_name.endswith('.mgh.gz'):
            prop_mime = 'application/x-gzip'
        elif prop_name.endswith('.nii'):
            prop_mime = 'application/NIfTI-1'
        elif prop_name.endswith('.mgh'):
            prop_mime = 'application/MGH'
        else:
            raise ValueError('unsupported file type: ' + prop_name)
        # Create a new object identifier.
        identifier = str(uuid.uuid4()).replace('-','')
        # The object directory is given by the object identifier.
        object_dir = os.path.join(self.directory, identifier)
        # Create (sub-)directories for the uploaded and extracted data files.
        if not os.access(object_dir, os.F_OK):
            os.makedirs(object_dir)
        data_dir = os.path.join(object_dir, DATA_DIRECTORY)
        os.mkdir(data_dir)
        func_data_file = prop_name
        uploaded_file = os.path.join(data_dir, prop_name)
        shutil.copyfile(filename, uploaded_file)
        # Create the initial set of properties for the new image object.
        properties = {
            datastore.PROPERTY_NAME: prop_name,
            datastore.PROPERTY_FILENAME : prop_name,
            datastore.PROPERTY_FILESIZE : os.path.getsize(uploaded_file),
            datastore.PROPERTY_MIMETYPE : prop_mime,
            datastore.PROPERTY_FUNCDATAFILE : func_data_file
        }
        if read_only:
            properties[datastore.PROPERTY_READONLY] = True
        # Create object handle and store it in database before returning it
        obj = FunctionalDataHandle(
            identifier,
            properties,
            object_dir
        )
        self.insert_object(obj)
        return obj