Purpose

The ImageFileCache macro can be used to buffer an image in a cache file on the hard disk (e.g. in the temp directory). This makes it possible to simply replace memory consuming MemCache modules with the ImageCache macro.

Usage

Connect an input image. Select the required update mode. The cached picture is available on the output connector.

Details

The cache files are stored in the directory provided by MLAB.getTmpDir() and are named “cache” + uniquenumber + ext (ext = “.dcm” or “.tif”). Beside using files, there is one difference to the behavior of MemoryCache: a new file is created once the cache is updated and the old file is deleted. This makes it possible to use ImageFileCache in loops that incrementally change.

When clear is pressed, the module is deleted, the network closed, or MeVisLab is normally terminated, the current cache file is automatically deleted from the disk.

Windows

Default Panel

../../../Modules/Macros/FileHandling/mhelp/Images/Screenshots/ImageFileCache._default.png

Input Fields

input0

name: input0, type: Image

Input image

Output Fields

output0

name: output0, type: Image

Output cached or bypassed image

Parameter Fields

Visible Fields

Cache file is valid

name: cacheValid, type: Bool, persistent: no

Indicates if the current cache file is valid (output only)

Output is valid

name: outputValid, type: Bool, persistent: no, deprecated name: valid

Indicates if the current output is valid (output only)

Cache Update Mode

name: updateMode, type: Enum, default: AutoUpdate

Select if you want to automatically or manually update the cache or to invalidate the cache once the input image has changed (default: auto).

Values:

Title Name
Off Off
Auto Update AutoUpdate
Auto Clear AutoClear

Clear

name: clear, type: Trigger

Allows manual triggering of cache file clear.

Enable output

name: enableOutput, type: Bool, default: TRUE

If disabled, the output is invalidated independent from the cache content or the bypass setting (default: on).

Update

name: update, type: Trigger

Allows manual triggering of cache file update.

Bypass cache

name: bypass, type: Bool, default: FALSE

If enabled, the input is directly relayed to the output, bypassing a possibly existing cache file (default: off).

Duration

name: duration, type: Float, persistent: no

Time required for caching (output only)

Overwrite existing files

name: overwrite, type: Bool, default: FALSE

If enabled, the cache file name is not modified when a file already exists. It is still possible to use the module in a loop (as long as the file is not locked by another module or application), since internally, a temp file will be created in the same directory first before deleting the old file and renaming the temp file to the desired file name (default: off).

Create renamed file on failed overwrite

name: createNewFileIfOverwriteFailed, type: Bool, default: FALSE

If ‘overwrite’ is on and the target file already exists, but cannot be overwritten for whatever reason (possibly because the file is locked), the cache update fails if this flag is disabled. If this flag is enabled, the module falls back to non-overwrite mode and saves the cache file under some unique name (default: off).

Create if necessary

name: createNewDirIfNotExisting, type: Bool, default: TRUE

Create new directory if not previously existing. Note that the created directory will not be removed on ‘clear cache’. If not checked and the custom path is invalid, the default temp directory is selected.

Use custom directory

name: useCustomPath, type: Bool, default: FALSE

Enable to use a user-defined path for the cache file storage. If disabled, the user’s system temp directory is used (default: off).

Custom Path

name: customPath, type: String

User-defined path for the cache file storage (used if Use custom directory is enabled)

Use custom name

name: useCustomName, type: Bool, default: FALSE

Enable to use a user-defined name for the cache file. If disabled, ‘cache’ is used (default: off).

Custom Name

name: customName, type: String, default: cache

User-defined name for the cache file (used if Use custom name is enabled)

File Name

name: fileName, type: String, persistent: no

The cache file’s filename and path. Depends on the path/filename settings. (output only)

Hidden Fields

progress

name: progress, type: Float, persistent: no

Shows the progress of the buffering.

autoDeleteCacheFile

name: autoDeleteCacheFile, type: Bool, default: TRUE

Auto-delete cache file on clear (and on destruction). Usually not disabled since this changes the behavior from a ‘cache’ to a ‘save’ module.

forceDeleteCacheFile

name: forceDeleteCacheFile, type: Trigger

Deletes the cache file even if autoDeleteCacheFile is disabled.