ImFusion C++ SDK 4.5.0
ImFusion::DicomBrowserFilterModel Class Reference

#include <ImFusion/Dicom/GUI/DicomBrowserFilterModel.h>

A QSortFilterProxyModel specifically for a DicomBrowserModel. More...

Inheritance diagram for ImFusion::DicomBrowserFilterModel:

Detailed Description

A QSortFilterProxyModel specifically for a DicomBrowserModel.

Check https://doc.qt.io/qt-5/model-view-programming.html for details about Qt's Model/View architecture.

Warning
Do not use the QRegularExpression based filter options with Qt 5. Those are only supported starting from Qt 6!

Example:

auto model = new DicomBrowserModel();
model->scanDirectory(...); // can also be scanned later
auto filter = new DicomBrowserFilterModel();
filter->setSourceModel(model);
filter->setSortRole(DicomBrowserModel::SortRole); // Optional but sorting by SortRole is usually better than the default DisplayRole
auto view = new QTreeView();
view->setModel(filter);
Hierarchical model of DICOM patients.
Definition DicomBrowserModel.h:50
@ SortRole
Special role used to compare indices (e.g. patients by name). Values should be unique to assure stabl...
Definition DicomBrowserModel.h:66

Public Slots

void setOriginalOnly (bool flag)
 If enabled only images with an Image Type (0008, 0008) of "ORIGINAL" will be part of the model.
void setModalitiesFilter (const std::vector< QString > &modalities)
 Only show series that have a Modality (0008,0060) matching a value in the given list.
void setDateFilter (const std::optional< std::tuple< QDate, QDate > > &dateFilter)
 Filters out series which date is outside the given date interval or series that don't specify an explicit date.
void setImagesVisible (bool hide)
 Sets whether the sub-entries for images below series should be visible or not (visible by default).

Signals

void modalitiesFilterChanged (const std::vector< QString > &modalities)
void dateFilterChanged (const std::optional< std::tuple< QDate, QDate > > &dateFilter)

Public Member Functions

 DicomBrowserFilterModel (QObject *parent=nullptr)
bool filterAcceptsPatient (const DicomBrowserModel::Patient &patient, bool checkStudies=true) const
 Accepts the patient when the name or comment matches the current filterRegExp.
bool filterAcceptsStudy (const DicomBrowserModel::Study &study, bool checkSeries=true) const
 Accepts the study when the description or id matches the current filterRegExp.
bool filterAcceptsSeries (const DicomBrowserModel::Series &series) const
 Accepts the series when the description matches the current filterRegExp.
bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override
 Calls filterAcceptsPatient, filterAcceptsStudy or filterAcceptsSeries depending on the index.
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override
const std::vector< QString > & modalitiesFilter () const
 Returns the current filtered modalities.
const std::optional< std::tuple< QDate, QDate > > & studyDateFilter () const
 Returns the current filter for the study date.
bool imagesVisible () const
 Returns whether images are visible.
void setFilterInvalidSeries (bool enable)
 If enabled, filters out invalid Dicom series, i.e. series containing images with the following invalid tags: bitsAllocated, width, height, channels.
bool setData (const QModelIndex &index, const QVariant &value, int role) override
 Overrides base class to make sure the check/uncheck behavior is consistent with the filtering.
QList< Dicom::Series * > selectedSeries () const
 Returns all currently checked Series that are accepted by the filter.

Static Public Member Functions

static std::tuple< QDate, QDate > getFilterDateRange (const Dicom::Series &series)
 Returns the date range of the series that is used for filtering.

Properties

std::vector< QString > modalitiesFilter

Member Function Documentation

◆ filterAcceptsPatient()

bool ImFusion::DicomBrowserFilterModel::filterAcceptsPatient ( const DicomBrowserModel::Patient & patient,
bool checkStudies = true ) const

Accepts the patient when the name or comment matches the current filterRegExp.

When checkStudies is true, the patient is accepted when filterAcceptsStudy returns true for any study of this patient.

◆ filterAcceptsStudy()

bool ImFusion::DicomBrowserFilterModel::filterAcceptsStudy ( const DicomBrowserModel::Study & study,
bool checkSeries = true ) const

Accepts the study when the description or id matches the current filterRegExp.

When checkSeries is true, the patient is accepted when filterAcceptsSeries returns true for any series of this study. A study is also accepted if its parent patient is accepted by filterAcceptsPatient.

◆ filterAcceptsSeries()

bool ImFusion::DicomBrowserFilterModel::filterAcceptsSeries ( const DicomBrowserModel::Series & series) const

Accepts the series when the description matches the current filterRegExp.

A series is also accepted if its parent study is accepted by filterAcceptsStudy.

◆ getFilterDateRange()

std::tuple< QDate, QDate > ImFusion::DicomBrowserFilterModel::getFilterDateRange ( const Dicom::Series & series)
static

Returns the date range of the series that is used for filtering.

See setDateFilter for details.

◆ setOriginalOnly

void ImFusion::DicomBrowserFilterModel::setOriginalOnly ( bool flag)
slot

If enabled only images with an Image Type (0008, 0008) of "ORIGINAL" will be part of the model.

Disabled by default.

◆ setModalitiesFilter

void ImFusion::DicomBrowserFilterModel::setModalitiesFilter ( const std::vector< QString > & modalities)
slot

Only show series that have a Modality (0008,0060) matching a value in the given list.

Passing an empty list will not filter any series (default).

◆ setDateFilter

void ImFusion::DicomBrowserFilterModel::setDateFilter ( const std::optional< std::tuple< QDate, QDate > > & dateFilter)
slot

Filters out series which date is outside the given date interval or series that don't specify an explicit date.

The date of the series is determined by the following tags:

  1. Series Date (0008,0031)
  2. Acquisition Date (0008,0032)
  3. Study Date (0008,0020)

The first date in this order that is valid will be used, the other are ignored. The Acquisition Date is only used when all images of the series have a valid Acquisition Date. When the Acquisition Date is used, the series will be filtered out when the range of Acquisition Dates is not completely inside the filter range.

If set to std::nullopt, no date filtering is performed (default) Examples:

DicomBrowserFilterModel filter;
filter.setSourceModel(...);
// Filter between 2000 and 2010:
filter.setDateFilter(std::make_tuple(QDate(2000, 1, 1), QDate(2010, 12, 31)));
// Remove filter again:
filter.setDateFilter(std::nullopt);
T make_tuple(T... args)

The documentation for this class was generated from the following file:
  • ImFusion/Dicom/GUI/DicomBrowserFilterModel.h
Search Tab / S to search, Esc to close