// ------------------------------------------------------------------------ void readFilenames(const std::string &inputDirectory, FilenamesType &imageFilenames) { QDir dir(QString::fromStdString(inputDirectory)); QStringList filters; filters << "label*"; QStringList filenames = dir.entryList(filters); for(int i = 0; i < filenames.size(); i++) { QString fname = dir.absoluteFilePath(filenames[i]); imageFilenames.push_back(fname.toStdString()); } }
// ------------------------------------------------------------------------ std::string InitialTransformExtractor::GetReferenceImageFilename() { FilenamesType targetFilenames; for(unsigned int i = 0; i < m_Filenames.size(); i++) { const char * fname = m_Filenames[i].c_str(); if(m_Mapping.count(fname) == 0) continue; // extract the image information std::string descriptionStr = m_Mapping[fname][seriesDescription]; std::string instanceNumberStr = m_Mapping[fname][instanceNumber]; QString description = QString::fromStdString(descriptionStr); unsigned int instanceNumber = QString::fromStdString(instanceNumberStr).toInt(); // check that the description is a short axis one and is instance 1 if(instanceNumber == 1 && description.contains("sa", Qt::CaseInsensitive)) { targetFilenames.push_back(m_Filenames[i]); } } // find the slice with the smallest slice position double smallest = 1000000.0; int smallestIndex; for(unsigned int i = 0; i < targetFilenames.size(); i++) { const char * fname = targetFilenames[i].c_str(); std::string slicePosition = m_Mapping[fname][sliceLocation]; double pos = QString::fromStdString(slicePosition).toDouble(); if(pos < smallest) { smallest = pos; smallestIndex = i; } } return targetFilenames[smallestIndex]; }