comparison Tests/Tests.py @ 263:a2719263fd04

test_study_series_find_inconsistency
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 Feb 2020 19:58:30 +0100
parents 045a45c3f945
children 445f498bc1d4
comparison
equal deleted inserted replaced
262:045a45c3f945 263:a2719263fd04
4899 4899
4900 # Switch back to the original log level 4900 # Switch back to the original log level
4901 DoPut(_REMOTE, '/tools/log-level', original) 4901 DoPut(_REMOTE, '/tools/log-level', original)
4902 4902
4903 4903
4904 def test_study_series_find_inconsistency(self):
4905 # https://groups.google.com/forum/#!topic/orthanc-users/bLv6Z11COy0
4906
4907 def CountAnswers(query):
4908 a = DoPost(_REMOTE, 'modalities/self/query', query)
4909 return len(DoGet(_REMOTE, '%s/answers' % a['Path']))
4910
4911 # This instance has "SeriesDescription" (0008,103e) tag, but no
4912 # "ProtocolName" (0018,1030). Both of those tags are part of
4913 # the "main DICOM tags" of Orthanc.
4914 UploadInstance(_REMOTE, 'Issue137.dcm')
4915
4916
4917 self.assertEqual(1, CountAnswers({
4918 'Level' : 'Study',
4919 }))
4920
4921 self.assertEqual(1, CountAnswers({
4922 'Level' : 'Series',
4923 }))
4924
4925
4926 ##
4927 ## "SeriesDescription" is present, and has VR "CS" => wildcard is allowed
4928 ## http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.4.html
4929 ##
4930
4931 # At the study level, the "SeriesDescription" tag is not allowed, but
4932 # is wiped out by the normalization
4933 self.assertEqual(0, CountAnswers({
4934 'Level' : 'Study',
4935 'Query' : {
4936 'SeriesDescription' : 'NOPE'
4937 },
4938 'Normalize' : False
4939 }))
4940 self.assertEqual(0, CountAnswers({
4941 # This test fails on Orthanc <= 1.5.8
4942 'Level' : 'Study',
4943 'Query' : {
4944 'SeriesDescription' : '*' # Wildcard matching => no match, as the tag is absent
4945 },
4946 'Normalize' : False
4947 }))
4948 self.assertEqual(1, CountAnswers({
4949 'Level' : 'Study',
4950 'Query' : {
4951 'SeriesDescription' : 'THIS^VALUE^IS^WIPED^OUT'
4952 },
4953 'Normalize' : True
4954 }))
4955 self.assertEqual(1, CountAnswers({
4956 'Level' : 'Study',
4957 'Query' : {
4958 'SeriesDescription' : '*' # Matches, as wiped out by the normalization
4959 },
4960 'Normalize' : True
4961 }))
4962
4963 for normalize in [ True, False ]:
4964 # At the series level, the "SeriesDescription" tag is allowed, and
4965 # normalization has no effect
4966
4967 # "Universal matching" will match all entities, including
4968 # those with the missing tag
4969 # http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.3.html
4970 self.assertEqual(1, CountAnswers({
4971 'Level' : 'Series',
4972 'Query' : {
4973 'SeriesDescription' : '' # Universal matching
4974 },
4975 'Normalize' : normalize,
4976 }))
4977 # "Universal matching" will match all entities, including
4978 # those with the missing tag
4979 # http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.3.html
4980 self.assertEqual(1, CountAnswers({
4981 'Level' : 'Series',
4982 'Query' : {
4983 'SeriesDescription' : '*' # Wildcard matching
4984 },
4985 'Normalize' : normalize,
4986 }))
4987 self.assertEqual(1, CountAnswers({
4988 'Level' : 'Series',
4989 'Query' : {
4990 'SeriesDescription' : '*model*' # The actual value is "STL model: intraop Report"
4991 },
4992 'Normalize' : normalize,
4993 }))
4994 self.assertEqual(0, CountAnswers({
4995 'Level' : 'Series',
4996 'Query' : {
4997 'SeriesDescription' : '*MISMATCHED^VALUE*'
4998 },
4999 'Normalize' : normalize,
5000 }))
5001
5002 # Universal matching matches any instance, even if the
5003 # query is at the study-level, and thus if "SeriesDescription"
5004 # makes no sense
5005 self.assertEqual(1, CountAnswers({
5006 'Level' : 'Study',
5007 'Query' : {
5008 'SeriesDescription' : '' # Universal matching
5009 },
5010 'Normalize' : normalize,
5011 }))
5012
5013
5014
5015 ##
5016 ## "ProtocolName" is absent, and has VR "CS" => wildcard is allowed
5017 ##
5018
5019 # At the study level, the "ProtocolName" tag is not allowed, but
5020 # is wiped out by the normalization
5021 self.assertEqual(0, CountAnswers({
5022 'Level' : 'Study',
5023 'Query' : {
5024 'ProtocolName' : 'NOPE'
5025 },
5026 'Normalize' : False
5027 }))
5028 self.assertEqual(0, CountAnswers({
5029 'Level' : 'Study',
5030 'Query' : {
5031 'ProtocolName' : '*' # Wildcard matching => no match, as the tag is absent
5032 },
5033 'Normalize' : False
5034 }))
5035 self.assertEqual(1, CountAnswers({
5036 'Level' : 'Study',
5037 'Query' : {
5038 'ProtocolName' : 'THIS^VALUE^IS^WIPED^OUT'
5039 },
5040 'Normalize' : True
5041 }))
5042 self.assertEqual(1, CountAnswers({
5043 'Level' : 'Study',
5044 'Query' : {
5045 'ProtocolName' : '*' # Matches, as wiped out by the normalization
5046 },
5047 'Normalize' : True
5048 }))
5049
5050 for normalize in [ True, False ]:
5051 # At the series level, the "ProtocolName" tag is allowed, and
5052 # normalization has no effect
5053
5054 self.assertEqual(1, CountAnswers({
5055 'Level' : 'Series',
5056 'Query' : {
5057 'ProtocolName' : '' # Universal matching
5058 },
5059 'Normalize' : normalize,
5060 }))
5061 self.assertEqual(0, CountAnswers({
5062 'Level' : 'Series',
5063 'Query' : {
5064 'ProtocolName' : '*' # Wildcard matching => no match, as the tag is absent
5065 },
5066 'Normalize' : normalize,
5067 }))
5068 self.assertEqual(0, CountAnswers({
5069 'Level' : 'Series',
5070 'Query' : {
5071 'ProtocolName' : '*MISMATCHED^VALUE*'
5072 },
5073 'Normalize' : normalize,
5074 }))
5075
5076 self.assertEqual(1, CountAnswers({
5077 'Level' : 'Study',
5078 'Query' : {
5079 'ProtocolName' : '' # Universal matching
5080 },
5081 'Normalize' : normalize,
5082 }))
5083
5084
5085 ##
5086 ## "StudyInstanceUID" is present, and has VR "UI" => wildcard is not allowed
5087 ##
5088
5089 for level in [ 'Study', 'Series' ] :
5090 for normalize in [ True, False ]:
5091 self.assertEqual(1, CountAnswers({
5092 'Level' : level,
5093 'Query' : {
5094 'StudyInstanceUID' : '' # Universal matching
5095 },
5096 'Normalize' : normalize,
5097 }))
5098 self.assertEqual(0, CountAnswers({
5099 'Level' : level,
5100 'Query' : {
5101 'StudyInstanceUID' : 'MISMATCHED^VALUE'
5102 },
5103 'Normalize' : normalize,
5104 }))
5105 self.assertEqual(1, CountAnswers({
5106 'Level' : level,
5107 'Query' : {
5108 'StudyInstanceUID' : '4.5.6' # This is the actual value
5109 },
5110 'Normalize' : normalize,
5111 }))
5112
5113 # This test fails on Orthanc <= 1.5.8
5114 self.assertEqual(0, CountAnswers({
5115 'Level' : level,
5116 'Query' : {
5117 'StudyInstanceUID' : '*' # Wildcard matching not allowed for this VR
5118 },
5119 'Normalize' : normalize,
5120 }))