MeVisLab Toolbox Reference
mlFileListFilterPlugin.h
Go to the documentation of this file.
1 // Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2 // **InsertLicense** code
3 //----------------------------------------------------------------------------------
6 
11 //----------------------------------------------------------------------------------
12 #pragma once
13 
14 // Local includes
16 
17 // Include muParse for the evaluation of numeric function strings.
18 #if defined _WIN32
19 //include as C-API only for windows case as the muParser API is written like that
20 extern "C"
21 {
22  #include "muParserDLL.h"
23 }
24 #else
25  #include "muParserDLL.h"
26 #endif
27 
28 ML_START_NAMESPACE
29 
30 //----------------------------------------------------------------------------------
33 //----------------------------------------------------------------------------------
35 {
36 public:
37 
40  DoNotChangeLabel = 0,
48 
49  NumLabellingEnumModes
50  };
51 
54  DoNotChangeConfig = 0,
62 
63  NumConfigurationAssignmentEnumModes
64  };
65 
68  DoNotChangeProcSettings = 0,
76 
77  NumProcSettingsAssignmentEnumModes
78  };
79 
81  static const char * const LabellingEnumStrings[NumLabellingEnumModes];
82 
84  static const char * const ConfigurationAssignmentEnumStrings[NumConfigurationAssignmentEnumModes];
85 
87  static const char * const ProcessingSettingsAssignmentEnumStrings[NumProcSettingsAssignmentEnumModes];
88 
90  FileListFilterPlugin(int numIns=0, int numOuts=0);
91 
94 
101  virtual void filterFile(FileListTools::FileAttribute &filterAttributes,
102  FilterMessageList *messageList) const override;
103 
105  inline BoolField &getClearPassFlagBeforeFilteringFld () const { return *_clearPassFlagBeforeFilteringFld ; }
106  inline StringField &getVolumeLabelFld () const { return *_volumeLabelFld ; }
107  inline StringField &getVolumeConfigFld () const { return *_volumeConfigFld ; }
108  inline StringField &getProcessingSettingsFld () const { return *_processingSettingsFld ; }
109  inline EnumField &getLabelAssignModeFld () const { return *_labelAssignModeFld ; }
110  inline EnumField &getConfigAssignModeFld () const { return *_configAssignModeFld ; }
111  inline EnumField &getProcessingSettingsAssignModeFld () const { return *_processingSettingsAssignModeFld ; }
112  inline BoolField &getAllowRecursiveTagSearchFld () const { return *_allowRecursiveTagSearchFld ; }
113  inline BoolField &getApplyFilePathFilterFld () const { return *_applyFilePathFilterFld ; }
114  inline StringField &getPathFilterRegExFld () const { return *_pathFilterRegExFld ; }
115  inline BoolField &getInvertPathFilterRegExFld () const { return *_invertPathFilterRegExFld ; }
116  inline BoolField &getSetPassFlagOnPathMatchesFld () const { return *_setPassFlagOnPathMatchesFld ; }
117  inline BoolField &getClearPassFlagOnPathMismatchesFld () const { return *_clearPassFlagOnPathMismatchesFld ; }
118  inline StringField &getRegExStatusFld () const { return *_regExStatusFld ; }
119  inline BoolField &getApplyTagStringFilterFld () const { return *_applyTagStringFilterFld ; }
120  inline StringField &getTagStringFilterTagIdFld () const { return *_tagStringFilterTagIdFld ; }
121  inline IntField &getTagStringFilterTagValueIndexFld () const { return *_tagStringFilterTagValueIndexFld ; }
122  inline StringField &getTagStringFilterPrivateCreatorFld () const { return *_tagStringFilterPrivateCreatorFld ; }
123  inline BoolField &getCheckOnlyFirstRecursiveTagStringFld () const { return *_checkOnlyFirstRecursiveTagStringFld ; }
124  inline StringField &getTagStringEvalRegExFld () const { return *_tagStringEvalRegExFld ; }
125  inline BoolField &getInvertTagStringEvalRegExFld () const { return *_invertTagStringEvalRegExFld ; }
126  inline BoolField &getSetTagStrEvalPassFlagOnPathMatchesFld () const { return *_setTagStrEvalPassFlagOnPathMatchesFld ; }
127  inline BoolField &getClearTagStrEvalPassFlagOnPathMismatchesFld () const { return *_clearTagStrEvalPassFlagOnPathMismatchesFld; }
128  inline StringField &getTagFilterRegExStatusFld () const { return *_tagFilterRegExStatusFld ; }
129  inline BoolField &getApplyTagValueFilterFld () const { return *_applyTagValueFilterFld ; }
130  inline StringField &getTreeFilterExFld () const { return *_treeFilterExFld ; }
131  inline StringField &getTagId0Fld () const { return *_tagId0Fld ; }
132  inline StringField &getTagId1Fld () const { return *_tagId1Fld ; }
133  inline StringField &getTagId2Fld () const { return *_tagId2Fld ; }
134  inline StringField &getTagId3Fld () const { return *_tagId3Fld ; }
135  inline IntField &getTagId0ValueIndexFld () const { return *_tagId0ValueIndexFld ; }
136  inline IntField &getTagId1ValueIndexFld () const { return *_tagId1ValueIndexFld ; }
137  inline IntField &getTagId2ValueIndexFld () const { return *_tagId2ValueIndexFld ; }
138  inline IntField &getTagId3ValueIndexFld () const { return *_tagId3ValueIndexFld ; }
139  inline StringField &getTagId0PrivateCreatorFld () const { return *_tagId0PrivateCreatorFld ; }
140  inline StringField &getTagId1PrivateCreatorFld () const { return *_tagId1PrivateCreatorFld ; }
141  inline StringField &getTagId2PrivateCreatorFld () const { return *_tagId2PrivateCreatorFld ; }
142  inline StringField &getTagId3PrivateCreatorFld () const { return *_tagId3PrivateCreatorFld ; }
143  inline DoubleField &getConst0Fld () const { return *_const0Fld ; }
144  inline DoubleField &getConst1Fld () const { return *_const1Fld ; }
145  inline DoubleField &getConst2Fld () const { return *_const2Fld ; }
146  inline DoubleField &getConst3Fld () const { return *_const3Fld ; }
147  inline DoubleField &getRangeMinFld () const { return *_rangeMinFld ; }
148  inline DoubleField &getRangeMaxFld () const { return *_rangeMaxFld ; }
149  inline BoolField &getSetPassFlagOnTagValueMatchesFld () const { return *_setPassFlagOnTagValueMatchesFld ; }
150  inline BoolField &getClearPassFlagOnTagValueMismatchesFld () const { return *_clearPassFlagOnTagValueMismatchesFld ; }
151  inline StringField &getTreeFilterStatusFld () const { return *_treeFilterStatusFld ; }
153 
154 protected:
155 
157  void activateAttachments() override;
158 
161  void handleNotification(Field *field) override;
162 
166 
173  FilterMessageList *messageList,
174  bool &wasDisabled,
175  bool &wasEnabled,
176  bool &expMatches) const;
177 
181 
190  FilterMessageList *messageList,
191  bool &wasDisabled,
192  bool &wasEnabled,
193  bool &expMatches,
194  DCMTree::Const_TreePtr &dcmTree) const;
195 
204  void _updateFlagsAccordingToTagStringValues(const std::vector<std::string>& tagStringValues,
205  bool& passFlag,
206  bool& wasDisabled,
207  bool& wasEnabled,
208  bool& expMatches) const;
209 
213 
222  FilterMessageList *messageList,
223  bool &wasDisabled,
224  bool &wasEnabled,
225  bool &expMatches,
226  DCMTree::Const_TreePtr dcmTree) const;
227 
234  virtual void _applyLabelling(FileListTools::FileAttribute &filterAttributes,
235  FilterMessageList *messageList,
236  bool &wasDisabled,
237  bool &wasEnabled,
238  bool &expMatches) const;
239 
246  virtual void _applyConfigAssignment(FileListTools::FileAttribute &filterAttributes,
247  FilterMessageList *messageList,
248  bool &wasDisabled,
249  bool &wasEnabled,
250  bool &expMatches) const;
251 
259  FilterMessageList *messageList,
260  bool &wasDisabled,
261  bool &wasEnabled,
262  bool &expMatches) const;
263 
271  DCMTree::RawTagId rawTagId,
272  std::vector<DCMTree::Const_TagPtr>* foundTags) const;
273 
298  DCMTree::RawTagId rawTagId,
299  const std::string &privateCreatorStr,
300  std::vector<DCMTree::Const_TagPtr> *foundTags=nullptr) const;
301 
305  std::vector<std::string> &foundValues) const;
306 
307 
322  MLint tagValueFilterId,
323  const std::string &privateCreatorString,
324  MLint valueIndex) const;
325 
326 private:
327 
328  //----------- General settings:
330  BoolField *_clearPassFlagBeforeFilteringFld;
331 
333  StringField *_volumeLabelFld;
334 
336  StringField *_volumeConfigFld;
337 
339  StringField *_processingSettingsFld;
340 
342  EnumField *_labelAssignModeFld;
343 
345  EnumField *_configAssignModeFld;
346 
348  EnumField *_processingSettingsAssignModeFld;
349 
351  BoolField *_allowRecursiveTagSearchFld;
352 
353  //----------- Path filtering:
355  BoolField *_applyFilePathFilterFld;
356 
358  StringField *_pathFilterRegExFld;
359 
361  BoolField *_invertPathFilterRegExFld;
362 
364  BoolField *_setPassFlagOnPathMatchesFld;
365 
367  BoolField *_clearPassFlagOnPathMismatchesFld;
368 
370  StringField *_regExStatusFld;
371 
372 
373  //----------- String tag filtering:
375  BoolField *_applyTagStringFilterFld;
376 
378  StringField *_tagStringFilterTagIdFld;
379 
382  IntField *_tagStringFilterTagValueIndexFld;
383 
385  StringField *_tagStringFilterPrivateCreatorFld;
386 
389  BoolField *_checkOnlyFirstRecursiveTagStringFld;
390 
392  StringField *_tagStringEvalRegExFld;
393 
395  BoolField *_invertTagStringEvalRegExFld;
396 
398  BoolField *_setTagStrEvalPassFlagOnPathMatchesFld;
399 
401  BoolField *_clearTagStrEvalPassFlagOnPathMismatchesFld;
402 
404  StringField *_tagFilterRegExStatusFld;
405 
407  MLint _strEvalTagId;
408 
409 
410  //----------- Numeric Tag filtering:
412  muParserHandle_t _parser;
413 
415  BoolField *_applyTagValueFilterFld;
416 
418  StringField *_treeFilterExFld;
419 
421  StringField *_tagId0Fld;
422  StringField *_tagId1Fld;
423  StringField *_tagId2Fld;
424  StringField *_tagId3Fld;
426 
428  IntField *_tagId0ValueIndexFld;
429  IntField *_tagId1ValueIndexFld;
430  IntField *_tagId2ValueIndexFld;
431  IntField *_tagId3ValueIndexFld;
433 
435  StringField *_tagId0PrivateCreatorFld;
436  StringField *_tagId1PrivateCreatorFld;
437  StringField *_tagId2PrivateCreatorFld;
438  StringField *_tagId3PrivateCreatorFld;
440 
442  MLint _tagValueFilterId0;
443  MLint _tagValueFilterId1;
444  MLint _tagValueFilterId2;
445  MLint _tagValueFilterId3;
447 
449  DoubleField *_const0Fld;
450  DoubleField *_const1Fld;
451  DoubleField *_const2Fld;
452  DoubleField *_const3Fld;
454 
456  DoubleField *_rangeMinFld;
457  DoubleField *_rangeMaxFld;
459 
461  BoolField *_setPassFlagOnTagValueMatchesFld;
462 
464  BoolField *_clearPassFlagOnTagValueMismatchesFld;
465 
466 
468  StringField *_treeFilterStatusFld;
469 
470 
473 };
474 
477 
478 
479 ML_END_NAMESPACE
#define MLFILE_LIST_TOOLS_EXPORT
DLL export macro definition.
Field to encapsulate a boolean value.
Definition: mlFields.h:62
Field to encapsulate a double value.
Definition: mlFields.h:806
Field to encapsulate an enumerated value.
Definition: mlFields.h:363
Base class for all fields used in the ML.
Definition: mlField.h:73
A base class for plugins which can be used by file list importers to filter and classify files.
A concrete module class for file and DCMTree filtering which can be used by FileList importers to fil...
ProcessingSettingsAssignmentEnumModes
Enumerator defining how processing settings are assigned to the file attribute structures.
@ SetProcSettingsIfPassFlagIsTrue
The processing settings are assigned if after filtering the pass flag is true or if it was already tr...
@ SetProcSettingsIfExpressionDoesNotMatch
The processing settings are assigned if any expression matches.
@ SetProcSettingsIfPassFlagIsFalse
The processing settings are assigned if after filtering the pass flag is false or if it was false bef...
@ SetProcSettingsIfExpressionMatches
The processing settings are assigned if any expression matches.
@ SetProcSettingsIfPassFlagIsSet
The processing settings are assigned if the pass flag is set to true (independent of its previous sta...
@ SetProcSettingsIfPassFlagIsUnchanged
The processing settings are assigned if the pass flag is neither set nor cleared by the filter.
@ SetProcSettingsIfPassFlagIsCleared
The processing settings are assigned if the pass flag is set to false (independent of its previous st...
DoubleField & getConst1Fld() const
virtual bool _handleNotificationForPathStringFiltering(Field *field)
Do the notification handling for path string filtering, return true if output notification is needed.
StringField & getTagId3Fld() const
virtual void filterFile(FileListTools::FileAttribute &filterAttributes, FilterMessageList *messageList) const override
Evaluates the regular expression given by field _pathFilterRegExFld on the filterAttributes....
DoubleField & getConst2Fld() const
StringField & getPathFilterRegExFld() const
BoolField & getCheckOnlyFirstRecursiveTagStringFld() const
ConfigurationAssignmentEnumModes
Enumerator defining how configurations are assigned to the file/DCMTree attribute structures.
@ SetConfigIfExpressionDoesNotMatch
The configuration is assigned if any expression matches.
@ SetConfigIfPassFlagIsUnchanged
The configuration is assigned if the pass flag is neither set nor cleared by the filter.
@ SetConfigIfPassFlagIsFalse
The configuration is assigned if after filtering the pass flag is false or if it was false before.
@ SetConfigIfPassFlagIsCleared
The configuration is assigned if the pass flag is set to false (independent of its previous state).
@ SetConfigIfExpressionMatches
The configuration is assigned if any expression matches.
@ SetConfigIfPassFlagIsSet
The configuration is assigned if the pass flag is set to true (independent of its previous state).
@ SetConfigIfPassFlagIsTrue
The configuration is assigned if after filtering the pass flag is true or if it was already true befo...
StringField & getTagId0PrivateCreatorFld() const
StringField & getTagStringEvalRegExFld() const
BoolField & getApplyFilePathFilterFld() const
IntField & getTagId2ValueIndexFld() const
virtual void _applyFilePathFiltering(FileListTools::FileAttribute &filterAttributes, FilterMessageList *messageList, bool &wasDisabled, bool &wasEnabled, bool &expMatches) const
Applies path filtering.
BoolField & getSetPassFlagOnPathMatchesFld() const
StringField & getTagStringFilterPrivateCreatorFld() const
IntField & getTagId1ValueIndexFld() const
StringField & getVolumeLabelFld() const
virtual void _applyTagStringFiltering(FileListTools::FileAttribute &filterAttributes, FilterMessageList *messageList, bool &wasDisabled, bool &wasEnabled, bool &expMatches, DCMTree::Const_TreePtr &dcmTree) const
Applies filtering of tag values as strings.
StringField & getVolumeConfigFld() const
DoubleField & getConst0Fld() const
StringField & getTreeFilterExFld() const
BoolField & getSetPassFlagOnTagValueMatchesFld() const
BoolField & getApplyTagStringFilterFld() const
IntField & getTagStringFilterTagValueIndexFld() const
BoolField & getClearPassFlagBeforeFilteringFld() const
Provide programming access to field interface, see corresponding member for documentation.
BoolField & getClearTagStrEvalPassFlagOnPathMismatchesFld() const
BoolField & getAllowRecursiveTagSearchFld() const
void handleNotification(Field *field) override
Handle field changes of the field field, typically of the input field where changes are passes as not...
DoubleField & getConst3Fld() const
double _getTagValueForTagValueFilter(DCMTree::Const_TreePtr dcmTree, MLint tagValueFilterId, const std::string &privateCreatorString, MLint valueIndex) const
Read tag tagValueFilterId from dcmTree, take its double value and return it.
void _updateFlagsAccordingToTagStringValues(const std::vector< std::string > &tagStringValues, bool &passFlag, bool &wasDisabled, bool &wasEnabled, bool &expMatches) const
Apply tag string expression on all values in tagStringValues and update the flags.
StringField & getTagStringFilterTagIdFld() const
StringField & getTagId1Fld() const
StringField & getTagFilterRegExStatusFld() const
IntField & getTagId0ValueIndexFld() const
StringField & getTagId2Fld() const
StringField & getProcessingSettingsFld() const
StringField & getTreeFilterStatusFld() const
virtual void _applyTagValueFiltering(FileListTools::FileAttribute &filterAttributes, FilterMessageList *messageList, bool &wasDisabled, bool &wasEnabled, bool &expMatches, DCMTree::Const_TreePtr dcmTree) const
Applies filtering of tag values as numeric values.
EnumField & getLabelAssignModeFld() const
virtual bool _handleNotificationForTagStringFiltering(Field *field)
Do the notification handling for tag string filtering, return true if output notification is needed.
DoubleField & getRangeMinFld() const
BoolField & getInvertTagStringEvalRegExFld() const
FileListFilterPlugin(int numIns=0, int numOuts=0)
Constructor. Input and out images are probably not used.
StringField & getTagId1PrivateCreatorFld() const
EnumField & getConfigAssignModeFld() const
IntField & getTagId3ValueIndexFld() const
BoolField & getSetTagStrEvalPassFlagOnPathMatchesFld() const
LabellingEnumModes
Enumerator defining how label values are assigned to the file/DCMTree attribute structures.
@ SetLabelIfExpressionDoesNotMatch
The label is assigned if any expression matches.
@ SetLabelIfExpressionMatches
The label is assigned if any expression matches.
@ SetLabelIfPassFlagIsTrue
The label is assigned if after filtering the pass flag is true or if it was already true before.
@ SetLabelIfPassFlagIsFalse
The label is assigned if after filtering the pass flag is false or if it was false before.
@ SetLabelIfPassFlagIsSet
The label is assigned if the pass flag is set to true (independent of its previous state).
@ SetLabelIfPassFlagIsCleared
The label is assigned if the pass flag is set to false (independent of its previous state).
@ SetLabelIfPassFlagIsUnchanged
The label is assigned if the pass flag is neither set nor cleared by the filter.
virtual bool _handleNotificationForTagValueFiltering(Field *field)
Do the notification handling for tag value filtering, return true if output notification is needed.
BoolField & getClearPassFlagOnTagValueMismatchesFld() const
virtual void _applyProcessingSettingsAssignment(FileListTools::FileAttribute &filterAttributes, FilterMessageList *messageList, bool &wasDisabled, bool &wasEnabled, bool &expMatches) const
Sets processing settings if parameters and filter results require that.
StringField & getTagId3PrivateCreatorFld() const
virtual void _applyConfigAssignment(FileListTools::FileAttribute &filterAttributes, FilterMessageList *messageList, bool &wasDisabled, bool &wasEnabled, bool &expMatches) const
Sets volume configuration if parameters and filter results require that.
~FileListFilterPlugin() override
Destructor.
StringField & getTagId0Fld() const
BoolField & getClearPassFlagOnPathMismatchesFld() const
BoolField & getApplyTagValueFilterFld() const
void _getTagStringValues(DCMTree::Const_TreePtr dcmTree, std::vector< std::string > &foundValues) const
Retrieves as many string values from dcmTree as possible and specified by _allowRecursiveTagSearchFld...
EnumField & getProcessingSettingsAssignModeFld() const
DoubleField & getRangeMaxFld() const
DCMTree::Const_TagPtr _getNormalOrPrivateTag(DCMTree::Const_TreePtr dcmTree, DCMTree::RawTagId rawTagId, const std::string &privateCreatorStr, std::vector< DCMTree::Const_TagPtr > *foundTags=nullptr) const
Function to get as many normal or private tag values from the given DCIOM tree dependent on whether t...
BoolField & getInvertPathFilterRegExFld() const
StringField & getTagId2PrivateCreatorFld() const
virtual void _applyLabelling(FileListTools::FileAttribute &filterAttributes, FilterMessageList *messageList, bool &wasDisabled, bool &wasEnabled, bool &expMatches) const
Sets volume label if parameters and filter results require that.
void activateAttachments() override
Update internal state after field reload or clone..
DCMTree::Const_TagPtr _searchOneOrMultipleTags(DCMTree::Const_TreePtr dcmTree, DCMTree::RawTagId rawTagId, std::vector< DCMTree::Const_TagPtr > *foundTags) const
Dependent on _allowRecursiveTagSearchFld and _checkOnlyFirstRecursiveTagStringFld one or multiple tag...
StringField & getRegExStatusFld() const
Attributes assigned to files in a FileList according to filter operations on the file names or DICOM ...
Field to encapsulate an integer value.
Definition: mlFields.h:161
Field to encapsulate a string value.
Definition: mlFields.h:1000
#define ML_MODULE_CLASS_HEADER(className)
Like ML_CLASS_HEADER for the usage of derived classes from Module.
A base class for plugins which can be used by file list importers to filter and classify files.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
boost::shared_ptr< const Tag > Const_TagPtr
Definition: DCMTree_Lib.h:63
boost::shared_ptr< const Tree > Const_TreePtr
Definition: DCMTree_Lib.h:73
unsigned int RawTagId
Definition: DCMTree_Lib.h:147
FileListFilterPlugin DirectDicomImportImportFilterPlugin
For backward compatibility:
std::list< FilterMessage > FilterMessageList
List of messages which can occur during filter calls.