dbdicom.Record.clear#

Record.clear()[source]#

Clear the record from memory.

This will write the record to disk and clear it from memory. After this step, subsequent calculations will be performed from disk.

Note

If the record does not exist in memory, or if its database does not have a path on disk associated, read() does nothing.

See also

read()

Example

As an example, we can verify that editing data in memory is faster than on disk. We’ll need the time package and a large series in memory. We also provide a path to a directory for writing data:

>>> from time import time
>>> series = db.zeros((20,20,256,256))
>>> series.database().set_path(path)

Now measure the time it takes to set the slice locations to a constant value:

>>> t=time(); series.SliceLocation=1; print(time()-t)
1.9060208797454834

Since the series was created in memory, this is editing in memory. Now we clear the series from memory and perform the same computation:

>>> series.clear()
>>> t=time(); series.SliceLocation=1; print(time()-t)
17.933974981307983

The computation is now run from disk and is 10 times slower because of the need to read and write the files.