37 std::list<mitk::DICOMFileReader::Pointer>
48 const std::vector<us::ModuleResource> configs =
51 for (
auto iter = configs.cbegin(); iter != configs.cend(); ++iter )
61 stream.seekg(0, std::ios::end);
62 s.reserve(stream.tellg());
63 stream.seekg(0, std::ios::beg);
65 s.assign((std::istreambuf_iterator<char>(stream)),
66 std::istreambuf_iterator<char>());
84 stream.seekg(0, std::ios::end);
85 s.reserve(stream.tellg());
86 stream.seekg(0, std::ios::beg);
88 s.assign((std::istreambuf_iterator<char>(stream)),
89 std::istreambuf_iterator<char>());
100 this->AddConfigFromResource(r);
107 if (reader.IsNotNull())
109 m_Readers.push_back( reader );
119 this->AddConfigFromResource(
"configurations/3D/instancenumber.xml");
120 this->AddConfigFromResource(
"configurations/3D/instancenumber_soft.xml");
121 this->AddConfigFromResource(
"configurations/3D/slicelocation.xml");
122 this->AddConfigFromResource(
"configurations/3D/imageposition.xml");
123 this->AddConfigFromResource(
"configurations/3D/imageposition_byacquisition.xml");
131 this->AddConfigsFromResources(
"configurations/3DnT");
141 if (reader.IsNotNull())
143 m_Readers.push_back( reader );
144 m_PossibleConfigurations.push_back(xmlDescription);
148 std::stringstream ss;
149 ss <<
"Could not parse reader configuration. Ignoring it.";
150 throw std::invalid_argument( ss.str() );
158 std::ifstream file(filename.c_str());
161 file.seekg(0, std::ios::end);
162 s.reserve(file.tellg());
163 file.seekg(0, std::ios::beg);
165 s.assign((std::istreambuf_iterator<char>(file)),
166 std::istreambuf_iterator<char>());
175 m_InputFilenames = filenames;
182 return m_InputFilenames;
193 gdcmScanner->SetInputFiles( m_InputFilenames );
196 for (
auto rIter = m_Readers.cbegin(); rIter != m_Readers.cend(); ++rIter )
198 gdcmScanner->AddTagPaths((*rIter)->GetTagsOfInterest());
204 unsigned int readerIndex(0);
205 for (
auto rIter = m_Readers.cbegin(); rIter != m_Readers.cend(); ++readerIndex, ++rIter )
207 (*rIter)->SetInputFiles( m_InputFilenames );
208 (*rIter)->SetTagCache( gdcmScanner->GetScanCache() );
211 (*rIter)->AnalyzeInputFiles();
212 workingCandidates.push_back( *rIter );
213 MITK_INFO <<
"Reader " << readerIndex <<
" (" << (*rIter)->GetConfigurationLabel() <<
") suggests " << (*rIter)->GetNumberOfOutputs() <<
" 3D blocks";
214 if ((*rIter)->GetNumberOfOutputs() == 1)
216 MITK_DEBUG <<
"Early out with reader #" << readerIndex <<
" (" << (*rIter)->GetConfigurationLabel() <<
"), less than 1 block is not possible";
220 catch (
const std::exception& e )
222 MITK_ERROR <<
"Reader " << readerIndex <<
" (" << (*rIter)->GetConfigurationLabel() <<
") threw exception during file analysis, ignoring this reader. Exception: " << e.what();
226 MITK_ERROR <<
"Reader " << readerIndex <<
" (" << (*rIter)->GetConfigurationLabel() <<
") threw unknown exception during file analysis, ignoring this reader.";
234 unsigned int bestReaderIndex(0);
236 for (
auto rIter = workingCandidates.cbegin(); rIter != workingCandidates.cend(); ++readerIndex, ++rIter )
238 const unsigned int thisReadersNumberOfOutputs = (*rIter)->GetNumberOfOutputs();
239 if ( thisReadersNumberOfOutputs > 0
240 && thisReadersNumberOfOutputs < minimumNumberOfOutputs )
242 minimumNumberOfOutputs = (*rIter)->GetNumberOfOutputs();
244 bestReaderIndex = readerIndex;
248 MITK_DEBUG <<
"Decided for reader #" << bestReaderIndex <<
" (" << bestReader->GetConfigurationLabel() <<
")";
249 MITK_DEBUG << m_PossibleConfigurations[bestReaderIndex];
itk::SmartPointer< Self > Pointer
void AddConfigFile(const std::string &filename)
Add a configuration as expected by DICOMReaderConfigurator. Configs can only be reset by instantiatin...
std::list< DICOMFileReader::Pointer > ReaderList
void AddConfig(const std::string &xmlDescription)
Add a configuration as expected by DICOMReaderConfigurator. Configs can only be reset by instantiatin...
void SetInputFiles(StringList filenames)
Input files.
void AddConfigFromResource(const std::string &resourcename)
ReaderList GetAllConfiguredReaders() const
Return all the DICOMFileReaders that are currently used for selection by this class. The readers returned by this method depend on what config files have been added earlier (or which of the built-in readers have been loaded)
virtual ~DICOMFileReaderSelector()
Module * GetModule() const
static const std::string filename
const StringList & GetInputFiles() const
Input files.
void AddConfigsFromResources(const std::string &path)
std::vector< std::string > StringList
DICOMFileReaderSelector()
void LoadBuiltIn3DnTConfigs()
Load 3D+t image creating configurations from the MITK module system (see mitk::Module::FindResources)...
DICOMFileReader::Pointer GetFirstReaderWithMinimumNumberOfOutputImages()
Execute the analysis and selection process. The first reader with a minimal number of outputs will be...
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
void LoadBuiltIn3DConfigs()
Load 3D image creating configurations from the MITK module system (see mitk::Module::FindResources). For a default set of configurations, look into the directory Resources of the DICOMReader module.
void AddFileReaderCanditate(DICOMFileReader::Pointer reader)
Add a whole pre-configured reader to the selection process.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.