本文整理汇总了C++中MetaData::read方法的典型用法代码示例。如果您正苦于以下问题:C++ MetaData::read方法的具体用法?C++ MetaData::read怎么用?C++ MetaData::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetaData
的用法示例。
在下文中一共展示了MetaData::read方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
PyObject * xmipp_MetaDataInfo(PyObject *obj, PyObject *args, PyObject *kwargs)
{
PyObject *pyValue; //Only used to skip label and value
if (PyArg_ParseTuple(args, "O", &pyValue))
{
try
{
MetaData *md = NULL;
size_t size; //number of elements in the metadata
bool destroyMd = true;
if (PyString_Check(pyValue))
{
char * str = PyString_AsString(pyValue);
md = new MetaData();
md->setMaxRows(1);
md->read(str);
size = md->getParsedLines();
}
else if (FileName_Check(pyValue))
{
md = new MetaData();
md->setMaxRows(1);
md->read(FileName_Value(pyValue));
size = md->getParsedLines();
}
else if (MetaData_Check(pyValue))
{
md = ((MetaDataObject*)pyValue)->metadata;
destroyMd = false;
size = md->size();
}
else
{
PyErr_SetString(PyXmippError, "Invalid argument: expected String, FileName or MetaData");
return NULL;
}
size_t xdim, ydim, zdim, ndim;
getImageSize(*md, xdim, ydim, zdim, ndim);
if (destroyMd)
delete md;
return Py_BuildValue("iiikk", xdim, ydim, zdim, ndim, size);
}
catch (XmippError &xe)
{
PyErr_SetString(PyXmippError, xe.msg.c_str());
}
}
return NULL;
}/* Metadata info (from metadata filename)*/
示例2: read_coordinates
/* Read coordinates from disk ---------------------------------------------- */
void Micrograph::read_coordinates(int label, const FileName &_fn_coords)
{
std::ifstream fh;
int line_no = 0;
std::string line;
fn_coords = _fn_coords;
MetaData MD;
MD.read(fn_coords);
line_no = MD.size();
// Resize coordinate list and read
coords.reserve(line_no);
struct Particle_coords aux;
aux.valid = true;
aux.label = label;
aux.cost = 1;
FOR_ALL_OBJECTS_IN_METADATA(MD)
{
MD.getValue(MDL_XCOOR, aux.X, __iter.objId); //aux.X=x;
MD.getValue(MDL_YCOOR, aux.Y, __iter.objId); //aux.Y=y;
coords.push_back(aux);
}
}
示例3: read
std::istream& read(std::istream &is) {
assert(is.good());
metaData.read(is);
reserve(metaData.getBytes());
is.read(data, metaData.getBytes());
assert(is.good());
return is;
}
示例4: getData
vector<MetaData> getData(const char *dir,const char *id)
{
char fileName[100];
strcpy(fileName,dir);
strcat(fileName,idpre);
strcat(fileName,id);
strcat(fileName,".csv");
FILE *fp=fopen(fileName,"r");
vector<MetaData> res;
MetaData tmp;
while(tmp.read(fp)!=NULL)
{
res.push_back(tmp);
}
return res;
}
示例5: selectPartFromMd
void MpiProgImageRotationalPCA::selectPartFromMd(MetaData &MDin)
{
if (IS_MASTER)
{
ProgImageRotationalPCA::selectPartFromMd(MDin);
MDin.write(fnRoot + "_temp.xmd");
node->barrierWait();
node->barrierWait();
unlink((fnRoot + "_temp.xmd").c_str());
}
else
{
node->barrierWait();
MDin.read(fnRoot + "_temp.xmd");
node->barrierWait();
}
}
示例6: while
// Outliers ===============================================================
void ProgClassifyCL2DCore::computeCores()
{
if (verbose && node->rank==0)
std::cerr << "Computing cores ...\n";
ProgAnalyzeCluster analyzeCluster;
analyzeCluster.verbose=0;
analyzeCluster.NPCA=NPCA;
analyzeCluster.Niter=10;
analyzeCluster.distThreshold=thPCAZscore;
analyzeCluster.dontMask=false;
MetaData MD;
size_t first, last;
size_t Nblocks=blocks.size();
if (verbose && node->rank==0)
init_progress_bar(Nblocks);
while (taskDistributor->getTasks(first, last))
for (size_t idx=first; idx<=last; ++idx)
{
// Remove outliers in the PCA projection
analyzeCluster.SFin.clear();
analyzeCluster.fnSel=blocks[idx].block+"@"+blocks[idx].fnLevel;
analyzeCluster.fnOut=blocks[idx].fnLevel.insertBeforeExtension((String)"_core_"+blocks[idx].block);
analyzeCluster.run();
// Remove outliers from file
MD.read(analyzeCluster.fnOut);
MD.removeDisabled();
MD.write(analyzeCluster.fnOut,MD_APPEND);
if (verbose && node->rank==0)
progress_bar(idx);
}
taskDistributor->wait();
if (verbose && node->rank==0)
progress_bar(Nblocks);
// Gather all results
gatherResults(0,"core");
}
示例7: run
void run()
{
// Get angles ==============================================================
MetaData angles;
angles.read(fnIn);
size_t AngleNo = angles.size();
if (AngleNo == 0 || !angles.containsLabel(MDL_ANGLE_ROT))
REPORT_ERROR(ERR_MD_BADLABEL, "Input file doesn't contain angular information");
double maxWeight = -99.e99;
MultidimArray<double> weight;
weight.initZeros(AngleNo);
if (angles.containsLabel(MDL_WEIGHT))
{
// Find maximum weight
int i=0;
FOR_ALL_OBJECTS_IN_METADATA(angles)
{
double w;
angles.getValue(MDL_WEIGHT,w,__iter.objId);
DIRECT_A1D_ELEM(weight,i++)=w;
maxWeight=XMIPP_MAX(w,maxWeight);
}
}
示例8: createGroupSamplingFiles
void ProgAngularProjectLibrary::createGroupSamplingFiles(void)
{
//#define DEBUGTIME
#ifdef DEBUGTIME
time_t start,end;
double time_dif;
time (&start);
#endif
//load txt file
mysampling.readSamplingFile(output_file_root,false);
#ifdef DEBUGTIME
time (&end);
time_dif = difftime (end,start);
start=end;
printf ("re-read entire sampling file after %.2lf seconds\n", time_dif );
#endif
StringVector blockList;
getBlocksInMetaDataFile(fn_groups,blockList);
FileName fn_temp, fn_exp;
FileName my_output_file_root;
MetaData SFBlock;
fn_exp = FnexperimentalImages.removeBlockName();
int igrp=1;
for (StringVector::iterator it= blockList.begin();
it!=blockList.end(); it++,igrp++)
{
my_output_file_root.compose(output_file_root + "_group",igrp,"");
std::cerr<<"Writing group sampling file "<< my_output_file_root<<std::endl;
fn_temp.compose(*it,fn_exp);
SFBlock.read(fn_temp);
if (SFBlock.size() > 0)//Do we really need this check?
//I guess so since user may have supplied a particular
//defocus classification. ROB
{
mysampling.fillExpDataProjectionDirectionByLR(fn_temp);//[email protected]_groups
if(compute_closer_sampling_point_bool)
{
//find sampling point closer to experimental point (only 0) and bool
//and save docfile with this information
mysampling.findClosestSamplingPoint(fn_temp,my_output_file_root);
}
//save saveSamplingFile
if (compute_neighbors_bool)
{
mysampling.computeNeighbors(only_winner);
mysampling.saveSamplingFile(my_output_file_root,false);
}
}
}
#ifdef DEBUGTIME
time (&end);
time_dif = difftime (end,start);
start=end;
printf ("Written all group sampling files after %.2lf seconds\n", time_dif );
#endif
}
示例9: performCompleteSearch
// Perform complete search =================================================
void ProgNmaAlignment::performCompleteSearch(const FileName &fnRandom,
int pyramidLevel) const {
String program;
String arguments;
const char * randStr = fnRandom.c_str();
// Reduce the image
FileName fnDown = formatString("%s_downimg.xmp", fnRandom.c_str());
if (pyramidLevel != 0) {
Image<double> I;
I.read(currentImgName);
selfPyramidReduce(BSPLINE3, I(), pyramidLevel);
I.write(fnDown);
} else
copyImage(currentImgName.c_str(), fnDown.c_str());
mkdir((fnRandom+"_ref").c_str(), S_IRWXU);
double angSampling=2*RAD2DEG(atan(1.0/((double) imgSize / pow(2.0, (double) pyramidLevel+1))));
angSampling=std::max(angSampling,discrAngStep);
program = "xmipp_angular_project_library";
arguments = formatString(
"-i %s_deformedPDB.vol -o %s_ref/ref.stk --sampling_rate %f -v 0",
randStr, randStr, angSampling);
if (projMatch)
arguments +=formatString(
" --compute_neighbors --angular_distance -1 --experimental_images %s_downimg.xmp", randStr);
runSystem(program, arguments, false);
String refSelStr = formatString("%s_ref/ref.doc", randStr);
if (fnmask != "") {
program = "xmipp_transform_mask";
arguments = formatString("-i %s --mask binary_file %s", refSelStr.c_str(),
fnmask.c_str());
runSystem(program, arguments, false);
}
// Perform alignment
String fnOut=formatString("%s_angledisc.xmd",randStr);
if (!projMatch) {
program = "xmipp_angular_discrete_assign";
arguments = formatString(
"-i %s_downimg.xmp --ref %s -o %s --psi_step 5 --max_shift_change %d --search5D -v 0",
randStr, refSelStr.c_str(), fnOut.c_str(), (int)round((double) imgSize / (10.0 * pow(2.0, (double) pyramidLevel))));
} else {
String refStkStr = formatString("%s_ref/ref.stk", randStr);
program = "xmipp_angular_projection_matching";
arguments = formatString(
"-i %s_downimg.xmp --ref %s -o %s --search5d_step 1 --max_shift %d -v 0",
randStr, refStkStr.c_str(), fnOut.c_str(), (int)round((double) imgSize / (10.0 * pow(2.0, (double) pyramidLevel))));
}
runSystem(program, arguments, false);
if (projMatch)
{
MetaData MD;
MD.read(fnOut);
bool flip;
size_t id=MD.firstObject();
MD.getValue(MDL_FLIP,flip,id);
if (flip)
{
// This is because continuous assignment does not understand flips
double shiftX, rot, tilt, psi, newrot, newtilt, newpsi;
// Change sign in shiftX
MD.getValue(MDL_SHIFT_X,shiftX,id);
MD.setValue(MDL_SHIFT_X,-shiftX,id);
// Change Euler angles
MD.getValue(MDL_ANGLE_ROT,rot,id);
MD.getValue(MDL_ANGLE_TILT,tilt,id);
MD.getValue(MDL_ANGLE_PSI,psi,id);
Euler_mirrorY(rot,tilt,psi,newrot,newtilt,newpsi);
MD.setValue(MDL_ANGLE_ROT,newrot,id);
MD.setValue(MDL_ANGLE_TILT,newtilt,id);
MD.setValue(MDL_ANGLE_PSI,newpsi,id);
MD.write(fnOut);
}
}
}
示例10: setDevice
int main2()
{
MultidimArray<double> preImg, avgCurr, mappedImg;
MultidimArray<double> outputMovie;
Matrix1D<double> meanStdev;
ImageGeneric movieStack;
Image<double> II;
MetaData MD; // To save plot information
FileName motionInfFile, flowFileName, flowXFileName, flowYFileName;
ArrayDim aDim;
// For measuring times (both for whole process and for each level of the pyramid)
clock_t tStart, tStart2;
#ifdef GPU
// Matrix that we required in GPU part
GpuMat d_flowx, d_flowy, d_dest;
GpuMat d_avgcurr, d_preimg;
#endif
// Matrix required by Opencv
cv::Mat flow, dest, flowx, flowy;
cv::Mat flowxPre, flowyPre;
cv::Mat avgcurr, avgstep, preimg, preimg8, avgcurr8;
cv::Mat planes[]={flowxPre, flowyPre};
int imagenum, cnt=2, div=0, flowCounter;
int h, w, levelNum, levelCounter=1;
motionInfFile=foname.replaceExtension("xmd");
std::string extension=fname.getExtension();
if (extension=="mrc")
fname+=":mrcs";
movieStack.read(fname,HEADER);
movieStack.getDimensions(aDim);
imagenum = aDim.ndim;
h = aDim.ydim;
w = aDim.xdim;
if (darkImageCorr)
{
II.read(darkRefFilename);
darkImage=II();
}
if (gainImageCorr)
{
II.read(gianRefFilename);
gainImage=II();
}
meanStdev.initZeros(4);
//avgcurr=cv::Mat::zeros(h, w,CV_32FC1);
avgCurr.initZeros(h, w);
flowxPre=cv::Mat::zeros(h, w,CV_32FC1);
flowyPre=cv::Mat::zeros(h, w,CV_32FC1);
#ifdef GPU
// Object for optical flow
FarnebackOpticalFlow d_calc;
setDevice(gpuDevice);
// Initialize the parameters for optical flow structure
d_calc.numLevels=6;
d_calc.pyrScale=0.5;
d_calc.fastPyramids=true;
d_calc.winSize=winSize;
d_calc.numIters=1;
d_calc.polyN=5;
d_calc.polySigma=1.1;
d_calc.flags=0;
#endif
// Initialize the stack for the output movie
if (saveCorrMovie)
outputMovie.initZeros(imagenum, 1, h, w);
// Correct for global motion from a cross-correlation based algorithms
if (globalShiftCorr)
{
Matrix1D<double> shiftMatrix(2);
shiftVector.reserve(imagenum);
shiftMD.read(globalShiftFilename);
FOR_ALL_OBJECTS_IN_METADATA(shiftMD)
{
shiftMD.getValue(MDL_SHIFT_X, XX(shiftMatrix), __iter.objId);
shiftMD.getValue(MDL_SHIFT_Y, YY(shiftMatrix), __iter.objId);
shiftVector.push_back(shiftMatrix);
}
}
tStart2=clock();
// Compute the average of the whole stack
fstFrame++; // Just to adapt to Li algorithm
lstFrame++; // Just to adapt to Li algorithm
if (lstFrame>=imagenum || lstFrame==1)
lstFrame=imagenum;
imagenum=lstFrame-fstFrame+1;
levelNum=sqrt(double(imagenum));
computeAvg(fname, fstFrame, lstFrame, avgCurr);
// if the user want to save the PSD
if (doAverage)
{
II()=avgCurr;
II.write(foname);
//.........这里部分代码省略.........