[Gdcm-hackers] gdcm-git:Grassroots DICOM branch release updated. 2fef7bebab084aaca50f386a34106a68cb
Cross-platform DICOM implementation
Brought to you by:
malat
|
From: Mathieu M. <ma...@us...> - 2019-09-12 08:03:02
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Grassroots DICOM".
The branch, release has been updated
via 2fef7bebab084aaca50f386a34106a68cbc9494b (commit)
via 870ddc5ff3bd7a8a57f349f0094e13cf6c8bbbc9 (commit)
via 3294558df95ff871216e16264ebfab3b5d24f752 (commit)
via d291c460a5064428d34aa58c7315a44091a7a7a6 (commit)
from 7aca7a8ae64046df77235fcad5a24fc8faa80edd (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sourceforge.net/p/gdcm/gdcm/ci/2fef7bebab084aaca50f386a34106a68cbc9494b/
commit 2fef7bebab084aaca50f386a34106a68cbc9494b
Author: Mathieu Malaterre <mat...@gm...>
Date: Tue Sep 10 15:34:14 2019 +0200
Accept keyword as input
diff --git a/Applications/Cxx/gdcmscanner.cxx b/Applications/Cxx/gdcmscanner.cxx
index 20a0f324b..f1cea7e1e 100644
--- a/Applications/Cxx/gdcmscanner.cxx
+++ b/Applications/Cxx/gdcmscanner.cxx
@@ -32,6 +32,10 @@
#include "gdcmTrace.h"
#include "gdcmVersion.h"
#include "gdcmSimpleSubjectWatcher.h"
+#include "gdcmGlobal.h"
+#include "gdcmDicts.h"
+#include "gdcmDict.h"
+#include "gdcmDictEntry.h"
#include <string>
#include <iostream>
@@ -55,8 +59,9 @@ static void PrintHelp()
std::cout << "Usage: gdcmscanner [OPTION] -d directory -t tag(s)" << std::endl;
std::cout << "Scan a directory containing DICOM files.\n";
std::cout << "Parameter (required):" << std::endl;
- std::cout << " -d --dir DICOM directory" << std::endl;
- std::cout << " -t --tag %d,%d DICOM tag(s) to look for" << std::endl;
+ std::cout << " -d --dir DICOM directory" << std::endl;
+ std::cout << " -t --tag %d,%d DICOM tag(s) to look for" << std::endl;
+ std::cout << " -k --keyword %s DICOM keyword(s) to look for" << std::endl;
std::cout << " -P --private-tag %d,%d,%s DICOM private tag(s) to look for" << std::endl;
std::cout << "Options:" << std::endl;
std::cout << " -p --print Print output." << std::endl;
@@ -122,6 +127,9 @@ int main(int argc, char *argv[])
VectorPrivateTags privatetags;
gdcm::Tag tag;
gdcm::PrivateTag privatetag;
+ static const gdcm::Global &g = gdcm::Global::GetInstance();
+ static const gdcm::Dicts &dicts = g.GetDicts();
+ static const gdcm::Dict &pubdict = dicts.GetPublicDict();
int strict = 0;
int table = 0;
@@ -136,26 +144,27 @@ int main(int argc, char *argv[])
//int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] = {
- {"dir", 1, nullptr, 0},
- {"tag", 1, nullptr, 0},
- {"recursive", 1, nullptr, 0},
- {"print", 1, nullptr, 0},
- {"private-tag", 1, nullptr, 0},
- {"strict", 0, &strict, 1},
- {"table", 0, &table, 1},
+ {"dir", required_argument, nullptr, 'd'},
+ {"tag", required_argument, nullptr, 't'},
+ {"recursive", no_argument, nullptr, 'r'},
+ {"print", no_argument, nullptr, 'p'},
+ {"private-tag", required_argument, nullptr, 'P'},
+ {"keyword", required_argument, nullptr, 'k'},
+ {"strict", no_argument, &strict, 1},
+ {"table", no_argument, &table, 1},
// General options !
- {"verbose", 0, &verbose, 1},
- {"warning", 0, &warning, 1},
- {"debug", 0, &debug, 1},
- {"error", 0, &error, 1},
- {"help", 0, &help, 1},
- {"version", 0, &version, 1},
+ {"verbose", no_argument, nullptr, 'V'},
+ {"warning", no_argument, nullptr, 'W'},
+ {"debug", no_argument, nullptr, 'D'},
+ {"error", no_argument, nullptr, 'E'},
+ {"help", no_argument, nullptr, 'H'},
+ {"version", no_argument, nullptr, 'v'},
{nullptr, 0, nullptr, 0}
};
- c = getopt_long (argc, argv, "d:t:rpP:VWDEhv",
+ c = getopt_long (argc, argv, "d:t:rpP:k:VWDEhv",
long_options, &option_index);
if (c == -1)
{
@@ -165,18 +174,10 @@ int main(int argc, char *argv[])
switch (c)
{
case 0:
+ if (optarg)
{
- //const char *s = long_options[option_index].name;
- //printf ("option %s", s);
- //if (optarg)
- // {
- // if( option_index == 0 ) /* input */
- // {
- // assert( strcmp(s, "input") == 0 );
- // }
- // printf (" with arg %s", optarg);
- // }
- //printf ("\n");
+ const char *s = long_options[option_index].name; (void)s;
+ assert(0);
}
break;
@@ -190,6 +191,20 @@ int main(int argc, char *argv[])
//std::cerr << optarg << std::endl;
break;
+ case 'k':
+ {
+ const char * keyword = optarg;
+ /*const gdcm::DictEntry &dictentry =*/ pubdict.GetDictEntryByKeyword(keyword, tag);
+ if( tag != gdcm::Tag(0xffff,0xffff) )
+ tags.push_back( tag );
+ else
+ {
+ std::cerr << "Invalid keyword: " << keyword << std::endl;
+ return 1;
+ }
+ }
+ break;
+
case 'P':
privatetag.ReadFromCommaSeparatedString(optarg);
privatetags.push_back( privatetag );
https://sourceforge.net/p/gdcm/gdcm/ci/870ddc5ff3bd7a8a57f349f0094e13cf6c8bbbc9/
commit 870ddc5ff3bd7a8a57f349f0094e13cf6c8bbbc9
Author: Mathieu Malaterre <mat...@gm...>
Date: Tue Sep 10 14:17:17 2019 +0200
Return an error when no file (bogus dir?)
diff --git a/Applications/Cxx/gdcmscanner.cxx b/Applications/Cxx/gdcmscanner.cxx
index 32f6e6f3e..20a0f324b 100644
--- a/Applications/Cxx/gdcmscanner.cxx
+++ b/Applications/Cxx/gdcmscanner.cxx
@@ -300,6 +300,11 @@ int main(int argc, char *argv[])
gdcm::Directory d;
unsigned int nfiles = d.Load( dirname.c_str(), recursive );
+ if( !nfiles )
+ {
+ std::cerr << "No files found in: " << dirname << std::endl;
+ return 1;
+ }
if( verbose ) d.Print( std::cout );
if( !table )
std::cout << "done retrieving file list " << nfiles << " files found." << std::endl;
https://sourceforge.net/p/gdcm/gdcm/ci/3294558df95ff871216e16264ebfab3b5d24f752/
commit 3294558df95ff871216e16264ebfab3b5d24f752
Author: Mathieu Malaterre <mat...@gm...>
Date: Tue Sep 10 14:15:19 2019 +0200
Properly return the correct type
diff --git a/Source/Common/gdcmDirectory.cxx b/Source/Common/gdcmDirectory.cxx
index db27359e1..045cf2a1e 100644
--- a/Source/Common/gdcmDirectory.cxx
+++ b/Source/Common/gdcmDirectory.cxx
@@ -40,7 +40,7 @@ unsigned int Directory::Load(FilenameType const &name, bool recursive)
Toplevel = name;
return Explore( Toplevel, recursive );
}
- return false;
+ return 0;
}
unsigned int Directory::Explore(FilenameType const &name, bool recursive)
https://sourceforge.net/p/gdcm/gdcm/ci/d291c460a5064428d34aa58c7315a44091a7a7a6/
commit d291c460a5064428d34aa58c7315a44091a7a7a6
Author: Mathieu Malaterre <mat...@gm...>
Date: Tue Sep 10 12:21:27 2019 +0200
Minimal work to have a dctable equivalent tool
diff --git a/Applications/Cxx/gdcmscanner.cxx b/Applications/Cxx/gdcmscanner.cxx
index 5318f1f15..32f6e6f3e 100644
--- a/Applications/Cxx/gdcmscanner.cxx
+++ b/Applications/Cxx/gdcmscanner.cxx
@@ -62,6 +62,7 @@ static void PrintHelp()
std::cout << " -p --print Print output." << std::endl;
std::cout << " -r --recursive Recusively descend directory." << std::endl;
std::cout << " --strict Use strict parser (faster but less tolerant with bogus DICOM files)." << std::endl;
+ std::cout << " --table Use Table output." << std::endl;
std::cout << "General Options:" << std::endl;
std::cout << " -V --verbose more verbose (warning+error)." << std::endl;
std::cout << " -W --warning print warning info." << std::endl;
@@ -76,7 +77,7 @@ typedef std::vector<gdcm::PrivateTag> VectorPrivateTags;
template < typename TScanner >
static int DoIt(
gdcm::Directory const & d,
- bool const & print ,
+ bool const & print , int table,
VectorTags const & tags,
VectorPrivateTags const & privatetags)
{
@@ -97,7 +98,13 @@ static int DoIt(
std::cerr << "Scanner failed" << std::endl;
return 1;
}
- if (print) s.Print( std::cout );
+ if (print)
+ {
+ if(table)
+ s.PrintTable( std::cout );
+ else
+ s.Print( std::cout );
+ }
return 0;
}
@@ -117,6 +124,7 @@ int main(int argc, char *argv[])
gdcm::PrivateTag privatetag;
int strict = 0;
+ int table = 0;
int verbose = 0;
int warning = 0;
int debug = 0;
@@ -134,6 +142,7 @@ int main(int argc, char *argv[])
{"print", 1, nullptr, 0},
{"private-tag", 1, nullptr, 0},
{"strict", 0, &strict, 1},
+ {"table", 0, &table, 1},
// General options !
{"verbose", 0, &verbose, 1},
@@ -292,9 +301,10 @@ int main(int argc, char *argv[])
gdcm::Directory d;
unsigned int nfiles = d.Load( dirname.c_str(), recursive );
if( verbose ) d.Print( std::cout );
- std::cout << "done retrieving file list " << nfiles << " files found." << std::endl;
+ if( !table )
+ std::cout << "done retrieving file list " << nfiles << " files found." << std::endl;
if( strict )
- return DoIt<gdcm::StrictScanner>(d,print,tags,privatetags);
- return DoIt<gdcm::Scanner>(d,print,tags,privatetags);
+ return DoIt<gdcm::StrictScanner>(d,print,table,tags,privatetags);
+ return DoIt<gdcm::Scanner>(d,print,table,tags,privatetags);
}
diff --git a/Source/MediaStorageAndFileFormat/gdcmAnonymizer.cxx b/Source/MediaStorageAndFileFormat/gdcmAnonymizer.cxx
index ac23d8942..dd8a3db18 100644
--- a/Source/MediaStorageAndFileFormat/gdcmAnonymizer.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmAnonymizer.cxx
@@ -743,7 +743,7 @@ catch(...)
}
-bool IsVRUI(Tag const &tag)
+static bool IsVRUI(Tag const &tag)
{
static const Global &g = Global::GetInstance();
static const Dicts &dicts = g.GetDicts();
diff --git a/Source/MediaStorageAndFileFormat/gdcmScanner.cxx b/Source/MediaStorageAndFileFormat/gdcmScanner.cxx
index 3dec7da65..1114d17ab 100644
--- a/Source/MediaStorageAndFileFormat/gdcmScanner.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmScanner.cxx
@@ -202,6 +202,51 @@ void Scanner::Print( std::ostream & os ) const
}
}
+static bool IsVRUI(Tag const &tag)
+{
+ static const Global &g = Global::GetInstance();
+ static const Dicts &dicts = g.GetDicts();
+ const DictEntry &dictentry = dicts.GetDictEntry(tag);
+ if( dictentry.GetVR() == VR::UI ) return true;
+ //if( tag == Tag(0x0020,0x000d) // Study Instance UID : UI
+ // || tag == Tag(0x0020,0x0052) //
+ // || tag == Tag(0x0020,0x000e) ) // Series Instance UID : UI
+ // {
+ // return true;
+ // }
+ return false;
+}
+
+void Scanner::PrintTable( std::ostream & os ) const
+{
+ Directory::FilenamesType::const_iterator file = Filenames.begin();
+ for(; file != Filenames.end(); ++file)
+ {
+ const char *filename = file->c_str();
+ assert( filename && *filename );
+ bool b = IsKey(filename);
+ const char *comment = !b ? "could not be read" : "could be read";
+ os << '"' << filename << '"' << "\t";
+ //const FilenameToValue &mapping = Mappings[*tag];
+ TagsType::const_iterator tag = Tags.begin();
+ const TagToValue &mapping = GetMapping(filename);
+ for( ; tag != Tags.end(); ++tag )
+ {
+ const Tag &t = *tag;
+ bool isui = IsVRUI(t);
+ const char *value = "";
+ if( mapping.find(t) != mapping.end() ) {
+ const char * v = mapping.find(t)->second;
+ //const char* value = this->GetValue(filename, *tag);
+ if(v) value = v;
+ }
+ os << '"' << (isui ? String<>::Trim( value ) : value) << '"';
+ os << "\t";
+ }
+ os << "\n";
+ }
+}
+
Scanner::TagToValue const & Scanner::GetMapping(const char *filename) const
{
// assert( Mappings.find(filename) != Mappings.end() );
diff --git a/Source/MediaStorageAndFileFormat/gdcmScanner.h b/Source/MediaStorageAndFileFormat/gdcmScanner.h
index 9b4090562..be898dada 100644
--- a/Source/MediaStorageAndFileFormat/gdcmScanner.h
+++ b/Source/MediaStorageAndFileFormat/gdcmScanner.h
@@ -89,6 +89,8 @@ public:
/// Print result
void Print( std::ostream & os ) const override;
+ void PrintTable( std::ostream & os ) const;
+
/// Check if filename is a key in the Mapping table.
/// returns true only of file can be found, which means
/// the file was indeed a DICOM file that could be processed
diff --git a/Source/MediaStorageAndFileFormat/gdcmStrictScanner.cxx b/Source/MediaStorageAndFileFormat/gdcmStrictScanner.cxx
index a8d5356c1..9699942bc 100644
--- a/Source/MediaStorageAndFileFormat/gdcmStrictScanner.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmStrictScanner.cxx
@@ -211,6 +211,51 @@ void StrictScanner::Print( std::ostream & os ) const
}
}
+static bool IsVRUI(Tag const &tag)
+{
+ static const Global &g = Global::GetInstance();
+ static const Dicts &dicts = g.GetDicts();
+ const DictEntry &dictentry = dicts.GetDictEntry(tag);
+ if( dictentry.GetVR() == VR::UI ) return true;
+ //if( tag == Tag(0x0020,0x000d) // Study Instance UID : UI
+ // || tag == Tag(0x0020,0x0052) //
+ // || tag == Tag(0x0020,0x000e) ) // Series Instance UID : UI
+ // {
+ // return true;
+ // }
+ return false;
+}
+
+void StrictScanner::PrintTable( std::ostream & os ) const
+{
+ Directory::FilenamesType::const_iterator file = Filenames.begin();
+ for(; file != Filenames.end(); ++file)
+ {
+ const char *filename = file->c_str();
+ assert( filename && *filename );
+ bool b = IsKey(filename);
+ const char *comment = !b ? "could not be read" : "could be read";
+ os << '"' << filename << '"' << "\t";
+ //const FilenameToValue &mapping = Mappings[*tag];
+ TagsType::const_iterator tag = Tags.begin();
+ const TagToValue &mapping = GetMapping(filename);
+ for( ; tag != Tags.end(); ++tag )
+ {
+ const Tag &t = *tag;
+ bool isui = IsVRUI(t);
+ const char *value = "";
+ if( mapping.find(t) != mapping.end() ) {
+ const char * v = mapping.find(t)->second;
+ //const char* value = this->GetValue(filename, *tag);
+ if(v) value = v;
+ }
+ os << '"' << (isui ? String<>::Trim( value ) : value) << '"';
+ os << "\t";
+ }
+ os << "\n";
+ }
+}
+
StrictScanner::TagToValue const & StrictScanner::GetMapping(const char *filename) const
{
// assert( Mappings.find(filename) != Mappings.end() );
diff --git a/Source/MediaStorageAndFileFormat/gdcmStrictScanner.h b/Source/MediaStorageAndFileFormat/gdcmStrictScanner.h
index f7f8636e3..607ca19c0 100644
--- a/Source/MediaStorageAndFileFormat/gdcmStrictScanner.h
+++ b/Source/MediaStorageAndFileFormat/gdcmStrictScanner.h
@@ -89,6 +89,8 @@ public:
/// Print result
void Print( std::ostream & os ) const override;
+ void PrintTable( std::ostream & os ) const;
+
/// Check if filename is a key in the Mapping table.
/// returns true only of file can be found, which means
/// the file was indeed a DICOM file that could be processed
-----------------------------------------------------------------------
Summary of changes:
Applications/Cxx/gdcmscanner.cxx | 92 ++++++++++++++--------
Source/Common/gdcmDirectory.cxx | 2 +-
.../MediaStorageAndFileFormat/gdcmAnonymizer.cxx | 2 +-
Source/MediaStorageAndFileFormat/gdcmScanner.cxx | 45 +++++++++++
Source/MediaStorageAndFileFormat/gdcmScanner.h | 2 +
.../gdcmStrictScanner.cxx | 45 +++++++++++
.../MediaStorageAndFileFormat/gdcmStrictScanner.h | 2 +
7 files changed, 157 insertions(+), 33 deletions(-)
hooks/post-receive
--
Grassroots DICOM
|