bool mostVesselTracerPlugin::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { vector<char*> infiles, inparas, outfiles; if(input.size() >= 1) infiles = *((vector<char*> *)input.at(0).p); if(input.size() >= 2) inparas = *((vector<char*> *)input.at(1).p); if(output.size() >= 1) outfiles = *((vector<char*> *)output.at(0).p); if (func_name == tr("MOST_trace")) { return autotrace(input, output,callback); } else if (func_name == tr("help")) { cout<<"Usage : v3d -x dllname -f MOST_trace -i <inimg_file> -p <ch> <th> <seed> <slip>"<<endl; cout<<endl; cout<<"ch the input channel value, start from 1, default 1"<<endl; cout<<"th the threshold value, default 20"<<endl; cout<<"seed window size of the seed, default 20"<<endl; cout<<"slip window size to slip from seed, default 20"<<endl; cout<<"The output swc file will be named automatically based on the input image file nmae"<<endl; cout<<endl; cout<<endl; } else return false; return true; }
bool SigenPlugin::dofunc( const QString &func_name, const V3DPluginArgList &input, V3DPluginArgList & /* output */, V3DPluginCallback2 &callback, QWidget *parent) { using std::vector; if (func_name == tr("trace")) { input_PARA PARA; vector<char *> *pinfiles = (input.size() >= 1) ? (vector<char *> *)input[0].p : 0; vector<char *> *pparas = (input.size() >= 2) ? (vector<char *> *)input[1].p : 0; vector<char *> infiles = (pinfiles != 0) ? *pinfiles : vector<char *>(); vector<char *> paras = (pparas != 0) ? *pparas : vector<char *>(); if (infiles.empty()) { fprintf(stderr, "Need input image. \n"); return false; } else { PARA.inimg_file = infiles[0]; } int k = 0; PARA.channel = ((int)paras.size() >= k + 1) ? atoi(paras[k]) : 1; k++; reconstruction_func(callback, parent, PARA, /* via_gui = */ false); } else if (func_name == tr("help")) { ////HERE IS WHERE THE DEVELOPERS SHOULD UPDATE THE USAGE OF THE PLUGIN printf("**** Usage of SIGEN tracing **** \n"); printf("vaa3d -x SIGEN -f trace -i <inimg_file> -p <channel> <other parameters>\n"); printf("inimg_file The input image\n"); printf("channel Data channel for tracing. Start from 1 (default 1).\n"); printf("outswc_file Will be named automatically based on the input image file name, so you don't have to specify it.\n\n"); } else { return false; } return true; }
bool processImage(V3DPluginCallback2 &callback, const V3DPluginArgList & input, V3DPluginArgList & output, unsigned int rotateflag) { cout<<"Welcome to Rotate image"<<endl; if (input.size() != 1 || output.size() != 1) return false; char * inimg_file = ((vector<char*> *)(input.at(0).p))->at(0); char * outimg_file = ((vector<char*> *)(output.at(0).p))->at(0); cout<<"rotateflag = "<<rotateflag<<endl; cout<<"inimg_file = "<<inimg_file<<endl; cout<<"outimg_file = "<<outimg_file<<endl; unsigned char * data1d = 0; V3DLONG in_sz[4]; int datatype; if(!simple_loadimage_wrapper(callback, inimg_file, data1d, in_sz, datatype)) { cerr<<"load image "<<inimg_file<<" error!"<<endl; return false; } unsigned char* outimg = 0; V3DLONG szx=in_sz[0], szy=in_sz[1], szz=in_sz[2], szc=in_sz[3]; switch (datatype) { case 1: rotateimage(data1d, in_sz, V3D_UINT8, rotateflag, outimg); break; case 2: rotateimage(data1d, in_sz, V3D_UINT16, rotateflag, outimg); break; case 4: rotateimage(data1d, in_sz, V3D_FLOAT32, rotateflag, outimg); break; default: v3d_msg("Invalid datatype."); if (data1d) {delete []data1d; data1d=0;} return false; } // save image switch(rotateflag) { case 1: case 2: in_sz[0]=szy; in_sz[1]=szx; simple_saveimage_wrapper(callback, outimg_file, (unsigned char *)outimg, in_sz, datatype); break; case 3: in_sz[0]=szx; in_sz[1]=szy; simple_saveimage_wrapper(callback, outimg_file, (unsigned char *)outimg, in_sz, datatype); break; default: break; } if (outimg) {delete []outimg; outimg =0;} if (data1d) {delete []data1d; data1d=0;} return true; }
bool swc2eswc_io(const V3DPluginArgList & input, V3DPluginArgList & output) { cout<<"Welcome to swc2eswc_io"<<endl; vector<char*>* inlist = (vector<char*>*)(input.at(0).p); vector<char*>* outlist = NULL; if(input.size() != 1) { printf("Please specify both input file name.\n"); return false; } QString fileOpenName = QString(inlist->at(0)); QString fileSaveName; QString tmp = fileOpenName; if (output.size()==0) { printf("No outputfile specified.\n"); tmp.chop(3); fileSaveName = tmp + "eswc"; } else if (output.size()==1) { outlist = (vector<char*>*)(output.at(0).p); fileSaveName = QString(outlist->at(0)); } else { printf("You have specified more than 1 output file.\n"); return false; } NeuronTree neuron; vector<V3DLONG> segment_id, segment_layer; if (fileOpenName.endsWith(".swc") || fileOpenName.endsWith(".SWC")) { neuron = readSWC_file(fileOpenName); segment_id, segment_layer; if (!swc2eswc(neuron,segment_id, segment_layer)) { v3d_msg("Cannot convert swc to eswc.", 0); return false; } } else { v3d_msg("The file type you specified is not supported. Please check.", 0); return false; } if (!export_eswc(neuron,segment_id,segment_layer,qPrintable(fileOpenName),qPrintable(fileSaveName))) { v3d_msg("fail to write the output eswc file.", 0); return false; } return true; }
bool median_swc_func(const V3DPluginArgList & input, V3DPluginArgList & output) { if(input.size()==0) return false; //parsing input vector<char *> * inlist = (vector<char*> *)(input.at(0).p); if (inlist->size() == 0) { cerr<<"You must specify input linker or swc files"<<endl; return false; } V3DLONG neuronNum = 0; vector<NeuronTree> nt_list; QString qs_linker; QStringList nameList; for (int i=0;i<inlist->size();i++) { qs_linker = QString(inlist->at(i)); if (qs_linker.toUpper().endsWith(".ANO")) { cout<<"(0). reading a linker file."<<endl; P_ObjectFileType linker_object; if (!loadAnoFile(qs_linker,linker_object)) { fprintf(stderr,"Error in reading the linker file.\n"); return 1; } nameList = linker_object.swc_file_list; neuronNum += nameList.size(); for (V3DLONG i=0;i<neuronNum;i++) { NeuronTree tmp = readSWC_file(nameList.at(i)); nt_list.push_back(tmp); } } else if (qs_linker.toUpper().endsWith(".SWC")) { cout<<"(0). reading an swc file"<<endl; NeuronTree tmp = readSWC_file(qs_linker); nt_list.push_back(tmp); neuronNum++; } } cout << "There are "<<nt_list.size() <<" input neurons."<<endl; int idx = median_swc(nt_list); if (idx <0){ cerr << "error in median_swc()" << endl; return false; } cout<<"Median swc is " << idx << endl; return true; }
bool retype_swc::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { vector<char*> infiles, paras, outfiles; if(input.size() >= 1) infiles = *((vector<char*> *)input.at(0).p); if(input.size() >= 2) paras = *((vector<char*> *)input.at(1).p); if(output.size() >= 1) outfiles = *((vector<char*> *)output.at(0).p); if (func_name == tr("retype")) { cout<<"Welcome to swc retyping plugin"<<endl; if(infiles.empty()) { cerr<<"Need input swc file"<<endl; return false; } QString inswc_file = infiles[0]; int k=0; int type = (paras.size() >= k+1) ? atoi(paras[k]) : 3; k++;//0; QString outswc_file; if(!outfiles.empty()) outswc_file = outfiles[0]; else outswc_file = inswc_file + "_retyped.swc"; cout<<"inswc_file = "<<inswc_file.toStdString().c_str()<<endl; cout<<"node type = "<<type<<endl; cout<<"outswc_file = "<<outswc_file.toStdString().c_str()<<endl; NeuronTree nt; nt = readSWC_file(inswc_file); for(V3DLONG i = 0; i < nt.listNeuron.size(); i++) { if(nt.listNeuron[i].parent == -1) nt.listNeuron[i].type = 1; else nt.listNeuron[i].type = type; } if (!export_list2file(nt.listNeuron,outswc_file,inswc_file)) { v3d_msg("fail to write the output swc file."); return false; } } else if (func_name == tr("help")) { cout<<"Usage : v3d -x dllname -f retype -i <inswc_file> -o <outswc_file> -p <type>"<<endl; cout<<endl; } else return false; return true; }
bool RivuletPlugin::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { if (func_name == tr("tracing_func")) { bool bmenu = false; input_PARA PARA; vector<char*> * pinfiles = (input.size() >= 1) ? (vector<char*> *) input[0].p : 0; vector<char*> * pparas = (input.size() >= 2) ? (vector<char*> *) input[1].p : 0; vector<char*> infiles = (pinfiles != 0) ? * pinfiles : vector<char*>(); vector<char*> paras = (pparas != 0) ? * pparas : vector<char*>(); if(infiles.empty()) { fprintf (stderr, "Need input image. \n"); return false; } else PARA.inimg_file = infiles[0]; int k=0; PARA.channel = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; PARA.threshold = (paras.size() >= k+1) ? atoi(paras[k]) : 10; k++; PARA.stepsize = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; PARA.gap = (paras.size() >= k+1) ? atoi(paras[k]) : 15; k++; PARA.dumpbranch = (paras.size() >= k+1) ? atoi(paras[k]) : 0; k++; PARA.connectrate = (paras.size() >= k+1) ? atof(paras[k]) : 1.5; k++; PARA.percentage = (paras.size() >= k+1) ? atof(paras[k]) : 0.98; k++; if (PARA.percentage > 1.0) PARA.percentage = 1.0; PARA.sigma = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; PARA.alpha_one = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; PARA.alpha_two = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; reconstruction_func(callback,parent,PARA,bmenu); } else if (func_name == tr("help")) { printf("**** Usage of Rivulet tracing **** \n"); printf("vaa3d -x Rivulet -f tracing_func -i <inimg_file> -p <channel> <threshold> <stepsize> <gap> <dumpbranch> <connectrate> <percentage>\n"); printf("inimg_file\tThe input image\n"); printf("channel\tData channel for tracing. Start from 1 (default 1).\n"); printf("threshold\tThe background threshold for segmentation (default 10).\n"); printf("stepsize\tThe step size of gradient descent tracing (default 1).\n"); printf("gap\tThe gap allowed for steps on background voxels. Useful for noisy images (default 15)\n"); printf("dumpbranch\tWhether the unconnected branches will be dumpped. (default 0)\n"); printf("connectrate\tBranch terminis within connectrate*(radius+3) will be connected to the trunk. (default 1.5)\n"); printf("percentage\tThe converage expected on the binary image before stopping tracing. (default 0.98)\n"); printf("outswc_file\tWill be named automatically based on the input image file name, so you don't have to specify it.\n\n"); } else return false; return true; }
bool NeuroStalker::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { if (func_name == tr("tracing_func")) { bool bmenu = false; input_PARA PARA; vector<char*> * pinfiles = (input.size() >= 1) ? (vector<char*> *) input[0].p : 0; vector<char*> * pparas = (input.size() >= 2) ? (vector<char*> *) input[1].p : 0; vector<char*> infiles = (pinfiles != 0) ? * pinfiles : vector<char*>(); vector<char*> paras = (pparas != 0) ? * pparas : vector<char*>(); if(infiles.empty()) { fprintf (stderr, "Need input image. \n"); return false; } else PARA.inimg_file = infiles[0]; int k=0; PARA.channel = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; PARA.preprocessing = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; PARA.unittest = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; PARA.step = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; PARA.stepsize = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; PARA.threshold = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; cout<<"Input step test: "<<PARA.step<<endl; reconstruction_func(callback,parent,PARA,bmenu); } else if (func_name == tr("help")) { ////HERE IS WHERE THE DEVELOPERS SHOULD UPDATE THE USAGE OF THE PLUGIN printf("**** Usage of NeuroStalker tracing **** \n"); printf("vaa3d -x NeuroStalker -f tracing_func -i <inimg_file> -p <channel> <preprocessing> <run unit-tests>\n"); printf("inimg_file The input image\n"); printf("channel Data channel for tracing. Start from 1 (default 1).\n"); printf("preprocessing The preprocessing flag - 1: Crop Only; 2: Downsample; 3: Downsample and crop; \n"); printf("run unit-tests - 1: Run Tracing Only; 2: Run unit-tests only; 3: Run Both Unit Tests and Tracing; \n"); printf("outswc_file Will be named automatically based on the input image file name, so you don't have to specify it.\n\n"); } else return false; return true; }
bool neurontracing_rotation::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { if (func_name == tr("tracing_func")) { bool bmenu = false; input_PARA PARA; vector<char*> * pinfiles = (input.size() >= 1) ? (vector<char*> *) input[0].p : 0; vector<char*> * pparas = (input.size() >= 2) ? (vector<char*> *) input[1].p : 0; vector<char*> infiles = (pinfiles != 0) ? * pinfiles : vector<char*>(); vector<char*> paras = (pparas != 0) ? * pparas : vector<char*>(); if(infiles.empty()) { fprintf (stderr, "Need input image. \n"); return false; } PARA.inimg_file = infiles[0]; PARA.image = 0; int k=0; // QString inmarker_file = paras.empty() ? "" : paras[k]; if(inmarker_file == "NULL") inmarker_file = ""; k++; PARA.rotation_degree = (paras.size() >= k+1) ? atoi(paras[k]) : 36; k++; PARA.channel = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; PARA.bkg_thresh = (paras.size() >= k+1) ? atoi(paras[k]) : 10; if(PARA.bkg_thresh == atoi("AUTO")) PARA.bkg_thresh = -1;k++; PARA.b_256cube = (paras.size() >= k+1) ? atoi(paras[k]) : 0; k++; PARA.b_RadiusFrom2D = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; PARA.is_gsdt = (paras.size() >= k+1) ? atoi(paras[k]) : 0; k++; PARA.is_break_accept = (paras.size() >= k+1) ? atoi(paras[k]) : 0; k++; PARA.length_thresh = (paras.size() >= k+1) ? atoi(paras[k]) : 5; k++; reconstruction_func(callback,parent,PARA,bmenu); } else if (func_name == tr("help")) { ////HERE IS WHERE THE DEVELOPERS SHOULD UPDATE THE USAGE OF THE PLUGIN printf("**** Usage of neurontracing_rotation tracing **** \n"); printf("vaa3d -x neurontracing_rotation -f tracing_func -i <inimg_file> -p <channel> <other parameters>\n"); printf("inimg_file The input image\n"); printf("channel Data channel for tracing. Start from 1 (default 1).\n"); printf("outswc_file Will be named automatically based on the input image file name, so you don't have to specify it.\n\n"); } else return false; return true; }
bool markertree::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { vector<char*> infiles, inparas, outfiles; if(input.size() >= 1) infiles = *((vector<char*> *)input.at(0).p); if(input.size() >= 2) inparas = *((vector<char*> *)input.at(1).p); if(output.size() >= 1) outfiles = *((vector<char*> *)output.at(0).p); if (func_name == tr("help")) { v3d_msg("To be implemented"); } else return false; return true; }
bool border_tips::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { vector<char*> infiles, inparas, outfiles; if(input.size() >= 1) infiles = *((vector<char*> *)input.at(0).p); if(input.size() >= 2) inparas = *((vector<char*> *)input.at(1).p); if(output.size() >= 1) outfiles = *((vector<char*> *)output.at(0).p); if (func_name == tr("help")) { qDebug()<<"No do func available."; } else return false; return true; }
bool BlastNeuronPlugin::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { vector<char*> infiles, inparas, outfiles; if(input.size() >= 1) infiles = *((vector<char*> *)input.at(0).p); if(input.size() >= 2) inparas = *((vector<char*> *)input.at(1).p); if(output.size() >= 1) outfiles = *((vector<char*> *)output.at(0).p); if (func_name == tr("global_retrieve")) { return(global_retrieve_main(input, output)); } else if (func_name == tr("local_alignment")) { return(local_alignment_main(input, output)); } else if (func_name == tr("batch_compute")) { return (batch_compute_main(input, output)); } else if (func_name == tr("pre_processing")) { return (pre_processing_main(input, output)); } else if (func_name == tr("inverse_projection")) { return (inverse_projection_main(input, output)); } else { printf("\nBlastNeuron Plugin: rapid global retrieval and local alignent of 3D neuron morphologies. This plugin also includes pre-processing, inverse projection and batch feature computation. by Yinan Wan.\n\n"); printf("Functions:\n"); printf("\t pre_processing prune, resample and align neuron swcs.\n"); printf("\t global_retrieve given a query neuron, retrieve morphologically similar neurons from a neuron feature database.\n"); printf("\t local_alignment point to point alignment of two morphologically similar neurosn.\n"); printf("\t batch_compute generate neuron feature database (.nfb) file first to speed up neuron retrieve\n"); printf("\t invert_projection find an optimal affine transform between neuron structures regardless of topology.\n\n"); printf("Example: \n"); printf("\t vaa3d -x blastneuron -f pre_processing -p \"#i input.swc #o result.swc #l 3 #s 2 #r 1 \"\n"); printf("\t vaa3d -x blastneuron -f batch_compute -p \"#i mydatabase.ano #o features.nfb\"\n"); printf("\t vaa3d -x blastneuron -f global_retrieve -p \"#d features.nfb #q query.swc #n 10 #m 1,2,4 #o retrieve.ano\"\n"); printf("\t vaa3d -x blastneuron -f local_alignment -p \"#t target.swc #s subject.swc #o match.swc\"\n"); printf("\t vaa3d -x blastneuron -f inverse_projection -p \"#i target.swc #o target_invp.swc\"\n\n"); printf("Type vaa3d -x blastneuron -f <function_name> for instructions to run individual functions.\n"); printf("Alternatively, you can run a query search from the neuron feature database with a bash script: try \"sh blastneuron_plugin.sh\" for detailed instruction\n\n"); return true; } }
bool file_transform::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { vector<char*> infiles, inparas, outfiles; if(input.size() >= 1) infiles = *((vector<char*> *)input.at(0).p); if(input.size() >= 2) inparas = *((vector<char*> *)input.at(1).p); if(output.size() >= 1) outfiles = *((vector<char*> *)output.at(0).p); if (func_name == tr("affineImage")) { qDebug()<<"==== affine and combine images ===="; if(infiles.size()!=3 || outfiles.size()!=1){ qDebug()<<"ERROR: please set input and output!"; printHelp(); return false; } QString fname_img_tar=((vector<char*> *)(input.at(0).p))->at(0); QString fname_img_sub=((vector<char*> *)(input.at(0).p))->at(1); QString fname_amat=((vector<char*> *)(input.at(0).p))->at(2); QString fname_output=((vector<char*> *)(output.at(0).p))->at(0); //init parameters bool b_channelSeperate = false; bool b_negativeShift = true; int interpMethod = 0; if(input.size() >= 2){ vector<char*> paras = (*(vector<char*> *)(input.at(1).p)); if(paras.size()>0){ int tmp=atoi(paras.at(0)); if(tmp==1) interpMethod = 1; } if(paras.size()>1){ int tmp=atoi(paras.at(1)); if(tmp==0) b_negativeShift = false; } if(paras.size()>2){ int tmp=atoi(paras.at(2)); if(tmp==1) b_channelSeperate = true; } } doAffineImage(callback, fname_img_tar, fname_img_sub, fname_amat, fname_output, interpMethod, b_negativeShift, b_channelSeperate); } else if (func_name == tr("help")) { printHelp(); } else return false; return true; }
bool AnisoDiffPlugin_littlequick::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { if (func_name == tr("anisodiff_littlequick_menu")) { cout<<"============== Welcome to anisodiff function ================="<<endl; bool bmenu = false; input_PARA PARA; vector<char*> * pinfiles = (input.size() >= 1) ? (vector<char*> *) input[0].p : 0; vector<char*> infiles = (pinfiles != 0) ? * pinfiles : vector<char*>(); if(infiles.empty()) { fprintf (stderr, "Need input image. \n"); return false; } else PARA.inimg_file = infiles[0]; anisodiff_func(callback,parent,PARA,bmenu); } else { printHelp(); } return true; }
bool resample_swc_toolbox(const V3DPluginArgList & input) { vaa3d_neurontoolbox_paras * paras = (vaa3d_neurontoolbox_paras *)(input.at(0).p); NeuronTree nt = paras->nt; QString fileOpenName = nt.file; bool ok; double step = QInputDialog::getDouble(0, "Please specify the resampling step length","Step length:",1,0,2147483647,0.1,&ok); if (!ok) return true; NeuronTree result = resample(nt,step); QString fileDefaultName = fileOpenName+QString("_resampled.swc"); //write new SWC to file QString fileSaveName = QFileDialog::getSaveFileName(0, QObject::tr("Save File"), fileDefaultName, QObject::tr("Supported file (*.swc)" ";;Neuron structure (*.swc)" )); if (!export_list2file(result.listNeuron,fileSaveName,fileOpenName)) { v3d_msg("fail to write the output swc file."); return false; } return true; }
bool open_fiji::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { if (func_name == tr("openfiji")) { vector<char*> infiles, outfiles; if(input.size()==0) { cout<<"for usage type: vaa3d -x open_fiji -f help"<<endl; return false; } if(input.size() >= 1) infiles = *((vector<char*> *)input.at(0).p); if(input.size() >= 2) { if(output.size() >= 1) outfiles = *((vector<char*> *)output.at(0).p); } char * inimg_file = ((vector<char*> *)(input.at(0).p))->at(0); char * outimg_file = ((vector<char*> *)(output.at(0).p))->at(0); call_open_using_imagej(false, QString(inimg_file ),QString(outimg_file), callback); } else if (func_name == tr("help")) { cout<<"Usage : vaa3d -x open_fiji -f openfiji -i <input_file_name> -o <output_file_name> "<<endl; } else return false; return true; }
bool neuron_toolbox_func(V3DPluginCallback2 & callback, QWidget * parent, const V3DPluginArgList & input, V3DPluginArgList & output) { QString test_str1 = QString(((vaa3d_neurontoolbox_paras *)(input.at(0).p))->nt.file); QString test_str = QFileInfo(test_str1).baseName() + "." + QFileInfo(test_str1).completeSuffix(); SelectPluginDlg * selectDlg = new SelectPluginDlg(parent, callback, input); selectDlg->setWindowTitle(test_str + " - Select plugin to run..."); selectDlg->show(); return true; }
bool v3dneuron_tracing(const V3DPluginArgList & input, V3DPluginArgList & output) { cout<<"Welcome to v3dneuron_tracing"<<endl; if(input.size() != 2 || output.size() != 1) return false; char * paras = 0; if(((vector<char*> *)(input.at(1).p))->empty()){paras = new char[1]; paras[0]='\0';} else paras = (*(vector<char*> *)(input.at(1).p)).at(0); cout<<"paras : "<<paras<<endl; for(int i = 0; i < strlen(paras); i++) { if(paras[i] == '#') paras[i] = '-'; } cout<<"paras : "<<paras<<endl; cout<<string("v3dneuron_tracing ").append(paras).c_str()<<endl; system(string("v3dneuron_tracing ").append(paras).c_str()); return true; }
bool nctuTW::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { if (func_name == tr("tracing_func")) { bool bmenu = false; input_PARA PARA; vector<char*> * pinfiles = (input.size() >= 1) ? (vector<char*> *) input[0].p : 0; vector<char*> * pparas = (input.size() >= 2) ? (vector<char*> *) input[1].p : 0; vector<char*> infiles = (pinfiles != 0) ? * pinfiles : vector<char*>(); vector<char*> paras = (pparas != 0) ? * pparas : vector<char*>(); if(infiles.empty()) { fprintf (stderr, "Need input image. \n"); return false; } else PARA.inimg_file = infiles[0]; int k=0; PARA.inmarker_file = paras.empty() ? "" : paras[k]; if(PARA.inmarker_file == "NULL") PARA.inmarker_file = ""; k++; PARA.threshold = (paras.size() >= k+1) ? atof(paras[k]) : 0.9; reconstruction_func(callback,parent,PARA,bmenu); } else if (func_name == tr("help")) { ////HERE IS WHERE THE DEVELOPERS SHOULD UPDATE THE USAGE OF THE PLUGIN printf("**** Usage of nctuTW tracing **** \n"); printf("vaa3d -x nctuTW -f tracing_func -i <inimg_file> -p <inmarker_file> <threshold>\n"); printf("inimg_file The input image\n"); printf("inmarker_file If no input marker file, please set this para to NULL and it will detect soma automatically.\n"); printf("threshold Default 0.9, otherwise the threshold (from 0 to 1) specified by a user will be used.\n"); printf("outswc_file Will be named automatically based on the input image file name, so you don't have to specify it.\n\n"); } else return false; return true; }
int eswc2swc_toolbox(const V3DPluginArgList & input) { vaa3d_neurontoolbox_paras * paras = (vaa3d_neurontoolbox_paras *)(input.at(0).p); NeuronTree neuron = paras->nt; QString fileOpenName = neuron.file; vector<V3DLONG> segment_id, segment_layer; vector<double> feature; if (fileOpenName.endsWith(".eswc") || fileOpenName.endsWith(".ESWC")) { neuron = read_eswc(segment_id, segment_layer, feature, fileOpenName); if (!swc2eswc(neuron,segment_id, segment_layer)) { v3d_msg("Cannot convert eswc to swc.\n"); return -1; } } else { v3d_msg("The file type you specified is not in .eswc format. Please check."); return -1; } int ret = QMessageBox::Yes; if (check_eswc(neuron, segment_id, segment_layer)==-1) { QMessageBox msgBox; msgBox.setText("Something is wrong with the eswc file."); msgBox.setInformativeText("Do you still want to convert it to swc?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Cancel); ret = msgBox.exec(); } if (ret==QMessageBox::Cancel) return -1; QString fileDefaultName = fileOpenName; fileDefaultName.chop(4); fileDefaultName += QString("swc"); //write new SWC to file QString fileSaveName = QFileDialog::getSaveFileName(0, QObject::tr("Save File"), fileDefaultName, QObject::tr("Supported file (*.swc)" ";;Neuron structure (*.eswc)" )); if (!export_swc(neuron,qPrintable(fileSaveName))) { v3d_msg("fail to write the output swc file."); return -1; } return 1; }
bool resample_swc(const V3DPluginArgList & input, V3DPluginArgList & output) { cout<<"Welcome to resample_swc"<<endl; vector<char*>* inlist = (vector<char*>*)(input.at(0).p); vector<char*>* outlist = NULL; vector<char*>* paralist = NULL; if(input.size() != 2) { printf("Please specify both input file and step length parameter.\n"); return false; } paralist = (vector<char*>*)(input.at(1).p); if (paralist->size()!=1) { printf("Please specify only one parameter - the resampling step length.\n"); return false; } double step = atof(paralist->at(0)); QString fileOpenName = QString(inlist->at(0)); QString fileSaveName; if (output.size()==0) { printf("No outputfile specified.\n"); fileSaveName = fileOpenName + "_resampled.swc"; } else if (output.size()==1) { outlist = (vector<char*>*)(output.at(0).p); fileSaveName = QString(outlist->at(0)); } else { printf("You have specified more than 1 output file.\n"); return false; } NeuronTree nt; if (fileOpenName.toUpper().endsWith(".SWC") || fileOpenName.toUpper().endsWith(".ESWC")) nt = readSWC_file(fileOpenName); NeuronTree result = resample(nt,step); if (!export_list2file(result.listNeuron, fileSaveName, fileOpenName)) { printf("fail to write the output swc file.\n"); return false; } return true; }
bool neuronScore::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { vector<char*> infiles, inparas, outfiles; if(input.size() >= 1) infiles = *((vector<char*> *)input.at(0).p); if(input.size() >= 2) inparas = *((vector<char*> *)input.at(1).p); if(output.size() >= 1) outfiles = *((vector<char*> *)output.at(0).p); if (func_name == tr("calculate_score")) { vector<char*> * pinfiles = (input.size() >= 1) ? (vector<char*> *) input[0].p : 0; vector<char*> * pparas = (input.size() >= 2) ? (vector<char*> *) input[1].p : 0; vector<char*> * poutfiles = (output.size() >= 1) ? (vector<char*> *) output[0].p : 0; vector<char*> infiles = (pinfiles != 0) ? * pinfiles : vector<char*>(); vector<char*> paras = (pparas != 0) ? * pparas : vector<char*>(); vector<char*> outfiles = (poutfiles != 0) ? * poutfiles : vector<char*>(); if(infiles.size()<2) { fprintf (stderr, "Need input image and swc. \n"); printHelp(); return false; } if(outfiles.empty()) { fprintf (stderr, "Need output file name. \n"); printHelp(); return false; } int k=0; int scoreType = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; float radiusFactor = (paras.size() >= k+1) ? atof(paras[k]) : 2; k++; doCalculateScore(callback, infiles[0],infiles[1],outfiles[0],scoreType,radiusFactor,0); } else if (func_name == tr("help")) { printHelp(); } else return false; return true; }
void nf_main(const V3DPluginArgList & input, V3DPluginArgList & output) { //cout<<"Welcome to nf_main"<<"\n"; vector<char*>* inlist = (vector<char*>*)(input.at(0).p); //char * out = (*(vector<char*>*)(input.at(0).p)).at(0); //QString outfileName = QString(out); //QFile file(outfileName); //file.open(QIODevice::WriteOnly|QIODevice::Text); //QTextStream myfile(&file); int neuronNum = (int)inlist->size(); for (int i=0;i<neuronNum;i++) { Neuron * n = new Neuron((char*)inlist->at(i)); cout<<"\n--------------Neuron #"<<(i+1)<<"----------------\n"; //myfile<<"Neuron #"<<(i+1)<<"\n"; //Node # cout<<"Number of Nodes: "<<n->read<<"\n"; //myfile<<"Neuron #"<<n->read<<"\n"; computeStems(n); computeBifs(n); computeBranches(n); computeTips(n); computeWidth(n); computeHeight(n); computeDepth(n); avgType(n); avgDia(n); computeLength(n); computeSurface(n); computeVol(n); computeHausdorff(n); //computeFractalDim(n); } // file.close(); }
int check_eswc_toolbox(const V3DPluginArgList & input) { vaa3d_neurontoolbox_paras * paras = (vaa3d_neurontoolbox_paras *)(input.at(0).p); NeuronTree neuron = paras->nt; QString fileOpenName = neuron.file; vector<V3DLONG> segment_id, segment_layer; vector<double> feature; if (fileOpenName.endsWith(".eswc") || fileOpenName.endsWith(".ESWC")) neuron = read_eswc(segment_id, segment_layer, feature, fileOpenName); else { v3d_msg("The file type you specified is not in eswc format. Please check."); return -1; } int check_result = check_eswc(neuron, segment_id, segment_layer); if (check_result==-1 || check_result==0) { QMessageBox msgBox; if (check_result==-1) msgBox.setText("Something is wrong with the eswc file."); else msgBox.setText("Your eswc is written in default values."); msgBox.setInformativeText("Do you still want to overwrite it with a standard one?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Cancel); if (msgBox.exec()==QMessageBox::Yes) { swc2eswc(neuron, segment_id, segment_layer); export_eswc(neuron, segment_id, segment_layer, qPrintable(fileOpenName), qPrintable(fileOpenName)); v3d_msg(QString("%1 has been updated!").arg(fileOpenName)); } else return -1; } else v3d_msg("Your eswc file is in correct format!"); return 1; }
int swc2eswc_toolbox(const V3DPluginArgList & input) { vaa3d_neurontoolbox_paras * paras = (vaa3d_neurontoolbox_paras *)(input.at(0).p); NeuronTree neuron = paras->nt; QString fileOpenName = neuron.file; vector<V3DLONG> segment_id, segment_layer; if (fileOpenName.endsWith(".swc") || fileOpenName.endsWith(".SWC")) { segment_id, segment_layer; if (!swc2eswc(neuron,segment_id, segment_layer)) { v3d_msg("Cannot convert swc to eswc.\n"); return -1; } } else { v3d_msg("The file type you specified is not in swc format. Please check."); return -1; } QString fileDefaultName = fileOpenName; fileDefaultName.chop(3); fileDefaultName += QString("eswc"); //write new SWC to file QString fileSaveName = QFileDialog::getSaveFileName(0, QObject::tr("Save File"), fileDefaultName, QObject::tr("Supported file (*.eswc)" ";;Extended Neuron structure (*.eswc)" )); if (!export_eswc(neuron,segment_id,segment_layer,qPrintable(fileOpenName),qPrintable(fileSaveName))) { v3d_msg("fail to write the output eswc file."); return -1; } return 1; }
bool compute(V3DPluginCallback2 &callback, const V3DPluginArgList & input, V3DPluginArgList & output) { cout<<"Welcome to histogram"<<endl; if(output.size() != 1) return true; vector<char*>* inlist = (vector<char*>*) (input.at(0).p); if (inlist->size() != 1) { cerr<<"You must specify 1 input file!"<<endl; return false; } char * infile = inlist->at(0); cout<<"input file: "<<infile<<endl; unsigned char * inimg1d = NULL; V3DLONG sz[4]; int datatype; if (!simple_loadimage_wrapper(callback, infile, inimg1d, sz, datatype)) { cerr<<"faile to load image"<<endl; return false; } //Read the output file vector<char*>* outlist = (vector<char*>*) (output.at(0).p); if (outlist->size()!=1) { cerr<<"You must specify 1 output file!"<<endl; return false; } char* outfile = outlist->at(0); cout<<"output file: "<<outfile<<endl; if (datatype!=1) { v3d_msg("Now we only support 8 bit image.\n"); return -1; } //TODO add datatype judgment double max_value = 256; V3DLONG histscale = 256; QVector<QVector<int> > hist_vec; int nChannel = sz[3]; for (int c=0;c<nChannel;c++) { QVector<int> tmp; getHistogram(inimg1d+ c*sz[0]*sz[1]*sz[2], sz[0]*sz[1]*sz[2], max_value, histscale, tmp); hist_vec.append(tmp); } //output histogram to csv file FILE *fp; fp = fopen(outfile, "w"); for (int i=0;i<hist_vec.size();i++) { for (int j=0;j<hist_vec[i].size();j++) fprintf(fp, "%d,", hist_vec[i][j]); fprintf(fp,"\n"); } fclose(fp); if (inimg1d) {delete []inimg1d; inimg1d=NULL;} return true; }
bool SWCRadiusPlugin::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { vector<char*> infiles, inparas, outfiles; if(input.size() >= 1) infiles = *((vector<char*> *)input.at(0).p); if(input.size() >= 2) inparas = *((vector<char*> *)input.at(1).p); if(output.size() >= 1) outfiles = *((vector<char*> *)output.at(0).p); if (func_name == tr("neuron_radius")) { if(infiles.size() != 2 && infiles.size() != 3) { cerr<<"Invalid input"<<endl; return false; } string inimg_file = infiles[0]; string inswc_file = infiles[1]; string outswc_file = (infiles.size() == 3) ? infiles[2] : ""; if(outswc_file == "") outswc_file = inswc_file + ".out.swc"; double bkg_thresh = (inparas.size() >= 1) ? atof(inparas[0]) : 40; bool is_2d = (inparas.size() == 2) ? atoi(inparas[1]) : 0; cout<<"inimg_file = "<<inimg_file<<endl; cout<<"inswc_file = "<<inswc_file<<endl; cout<<"outswc_file = "<<outswc_file<<endl; cout<<"bkg_thresh = "<<bkg_thresh<<endl; cout<<"is2d = "<< (int)is_2d <<endl; unsigned char * inimg1d = 0; V3DLONG * in_sz = 0; int datatype; if(!loadImage((char*)inimg_file.c_str(), inimg1d, in_sz, datatype)) return false; vector<MyMarker*> inswc = readSWC_file(inswc_file); if(inswc.empty()) return false; for(int i = 0; i < inswc.size(); i++) { MyMarker * marker = inswc[i]; if(is_2d) marker->radius = markerRadiusXY(inimg1d, in_sz, *marker, bkg_thresh); else marker->radius = markerRadius(inimg1d, in_sz, *marker, bkg_thresh); //printf("2d=%5.3f \t 3d=%5.3f\n", markerRadiusXY(inimg1d, in_sz, *marker, bkg_thresh), // markerRadius(inimg1d, in_sz, *marker, bkg_thresh)); } saveSWC_file(outswc_file, inswc); cout<<"The output swc is saved to "<<outswc_file<<endl; for(int i = 0; i < inswc.size(); i++) delete inswc[i]; if(inimg1d){delete [] inimg1d; inimg1d = 0;} if(in_sz){delete [] in_sz; in_sz = 0;} } else //if (func_name == tr("help")) { cout<<"v3d -x <plugin_dll> -f neuron_radius -i <inimg_file> <inswc_file> -p <threshold> [<is2d>]" <<endl <<"The output will be appended .out.swc automatically" <<endl; } return true; }
bool smartTrace_plugin::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { if (func_name == tr("tracing_func")) { bool bmenu = false; input_PARA PARA; vector<char*> * pinfiles = (input.size() >= 1) ? (vector<char*> *) input[0].p : 0; vector<char*> * pparas = (input.size() >= 2) ? (vector<char*> *) input[1].p : 0; vector<char*> infiles = (pinfiles != 0) ? * pinfiles : vector<char*>(); vector<char*> paras = (pparas != 0) ? * pparas : vector<char*>(); if(infiles.empty()) { fprintf (stderr, "Need input image. \n"); return false; } else PARA.inimg_file = infiles[0]; int k=0; PARA.channel = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; reconstruction_func(callback,parent,PARA,bmenu); } else if(func_name == tr("selfCorrection")) { vector<char*> * pinfiles = (input.size() >= 1) ? (vector<char*> *) input[0].p : 0; vector<char*> * pparas = (input.size() >= 2) ? (vector<char*> *) input[1].p : 0; vector<char*> * poutfiles = (output.size() >= 1) ? (vector<char*> *) output[0].p : 0; vector<char*> infiles = (pinfiles != 0) ? * pinfiles : vector<char*>(); vector<char*> paras = (pparas != 0) ? * pparas : vector<char*>(); vector<char*> outfiles = (poutfiles != 0) ? * poutfiles : vector<char*>(); if(infiles.size()<2) { fprintf (stderr, "Need input image and swc file. \n"); return false; } if(outfiles.empty()) { fprintf (stderr, "Need output file. \n"); return false; } if(paras.empty()) { fprintf (stderr, "Need confidential score file. \n"); return false; } nt_selfcorrect_func tracefunc; tracefunc.correct_tracing(infiles.at(0), infiles.at(1), paras.at(0), outfiles.at(0), &callback); } else if (func_name == tr("smartTrace")) { bool bmenu = false; input_PARA PARA; vector<char*> * pinfiles = (input.size() >= 1) ? (vector<char*> *) input[0].p : 0; vector<char*> * pparas = (input.size() >= 2) ? (vector<char*> *) input[1].p : 0; vector<char*> infiles = (pinfiles != 0) ? * pinfiles : vector<char*>(); vector<char*> paras = (pparas != 0) ? * pparas : vector<char*>(); if(infiles.empty()) { fprintf (stderr, "Need input image. \n"); return false; } else PARA.inimg_file = infiles[0]; int k=0; PARA.channel = (paras.size() >= k+1) ? atoi(paras[k]) : 1; k++; nt_selfcorrect_func tracefunc; tracefunc.smart_tracing(PARA.inimg_file,PARA.inimg_file+"_smartTracing",&callback); } else if (func_name == tr("help")) { ////HERE IS WHERE THE DEVELOPERS SHOULD UPDATE THE USAGE OF THE PLUGIN printf("\n\n**** Usage of smartTrace tracing **** \n"); printf("vaa3d -x smartTrace -f selfCorrection -i <inimg_file> <inswc_file> -o <output> -p <score.txt> \n"); printf("inimg_file The input image\n"); printf("inswc_file The input tracing\n"); printf("score.txt Confidential score calculated by plugin: calculate_reliability_score.\n"); printf("\n\nvaa3d -x smartTrace -f smartTrace -i <inimg_file> -p <channel>\n"); printf("inimg_file The input image\n"); printf("channel Data channel for tracing. Start from 1 (default 1).\n"); printf("outswc_file Will be named automatically based on the input image file name, so you don't have to specify it.\n\n"); } else return false; return true; }
bool ITilingPlugin::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { if (func_name == tr("help")) { printf("\nUsage: v3d -x imageTiling.dylib -f itiling -i <input_image_file> -o <output_images_prefix_string> \n"); return true; } else if (func_name == tr("itiling")) { // subpixel translation registration based on pixel-level translation estimation if(input.size()<1) return false; // no inputs vector<char*> * infilelist = (vector<char*> *)(input.at(0).p); vector<char*> * paralist; vector<char*> * outfilelist; if(infilelist->empty()) { //print Help info printf("\nUsage: v3d -x imageTiling.dylib -f itiling -i <input_image_file> -o <output_images_prefix_string> \n"); return true; } char * infile = infilelist->at(0); // input_image_folder char * paras = NULL; // parameters char * outfile = NULL; // output_image_file if(output.size()>0) { outfilelist = (vector<char*> *)(output.at(0).p); outfile = outfilelist->at(0);} // specify output if(input.size()>1) { paralist = (vector<char*> *)(input.at(1).p); paras = paralist->at(0);} // parameters // init int channel1 = 0; bool img_show = true; // save stitching file bool success = false; ImagePixelType imgdatatype; V3DLONG cdim; // parsing parameters if(paras) { int argc = 0; int len = strlen(paras); int posb[200]; char * myparas = new char[len]; strcpy(myparas, paras); for(int i = 0; i < len; i++) { if(i==0 && myparas[i] != ' ' && myparas[i] != '\t') { posb[argc++] = i; } else if((myparas[i-1] == ' ' || myparas[i-1] == '\t') && (myparas[i] != ' ' && myparas[i] != '\t')) { posb[argc++] = i; } } char ** argv = new char* [argc]; for(int i = 0; i < argc; i++) { argv[i] = myparas + posb[i]; } for(int i = 0; i < len; i++) { if(myparas[i]==' ' || myparas[i]=='\t') myparas[i]='\0'; } char* key; for(int i=0; i<argc; i++) { if(i+1 != argc) // check that we haven't finished parsing yet { key = argv[i]; qDebug()<<">>key ..."<<key; if (*key == '#') { while(*++key) { if (!strcmp(key, "c")) { channel1 = atoi( argv[i+1] ) - 1; // red 1 green 2 blue 3 i++; } else if (!strcmp(key, "s")) { img_show = atoi( argv[i+1] )?true:false; i++; } else { cout<<"parsing ..."<<key<<i<<"Unknown command. Type 'v3d -x plugin_name -f function_name' for usage"<<endl; return false; } } } else { cout<<"parsing ..."<<key<<i<<"Unknown command. Type 'v3d -x plugin_name -f function_name' for usage"<<endl; return false; } } } // error check if(channel1<0) { cout<<"illegal input parameters"<<endl; return false; } //free space if (argv) {delete []argv; argv=0;} if (myparas) {delete []myparas; myparas=0;} } // get stitch configuration //QDir myDir(infile); // group stitch in subspace int start_t = clock(); // int datatype_tile = 0; // assume all tiles with the same datatype V3DLONG *sz_relative = 0; unsigned char* relative1d = 0; if(QFile(QString(infile)).exists()) { if (!loadImage(const_cast<char *>(infile), relative1d, sz_relative, datatype_tile)) { if (!do_blockwise_read(const_cast<char *>(infile)), outfile) { fprintf(stderr, "Error happens in reading the subject file [%s]. Exit. \n",infile); return false; } else { v3d_msg("Succeed!"); return true; } } } else { v3d_msg("The input file is not supported!",0); return false; } // switch (datatype_tile) { case V3D_UINT8: if (!imgtiling<unsigned char, V3DLONG>((unsigned char *)relative1d, sz_relative[0], sz_relative[1], sz_relative[2], sz_relative[3], QString(outfile), datatype_tile)) { v3d_msg("Fail to call function imgtiling (8bit)! \n", 0); return false; } break; case V3D_UINT16: if (!imgtiling<unsigned short, V3DLONG>((unsigned short *)relative1d, sz_relative[0], sz_relative[1], sz_relative[2], sz_relative[3], QString(outfile), datatype_tile)) { v3d_msg("Fail to call function imgtiling (16bit)! \n", 0); return false; } break; case V3D_FLOAT32: if (!imgtiling<float, V3DLONG>((float *)relative1d, sz_relative[0], sz_relative[1], sz_relative[2], sz_relative[3], QString(outfile), datatype_tile)) { v3d_msg("Fail to call function imgtiling (32bit)! \n", 0); return false; } break; default: v3d_msg("Currently this program only support UINT8, UINT16, and FLOAT32 datatype.\n",0); return false; } cout<<"time elapse ... "<<clock()-start_t<<endl; return true; } else { v3d_msg("\nWrong function specified.\n",0); return false; } return true; }
bool IBioformatIOPlugin::dofunc(const QString & func_name, const V3DPluginArgList & input, V3DPluginArgList & output, V3DPluginCallback2 & callback, QWidget * parent) { if (func_name == tr("imgiobiof")) { cout<<"Welcome to imageIOBioformat loader"<<endl; if(input.size() != 1 || output.size() != 1) return false; char * inimg_file = ((vector<char*> *)(input.at(0).p))->at(0); char * outimg_file = ((vector<char*> *)(output.at(0).p))->at(0); cout<<"inimg_file = "<<inimg_file<<endl; cout<<"outimg_file = "<<outimg_file<<endl; QString m_FileName(inimg_file); // use inimge_file name if(m_FileName.isEmpty()) { printf("\nError: Your image does not exist!\n"); return false; } // temp QString baseName = QFileInfo(m_FileName).baseName(); //QString tmpfile = QDir::tempPath().append("/").append(baseName).append(".tif"); QString tmpfile(outimg_file); //use outimg_file name // QFile tmpqfile(tmpfile); if (tmpqfile.exists()) system(qPrintable(QString("rm -f \"%1\"").arg(tmpfile))); //look for loci_tools.jar QString lociDir = ("loci_tools.jar"); if (!QFile(lociDir).exists()) { printf("loci_tools.jar is not in current directory, search v3d app path.\n"); lociDir = getAppPath().append("/loci_tools.jar"); printf(qPrintable(lociDir)); printf("\n"); if (!QFile(lociDir).exists()) { v3d_msg("Cannot find loci_tools.jar, please download it and make sure it is put under the Vaa3D executable folder, parallel to the Vaa3D executable and the plugins folder.", 0); return false; } } QString cmd_loci = QString("java -cp %1 loci.formats.tools.ImageConverter \"%2\" \"%3\"").arg(lociDir.toStdString().c_str()).arg(m_FileName.toStdString().c_str()).arg(tmpfile.toStdString().c_str()); v3d_msg(cmd_loci, 0); system(qPrintable(cmd_loci)); if (!tmpqfile.exists()) { v3d_msg("The temprary file does not exist. The conversion of format using Bioformats has failed. Please use another way to convert and load using Vaa3D.\n"); return false; } return true; } else if(func_name == tr("help")) { cout<<"Usage : v3d -x imageIO_Bioformat -f imgiobiof -i <inimg_file> -o <outimg_file>"<<endl; cout<<"e.g. v3d -x imageIO_Bioformat -f imgiobiof -i input.raw -o output.raw"<<endl; cout<<endl; return true; } }