Xmipp  v3.23.11-Nereus
Classes | Static Public Member Functions | Friends | List of all members

#include <extract_subset.h>

Classes

class  Settings
 

Static Public Member Functions

static void createSubset (const Settings &s)
 

Friends

std::ostream & operator<< (std::ostream &os, const Settings &s)
 

Detailed Description

Class responsible for extracting particles from metadata / stack file into a new metadata / stack file

Definition at line 42 of file extract_subset.h.

Member Function Documentation

◆ createSubset()

void ExtractSubset::createSubset ( const Settings s)
static

This method will extract particles according to the passed settings. New files containing the subset shall be created.

Definition at line 29 of file extract_subset.cpp.

29  {
30  s.check();
31  auto it = s.md.ids().begin();
32  // get to proper position
33  for (size_t i = 0; i < s.first; ++i)
34  ++it;
35 
36  auto destMD = MetaDataVec();
37  auto img = Image<float>();
38  // iterate through all items
39  for (size_t i = 0; i < s.count; ++it, i++) {
40  // orig name
41  FileName origName;
42  s.md.getValue(MDL_IMAGE, origName, *it);
43  // new name
44  FileName newName;
45  newName.compose(i + 1, s.outStk); // within stk file, index images from one (1)
46  // copy row, replace name
47  MDRowVec row = s.md.getRowVec(*it);
48  row.setValue(MDL_IMAGE, newName);
49  row.setValue(MDL_ENABLED, 1);
50  destMD.addRow(row);
51  // copy image
52  // FIXME DS maybe we can do this more efficiently
53  img.read(origName);
54  img.write(newName, i, true, WRITE_APPEND);
55  }
56  // store metadata
57  destMD.write(s.outXmd);
58 }
void setValue(const MDObject &object) override
void compose(const String &str, const size_t no, const String &ext="")
#define i
Is this image enabled? (int [-1 or 1])
Name of an image (std::string)

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Settings s 
)
friend

Definition at line 89 of file extract_subset.cpp.

89  {
90  os << "Input metadata : " << s.md.getFilename() << "\n";
91  os << "Output metadata : " << s.outXmd << "\n";
92  os << "Matching items : " << s.count << "\n";
93  os << "Skip disabled : " << (s.skipDisabled ? "yes" : "no") << "\n";
94  os.flush();
95  return os;
96 }

The documentation for this class was generated from the following files: