![]() |
CTK
0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
|
#include <Libs/DICOM/Core/ctkDICOMDatabase.h>
Signals | |
void | databaseChanged () |
Indicates that an in-memory database has been updated. More... | |
void | instanceAdded (QString) |
void | patientAdded (int, QString, QString, QString) |
void | schemaUpdated () |
Indicates schema update finished. More... | |
void | schemaUpdateProgress (int) |
Indicates progress in updating schema (int is file number, string is file name) More... | |
void | schemaUpdateProgress (QString) |
void | schemaUpdateStarted (int) |
Indicates that the schema is about to be updated and how many files will be processed. More... | |
void | seriesAdded (QString) |
void | studyAdded (QString) |
Public Member Functions | |
Q_INVOKABLE QStringList | allFiles () |
Q_INVOKABLE QString | cachedTag (const QString sopInstanceUID, const QString tag) |
Return the value of a cached tag. More... | |
Q_INVOKABLE bool | cacheTag (const QString sopInstanceUID, const QString tag, const QString value) |
Insert an instance tag's value into to the cache. More... | |
Q_INVOKABLE bool | cacheTags (const QStringList sopInstanceUIDs, const QStringList tags, const QStringList values) |
Insert lists of tags into the cache as a batch query operation. More... | |
Q_INVOKABLE bool | cleanup () |
Q_INVOKABLE void | closeDatabase () |
close the database. It must not be used afterwards. More... | |
ctkDICOMDatabase (QObject *parent=0) | |
ctkDICOMDatabase (QString databaseFile) | |
const QSqlDatabase & | database () const |
const QString | databaseDirectory () const |
const QString | databaseFilename () const |
Q_INVOKABLE QString | descriptionForSeries (const QString seriesUID) |
Q_INVOKABLE QString | descriptionForStudy (const QString studyUID) |
Q_INVOKABLE QHash< QString, QString > | descriptionsForFile (QString fileName) |
Q_INVOKABLE bool | fileExistsAndUpToDate (const QString &filePath) |
Check if file is already in database and up-to-date. More... | |
Q_INVOKABLE QString | fileForInstance (const QString sopInstanceUID) |
Q_INVOKABLE QStringList | filesForSeries (const QString seriesUID) |
Q_INVOKABLE QString | fileValue (const QString fileName, const QString tag) |
Q_INVOKABLE QString | fileValue (const QString fileName, const unsigned short group, const unsigned short element) |
Q_INVOKABLE QString | groupElementToTag (const unsigned short &group, const unsigned short &element) |
Q_INVOKABLE QStringList | headerKeys () |
Q_INVOKABLE QString | headerValue (const QString key) |
Q_INVOKABLE bool | initializeDatabase (const char *schemaFile=":/dicom/dicom-schema.sql") |
delete all data and (re-)initialize the database. More... | |
Q_INVOKABLE bool | initializeTagCache () |
Create a tagCache in the current database. Delete the existing one if it exists. More... | |
Q_INVOKABLE void | insert (const ctkDICOMItem &ctkDataset, bool storeFile, bool generateThumbnail) |
Q_INVOKABLE void | insert (const QString &filePath, bool storeFile=true, bool generateThumbnail=true, bool createHierarchy=true, const QString &destinationDirectoryName=QString()) |
void | insert (DcmItem *item, bool storeFile=true, bool generateThumbnail=true) |
Q_INVOKABLE QDateTime | insertDateTimeForInstance (const QString fileName) |
Q_INVOKABLE QString | instanceForFile (const QString fileName) |
Q_INVOKABLE QStringList | instancesForSeries (const QString seriesUID) |
Q_INVOKABLE QString | instanceValue (const QString sopInstanceUID, const QString tag) |
access element values for given instance More... | |
Q_INVOKABLE QString | instanceValue (const QString sopInstanceUID, const unsigned short group, const unsigned short element) |
bool | isInMemory () const |
bool | isOpen () const |
const QString | lastError () const |
Q_INVOKABLE void | loadFileHeader (const QString fileName) |
Q_INVOKABLE void | loadInstanceHeader (const QString sopInstanceUID) |
load the header from a file and allow access to elements More... | |
Q_INVOKABLE QString | nameForPatient (const QString patientUID) |
virtual Q_INVOKABLE void | openDatabase (const QString databaseFile, const QString &connectionName="") |
Q_INVOKABLE QString | patientForStudy (QString studyUID) |
Q_INVOKABLE QStringList | patients () |
database accessors More... | |
Q_INVOKABLE void | prepareInsert () |
Q_INVOKABLE bool | removePatient (const QString &patientID) |
Q_INVOKABLE bool | removeSeries (const QString &seriesInstanceUID) |
Q_INVOKABLE bool | removeStudy (const QString &studyInstanceUID) |
Q_INVOKABLE QString | schemaVersion () |
returns the schema version needed by the current version of this code More... | |
Q_INVOKABLE QString | schemaVersionLoaded () |
Q_INVOKABLE QString | seriesForFile (QString fileName) |
Q_INVOKABLE QStringList | seriesForStudy (const QString studyUID) |
void | setTagsToPrecache (const QStringList tags) |
application-defined tags of interest This list of tags is added to the internal tag cache during import operations. The list should be prepared by the application as a hint to the database that these tags are likely to be accessed later. Internally, the database will cache the values of these tags so that subsequent calls to fileValue or instanceValue will be able to use the cache rather than re-reading the file. More... | |
Q_INVOKABLE void | setThumbnailGenerator (ctkDICOMAbstractThumbnailGenerator *generator) |
set thumbnail generator object More... | |
Q_INVOKABLE QStringList | studiesForPatient (const QString patientUID) |
Q_INVOKABLE QString | studyForSeries (QString seriesUID) |
Q_INVOKABLE bool | tagCacheExists () |
store values of previously requested instance elements These are meant to be internal methods used by the instanceValue and fileValue methods, but they can be used by calling classes to populate or access instance tag values as needed. More... | |
const QStringList | tagsToPrecache () |
Q_INVOKABLE bool | tagToGroupElement (const QString tag, unsigned short &group, unsigned short &element) |
Q_INVOKABLE ctkDICOMAbstractThumbnailGenerator * | thumbnailGenerator () |
get thumbnail genrator object More... | |
Q_INVOKABLE bool | updateSchema (const char *schemaFile=":/dicom/dicom-schema.sql") |
updates the database schema and reinserts all existing files More... | |
Q_INVOKABLE bool | updateSchemaIfNeeded (const char *schemaFile=":/dicom/dicom-schema.sql") |
virtual | ~ctkDICOMDatabase () |
Protected Attributes | |
QScopedPointer< ctkDICOMDatabasePrivate > | d_ptr |
Properties | |
QString | databaseDirectory |
QString | databaseFilename |
bool | isInMemory |
bool | isOpen |
QString | lastError |
QStringList | tagsToPrecache |
Class handling a database of DICOM objects. So far, an underlying SQLITE database is used for that. Usually, added DICOM objects are also stored within the file system. The SQLITE database file can be specified by the user. SQLITE (and this class) also support a special in memory mode, where no database file is created but the database is completely kept in memory (and after exiting the program, vanishes). If in "memory mode", the objects are not written to disk, otherwise they are stored in a subdirectory of the SQLITE database file directory called "dicom". Inside, a folder structure created which contains a directoy for each study, containing a directory for each series, containing a file for each object. The corresponding UIDs are used as filenames. Thumbnais for each image can be created; if so, they are stored in a directory parallel to "dicom" directory called "thumbs".
Definition at line 52 of file ctkDICOMDatabase.h.
|
explicit |
|
explicit |
|
virtual |
Q_INVOKABLE QStringList ctkDICOMDatabase::allFiles | ( | ) |
Q_INVOKABLE QString ctkDICOMDatabase::cachedTag | ( | const QString | sopInstanceUID, |
const QString | tag | ||
) |
Return the value of a cached tag.
Q_INVOKABLE bool ctkDICOMDatabase::cacheTag | ( | const QString | sopInstanceUID, |
const QString | tag, | ||
const QString | value | ||
) |
Insert an instance tag's value into to the cache.
Q_INVOKABLE bool ctkDICOMDatabase::cacheTags | ( | const QStringList | sopInstanceUIDs, |
const QStringList | tags, | ||
const QStringList | values | ||
) |
Insert lists of tags into the cache as a batch query operation.
Q_INVOKABLE bool ctkDICOMDatabase::cleanup | ( | ) |
Q_INVOKABLE void ctkDICOMDatabase::closeDatabase | ( | ) |
close the database. It must not be used afterwards.
const QSqlDatabase& ctkDICOMDatabase::database | ( | ) | const |
|
signal |
Indicates that an in-memory database has been updated.
const QString ctkDICOMDatabase::databaseDirectory | ( | ) | const |
Returns the absolute path of the database directory (where the database file resides in) in OS-prefered path format.
const QString ctkDICOMDatabase::databaseFilename | ( | ) | const |
Q_INVOKABLE QString ctkDICOMDatabase::descriptionForSeries | ( | const QString | seriesUID | ) |
Q_INVOKABLE QString ctkDICOMDatabase::descriptionForStudy | ( | const QString | studyUID | ) |
Q_INVOKABLE QHash<QString,QString> ctkDICOMDatabase::descriptionsForFile | ( | QString | fileName | ) |
Q_INVOKABLE bool ctkDICOMDatabase::fileExistsAndUpToDate | ( | const QString & | filePath | ) |
Check if file is already in database and up-to-date.
Q_INVOKABLE QString ctkDICOMDatabase::fileForInstance | ( | const QString | sopInstanceUID | ) |
Q_INVOKABLE QStringList ctkDICOMDatabase::filesForSeries | ( | const QString | seriesUID | ) |
Q_INVOKABLE QString ctkDICOMDatabase::fileValue | ( | const QString | fileName, |
const QString | tag | ||
) |
Q_INVOKABLE QString ctkDICOMDatabase::fileValue | ( | const QString | fileName, |
const unsigned short | group, | ||
const unsigned short | element | ||
) |
Q_INVOKABLE QString ctkDICOMDatabase::groupElementToTag | ( | const unsigned short & | group, |
const unsigned short & | element | ||
) |
Q_INVOKABLE QStringList ctkDICOMDatabase::headerKeys | ( | ) |
Q_INVOKABLE QString ctkDICOMDatabase::headerValue | ( | const QString | key | ) |
Q_INVOKABLE bool ctkDICOMDatabase::initializeDatabase | ( | const char * | schemaFile = ":/dicom/dicom-schema.sql" | ) |
delete all data and (re-)initialize the database.
Q_INVOKABLE bool ctkDICOMDatabase::initializeTagCache | ( | ) |
Create a tagCache in the current database. Delete the existing one if it exists.
Q_INVOKABLE void ctkDICOMDatabase::insert | ( | const ctkDICOMItem & | ctkDataset, |
bool | storeFile, | ||
bool | generateThumbnail | ||
) |
Insert into the database if not already exsting.
dataset | The dataset to store into the database. Usually, this is is a complete DICOM object, like a complete image. However the database also inserts partial objects, like studyl information to the database, even if no image data is contained. This can be helpful to store results from querying the PACS for patient/study/series or image information, where a full hierarchy is only constructed after some queries. |
storeFile | If store file is set (default), then the dataset will be stored to disk. Note that in case of a memory-only database, this flag is ignored. Usually, this flag does only make sense if a full object is received. |
Q_INVOKABLE void ctkDICOMDatabase::insert | ( | const QString & | filePath, |
bool | storeFile = true , |
||
bool | generateThumbnail = true , |
||
bool | createHierarchy = true , |
||
const QString & | destinationDirectoryName = QString() |
||
) |
void ctkDICOMDatabase::insert | ( | DcmItem * | item, |
bool | storeFile = true , |
||
bool | generateThumbnail = true |
||
) |
Q_INVOKABLE QDateTime ctkDICOMDatabase::insertDateTimeForInstance | ( | const QString | fileName | ) |
|
signal |
instance UID is provided instanceAdded arguments:
Q_INVOKABLE QString ctkDICOMDatabase::instanceForFile | ( | const QString | fileName | ) |
Q_INVOKABLE QStringList ctkDICOMDatabase::instancesForSeries | ( | const QString | seriesUID | ) |
Q_INVOKABLE QString ctkDICOMDatabase::instanceValue | ( | const QString | sopInstanceUID, |
const QString | tag | ||
) |
access element values for given instance
sopInstanceUID | A string with the uid for a given instance (corresponding file will be found via database) |
fileName | Full path to a dicom file to load. |
key | A group,element tag in zero-filled hex |
group | The group portion of the tag as an integer |
element | The element portion of the tag as an integer @Returns empty string if element is missing |
Q_INVOKABLE QString ctkDICOMDatabase::instanceValue | ( | const QString | sopInstanceUID, |
const unsigned short | group, | ||
const unsigned short | element | ||
) |
bool ctkDICOMDatabase::isInMemory | ( | ) | const |
Returns whether the database only resides in memory, i.e. the SQLITE DB is not written to stored to disk and DICOM objects are not stored to the file system.
bool ctkDICOMDatabase::isOpen | ( | ) | const |
Should be checked after trying to open the database @Returns true if database is open
const QString ctkDICOMDatabase::lastError | ( | ) | const |
Q_INVOKABLE void ctkDICOMDatabase::loadFileHeader | ( | const QString | fileName | ) |
Q_INVOKABLE void ctkDICOMDatabase::loadInstanceHeader | ( | const QString | sopInstanceUID | ) |
load the header from a file and allow access to elements
sopInstanceUID | A string with the uid for a given instance (corresponding file will be found via database) |
fileName | Full path to a dicom file to load. |
key | A group,element tag in zero-filled hex |
Q_INVOKABLE QString ctkDICOMDatabase::nameForPatient | ( | const QString | patientUID | ) |
|
virtual |
open the SQLite database in
databaseFile | . If the file does not exist, a new database is created and initialized with the default schema |
databaseFile | The file to store the SQLITE database should be stored to. If specified with ":memory:", the database is not written to disk at all but instead only kept in memory (and thus expires after destruction of this object). |
connectionName | The database connection name. If not specified then a random name is generated (reusing a connection name must be avoided as it breaks previously created database object that used the same connection name). |
update | the schema if it is found to be out of date |
|
signal |
Things inserted to database. patientAdded arguments:
Q_INVOKABLE QString ctkDICOMDatabase::patientForStudy | ( | QString | studyUID | ) |
Q_INVOKABLE QStringList ctkDICOMDatabase::patients | ( | ) |
database accessors
Q_INVOKABLE void ctkDICOMDatabase::prepareInsert | ( | ) |
Reset cached item IDs to make sure previous inserts do not interfere with upcoming insert operations. Typically, it should be call just before a batch of files insertion is started.
This has to be called before an insert() call if there is a chance that items have been deleted from the database since the the last insert() call. If there has been not been any insert() calls since connected to the database, then it should be called before the first insert().
Q_INVOKABLE bool ctkDICOMDatabase::removePatient | ( | const QString & | patientID | ) |
Q_INVOKABLE bool ctkDICOMDatabase::removeSeries | ( | const QString & | seriesInstanceUID | ) |
remove the series from the database, including images and thumbnails
Q_INVOKABLE bool ctkDICOMDatabase::removeStudy | ( | const QString & | studyInstanceUID | ) |
|
signal |
Indicates schema update finished.
|
signal |
Indicates progress in updating schema (int is file number, string is file name)
|
signal |
|
signal |
Indicates that the schema is about to be updated and how many files will be processed.
Q_INVOKABLE QString ctkDICOMDatabase::schemaVersion | ( | ) |
returns the schema version needed by the current version of this code
Q_INVOKABLE QString ctkDICOMDatabase::schemaVersionLoaded | ( | ) |
returns the schema version for the currently open database in order to support schema updating
|
signal |
seriesAdded arguments:
Q_INVOKABLE QString ctkDICOMDatabase::seriesForFile | ( | QString | fileName | ) |
Q_INVOKABLE QStringList ctkDICOMDatabase::seriesForStudy | ( | const QString | studyUID | ) |
void ctkDICOMDatabase::setTagsToPrecache | ( | const QStringList | tags | ) |
application-defined tags of interest This list of tags is added to the internal tag cache during import operations. The list should be prepared by the application as a hint to the database that these tags are likely to be accessed later. Internally, the database will cache the values of these tags so that subsequent calls to fileValue or instanceValue will be able to use the cache rather than re-reading the file.
tags | should be a list of ascii hex group/element tags like "0008,0008" as in the instanceValue and fileValue calls |
Q_INVOKABLE void ctkDICOMDatabase::setThumbnailGenerator | ( | ctkDICOMAbstractThumbnailGenerator * | generator | ) |
set thumbnail generator object
Q_INVOKABLE QStringList ctkDICOMDatabase::studiesForPatient | ( | const QString | patientUID | ) |
|
signal |
studyAdded arguments:
Q_INVOKABLE QString ctkDICOMDatabase::studyForSeries | ( | QString | seriesUID | ) |
Q_INVOKABLE bool ctkDICOMDatabase::tagCacheExists | ( | ) |
store values of previously requested instance elements These are meant to be internal methods used by the instanceValue and fileValue methods, but they can be used by calling classes to populate or access instance tag values as needed.
sopInstanceUID | A string with the uid for a given instance (corresponding file will be found via database) |
key | A group,element tag in zero-filled hex @Returns empty string if element for uid is missing from cache |
Lightweight check of tag cache existence (once db check per runtime)
const QStringList ctkDICOMDatabase::tagsToPrecache | ( | ) |
Q_INVOKABLE bool ctkDICOMDatabase::tagToGroupElement | ( | const QString | tag, |
unsigned short & | group, | ||
unsigned short & | element | ||
) |
Q_INVOKABLE ctkDICOMAbstractThumbnailGenerator* ctkDICOMDatabase::thumbnailGenerator | ( | ) |
get thumbnail genrator object
Q_INVOKABLE bool ctkDICOMDatabase::updateSchema | ( | const char * | schemaFile = ":/dicom/dicom-schema.sql" | ) |
updates the database schema and reinserts all existing files
Q_INVOKABLE bool ctkDICOMDatabase::updateSchemaIfNeeded | ( | const char * | schemaFile = ":/dicom/dicom-schema.sql" | ) |
updates the database schema only if the versions don't match Returns true if schema was updated
|
protected |
Definition at line 291 of file ctkDICOMDatabase.h.
|
read |
Definition at line 1 of file ctkDICOMDatabase.h.
|
read |
Definition at line 1 of file ctkDICOMDatabase.h.
|
read |
Definition at line 1 of file ctkDICOMDatabase.h.
|
read |
Definition at line 1 of file ctkDICOMDatabase.h.
|
read |
Definition at line 1 of file ctkDICOMDatabase.h.
|
readwrite |
Definition at line 1 of file ctkDICOMDatabase.h.