35 FileName fn_in, fn_out, fn_root, fn_cc;
36 String sortLabelStr, extension;
40 std::vector<MetaDataVec> mdVector;
41 bool dont_randomize, dont_remove_disabled, dont_sort, use_cc;
43 int AHCiter, AHCsubset;
49 addUsageLine(
"Split a metadata (randomly by default) in any number of equally sized output metadata.");
50 addUsageLine(
"By default, only enabled entries in the input file will be written to the output files.");
53 addParamsLine(
" [ -n <parts=2> ] : Number of output MetaDatas");
54 addParamsLine(
" [ --oroot <rootname=\"\"> ] : Rootname for output MetaDatas");
56 addParamsLine(
" [--dont_randomize ] : Do not generate random groups");
57 addParamsLine(
" [--dont_sort ] : Do not sort the outputs MetaData");
58 addParamsLine(
" [--dont_remove_disabled]: Do not remove disabled images from MetaData");
59 addParamsLine(
" [--use_correlation <fnCC=\"\"> <iter=100> <subset=16>] : Use correlation to a single volume.");
60 addParamsLine(
" : This is the output of xmipp_reconstruct_significant");
62 addParamsLine(
" :+ The metadata is splitted by taking random subsets of the projection");
63 addParamsLine(
" :+ directions and applying hierarchical clustering a number of");
65 addParamsLine(
" [-l <label=\"image\">] : sort using a label, default image");
70 addExampleLine(
" xmipp_metadata_split -i input.sel --oroot output_part");
71 addExampleLine(
"Splits input.sel in 4 output files without randomizing input metdata:",
false);
72 addExampleLine(
" xmipp_metadata_split -i input.sel -n 4 --dont_randomize");
73 addExampleLine(
"Splits input.sel in two parts with sel extension:",
false);
74 addExampleLine(
" xmipp_metadata_split -i input.sel --oroot output_part:sel");
86 if (extension.empty())
88 dont_randomize =
checkParam(
"--dont_randomize");
90 dont_remove_disabled =
checkParam(
"--dont_remove_disabled");
94 fn_cc =
getParam(
"--use_correlation",0);
100 sortLabelStr =
"objId";
125 size_t Num_images = mdPtr->
size();
126 size_t Num_groups =
XMIPP_MIN(N, Num_images);
128 mdPtr->
split(Num_groups, mdVector);
134 auto Ndirs=(int)
XSIZE(mcc);
135 auto Nvols=(int)
YSIZE(mcc);
136 auto Nimgs=(int)
ZSIZE(mcc);
155 for (
int i=0;
i<Nimgs-1; ++
i)
156 for (
int j=
i+1;
j<Nimgs; ++
j)
176 for (
size_t k=0;
k<Num_groups; ++
k)
177 mdVector.push_back(dummy);
180 for (
auto& row : *mdPtr)
188 for (
size_t i = 0;
i < Num_groups; ++
i)
190 fn_out.
compose(fn_root,
i + 1, extension);
193 mdPtr->
sort(mdVector[
i], sortLabel);
195 mdPtr = &(mdVector[
i]);
197 mdPtr->
write(fn_out);
#define FOR_ALL_ELEMENTS_IN_MATRIX2D(m)
static MDLabel str2Label(const String &labelName)
#define REPORT_ERROR(nerr, ErrormMsg)
FileName removeFileFormat() const
void compose(const String &str, const size_t no, const String &ext="")
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
void addSeeAlsoLine(const char *seeAlso)
void resizeNoCopy(int Ydim, int Xdim)
#define MAT_ELEM(m, i, j)
void clusterData(const Matrix2D< double > &X, int numberOfClusters=2, int distance=2, int linkageType=1)
#define A3D_ELEM(V, k, i, j)
Matrix1D< int > clusterAssigned
const char * getParam(const char *param, int arg=0)
Incorrect argument received.
void addExampleLine(const char *example, bool verbatim=true)
void clusterWithDistance(const Matrix2D< double > &D, int numberOfClusters=2, int linkageType=1)
FileName withoutExtension() const
String getFileFormat() const
bool checkParam(const char *param)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
void addUsageLine(const char *line, bool verbatim=false)
int getIntParam(const char *param, int arg=0)
void addParamsLine(const String &line)