dbdicom.Record.load#

Record.load()[source]#

Load the record into memory.

After loading the record into memory, all subsequent changes will be made in memory only. Call clear() to write any changes to disk and remove it from memory.

Note

If the record already exists in memory, read() does nothing. This is to avoid that any changes made after reading are overwritten.

See also

clear()

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 on disk:

>>> from time import time
>>> path = 'path\to\empty\folder'
>>> series = db.zeros((20,20,256,256), in_database=db.database(path))

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

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

Since the series was created on disk, this is editing on disk. Now load the series into memory and perform the same steps:

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

On the machine where this was executed, the same computation runs more than 10 times faster in memory.