本文整理汇总了C++中FileListType类的典型用法代码示例。如果您正苦于以下问题:C++ FileListType类的具体用法?C++ FileListType怎么用?C++ FileListType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileListType类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CopyResources
/// Copy derived resources from first time step. Append _reg tag, but leave data untouched.
static void CopyResources(FileListType fileList, std::string outputPath)
{
for (unsigned int j=0; j < fileList.size(); j++)
{
std::string derivedResourceFilename = fileList.at(j);
std::string fileType = itksys::SystemTools::GetFilenameExtension(derivedResourceFilename);
std::string fileStem = itksys::SystemTools::GetFilenameWithoutExtension(derivedResourceFilename);
std::string savePathAndFileName = outputPath +fileStem + "_reg." + fileType;
MITK_INFO << "Copy resource " << savePathAndFileName;
mitk::Image::Pointer resImage = mitk::IOUtil::LoadImage(derivedResourceFilename);
mitk::IOUtil::SaveImage(resImage, savePathAndFileName);
}
}
示例2: CreateDerivedFileList
/// Build a derived file name from moving images e.g. xxx_T2.nrrd becomes xxx_GTV.nrrd
static FileListType CreateDerivedFileList(std::string baseFN, std::string baseSuffix, std::vector<std::string> derivedPatterns)
{
FileListType files;
for (unsigned int i=0; i < derivedPatterns.size(); i++)
{
std::string derResourceSuffix = derivedPatterns.at(i);
std::string derivedResourceFilename = baseFN.substr(0,baseFN.length() -baseSuffix.length()) + derResourceSuffix;
MITK_INFO <<" Looking for file: " << derivedResourceFilename;
if (!itksys::SystemTools::FileExists(derivedResourceFilename.c_str()))
{
MITK_INFO << "CreateDerivedFileList: File does not exit. Skipping entry.";
continue;
}
files.push_back(derivedResourceFilename);
}
return files;
}
示例3: CreateFileList
/// Create list of all files in provided folder ending with same postfix
static FileListType CreateFileList(std::string folder , std::string postfix)
{
itk::Directory::Pointer dir = itk::Directory::New();
FileListType fileList;
if( dir->Load(folder.c_str() ) )
{
int n = dir->GetNumberOfFiles();
for(int r=0;r<n;r++)
{
std::string filename = dir->GetFile( r );
if (filename == "." || filename == "..")
continue;
filename = folder + filename;
if (!itksys::SystemTools::FileExists( filename.c_str()))
continue;
if (filename.substr(filename.length() -postfix.length() ) == postfix)
fileList.push_back(filename);
}
}
return fileList;
}
示例4: BatchedFolderRegistration
int BatchedFolderRegistration( int argc, char* argv[] )
{
ctkCommandLineParser parser;
parser.setArgumentPrefix("--","-");
// Add command line argument names
parser.addArgument("help", "h",ctkCommandLineParser::Bool, "Show this help text");
parser.addArgument("xml", "x",ctkCommandLineParser::Bool, "Print a XML description of this modules command line interface");
//parser.addArgument("usemask", "u", QVariant::Bool, "Use segmentations (derived resources) to exclude areas from registration metrics");
parser.addArgument("input", "i", ctkCommandLineParser::String, "Input folder",us::Any(),false);
parser.addArgument("output", "o", ctkCommandLineParser::String, "Output folder (ending with /)",us::Any(),false);
parser.addArgument("fixed", "f", ctkCommandLineParser::String, "Suffix for fixed image",us::Any(),false);
parser.addArgument("moving", "m", ctkCommandLineParser::String, "Suffix for moving images",us::Any(),false);
parser.addArgument("derived", "d", ctkCommandLineParser::String, "Derived resources suffixes (replaces suffix for moving images); comma separated",us::Any(),true);
parser.addArgument("silent", "s", ctkCommandLineParser::Bool, "No xml progress output.");
// Feature currently disabled
//parser.addArgument("resample", "r", QVariant::String, "Reference Image for resampling (optional), is not applied to tensor data");
map<string, us::Any> parsedArgs = parser.parseArguments(argc, argv);
// Handle special arguments
bool silent = false;
{
if (parsedArgs.size() == 0)
{
MITK_ERROR << "Missig arguements" ;
return EXIT_FAILURE;
}
if (parsedArgs.count("xml"))
{
MITK_ERROR << "This is to be handled by shell script";
return EXIT_SUCCESS;
}
if (parsedArgs.count("silent"))
silent = true;
// Show a help message
if ( parsedArgs.count("help") || parsedArgs.count("h"))
{
std::cout << parser.helpText();
return EXIT_SUCCESS;
}
}
std::string outputPath = us::any_cast<string>(parsedArgs["output"]);
std::string refPattern = us::any_cast<string>(parsedArgs["fixed"]);
std::string inputPath = us::any_cast<string>(parsedArgs["input"]);
std::string movingImgPattern = us::any_cast<string>(parsedArgs["moving"]);
//QString resampleReference = parsedArgs["resample"].toString();
//bool maskTumor = parsedArgs["usemask"].toBool();
// if derived sources pattern is provided, populate QStringList with possible filename postfixes
std::vector<std::string> derPatterns;
if (parsedArgs.count("derived") || parsedArgs.count("d") )
{
std::string arg = us::any_cast<string>(parsedArgs["derived"]);
derPatterns = split(arg ,',');
}
MITK_INFO << "Input Folder : " << inputPath;
MITK_INFO << "Looking for reference image ...";
FileListType referenceFileList = CreateFileList(inputPath,refPattern);
if (referenceFileList.size() != 1)
{
MITK_ERROR << "None or more than one possible reference images (" << refPattern <<") found. Exiting." << referenceFileList.size();
MITK_INFO << "Choose a fixed arguement that is unique in the given folder!";
return EXIT_FAILURE;
}
std::string referenceFileName = referenceFileList.at(0);
MITK_INFO << "Loading Reference (fixed) image: " << referenceFileName;
mitk::Image::Pointer refImage = mitk::IOUtil::LoadImage(referenceFileName);
if (refImage.IsNull())
MITK_ERROR << "Loaded fixed image is NULL";
// Copy reference image to destination
std::string savePathAndFileName = GetSavePath(outputPath, referenceFileName);
mitk::IOUtil::SaveImage(refImage, savePathAndFileName);
// Copy all derived resources also to output folder, adding _reg suffix
referenceFileList = CreateDerivedFileList(referenceFileName, movingImgPattern,derPatterns);
CopyResources(referenceFileList, outputPath);
std::string derivedResourceFilename;
mitk::Image::Pointer referenceMask = NULL; // union of all segmentations
if (!silent)
{
// XML Output to report progress
std::cout << "<filter-start>";
std::cout << "<filter-name>Batched Registration</filter-name>";
std::cout << "<filter-comment>Starting registration ... </filter-comment>";
std::cout << "</filter-start>";
}
// Now iterate over all files and register them to the reference image,
//.........这里部分代码省略.........
示例5: main
//.........这里部分代码省略.........
}
std::string outputPath = us::any_cast<string>(parsedArgs["output"]);
std::string inputPath = us::any_cast<string>(parsedArgs["input"]);
//QString resampleReference = parsedArgs["resample"].toString();
//bool maskTumor = parsedArgs["usemask"].toBool();
// if derived sources pattern is provided, populate QStringList with possible filename postfixes
std::vector<std::string> derPatterns;
if (parsedArgs.count("derived") || parsedArgs.count("d") )
{
std::string arg = us::any_cast<string>(parsedArgs["derived"]);
derPatterns = split(arg ,',');
}
std::vector<std::string> spacings;
float spacing[3];
bool doResampling = false;
if (parsedArgs.count("resample") || parsedArgs.count("d") )
{
std::string arg = us::any_cast<string>(parsedArgs["resample"]);
spacings = split(arg ,',');
spacing[0] = atoi(spacings.at(0).c_str());
spacing[1] = atoi(spacings.at(1).c_str());
spacing[2] = atoi(spacings.at(2).c_str());
doResampling = true;
}
MITK_INFO << "Input Folder : " << inputPath;
MITK_INFO << "Looking for reference image ...";
FileListType referenceFileList = CreateFileList(inputPath,refPattern);
if ((!useFirstMoving && referenceFileList.size() != 1) || (useFirstMoving && referenceFileList.size() == 0))
{
MITK_ERROR << "None or more than one possible reference images (" << refPattern <<") found. Exiting." << referenceFileList.size();
MITK_INFO << "Choose a fixed arguement that is unique in the given folder!";
return EXIT_FAILURE;
}
std::string referenceFileName = referenceFileList.at(0);
MITK_INFO << "Loading Reference (fixed) image: " << referenceFileName;
std::string fileType = itksys::SystemTools::GetFilenameExtension(referenceFileName);
mitk::Image::Pointer refImage = ExtractFirstTS(mitk::IOUtil::LoadImage(referenceFileName), fileType);
mitk::Image::Pointer resampleReference = NULL;
if (doResampling)
{
refImage = ResampleBySpacing(refImage,spacing);
resampleReference = refImage;
}
if (refImage.IsNull())
MITK_ERROR << "Loaded fixed image is NULL";
// Copy reference image to destination
std::string savePathAndFileName = GetSavePath(outputPath, referenceFileName);
mitk::IOUtil::SaveImage(refImage, savePathAndFileName);
// Copy all derived resources also to output folder, adding _reg suffix
referenceFileList = CreateDerivedFileList(referenceFileName, movingImgPattern,derPatterns);
CopyResources(referenceFileList, outputPath);