#include #include #include #include #include #include #include #include #include #include using namespace std; int main(int argc, char* argv[]) { // // Connect to OMERO // cout << "--- Connect ---" << endl; omero::client omero(argc, argv); omero::api::ServiceFactoryPrx sf = omero.createSession(); sf->closeOnDestroy(); // // Check the IAdmin interface // cout << "--- Login data ---" << endl; // IAdmin is responsible for all user/group creation, password changing, etc. omero::api::IAdminPrx admin = sf->getAdminService(); // Who you are logged in as. string loginName = admin->getEventContext()->userName; long loginId = admin->getEventContext()->userId; cout << "Logged as: " << loginName << endl; cout << "User ID: " << loginId << endl; // // Get experimenter data // cout << "--- Experimenter data ---" << endl; // Get your experimenter data omero::model::ExperimenterPtr e = admin->lookupExperimenter(loginName); if(e) { cout << "ID: " << e->getId()->getValue() << endl; cout << "First name: " << e->getFirstName()->getValue() << endl; cout << "Last name: " << e->getLastName()->getValue() << endl; cout << "Institution: " << e->getInstitution()->getValue() << endl; } else { cout << "You, " << loginName << " do not exist!" << endl; return 0; } // // Access projects // omero::api::GatewayPrx gateway = sf->createGateway(); // // Get project data // cout << "--- Projects data ---" << endl; omero::api::LongList ids; ids.push_back(omero::rtypes::rlong(loginId)); omero::api::ProjectList proj = gateway->getProjects(ids, false); omero::api::LongList pids; omero::api::ProjectList::iterator ip; for(ip=proj.begin(); ip != proj.end(); ++ip) { cout << "Name: " << (*ip)->getName()->getValue() << endl; cout << " " << (*ip)->getDescription()->getValue() << endl; pids.push_back(omero::rtypes::rlong((*ip)->getId())); } // // Get datasets data // cout << "--- Datasets ---" << endl; omero::api::DatasetList dset = gateway->getDatasets(pids, false); omero::api::LongList dsets; omero::api::DatasetList::iterator id; for(id=dset.begin(); id != dset.end(); ++id) { cout << "Name: " << (*id)->getName()->getValue() << endl; if((*id)->getDescription()) cout << " " << (*id)->getDescription()->getValue() << endl; dsets.push_back(omero::rtypes::rlong((*id)->getId())); } // // Get image data // cout << "--- Images ---" << endl; omero::api::ImageList imgs = gateway->getImages(omero::api::Dataset, dsets); omero::api::ImageList::iterator im; for(im=imgs.begin(); im != imgs.end(); ++im) { cout << "Id: " << (*im)->getId()->getValue() << endl; cout << "Name: " << (*im)->getName()->getValue() << endl; if((*im)->getDescription()) cout << " " << (*im)->getDescription()->getValue() << endl; } // // Simulating image selection // int selected_image_idx = 51; // // Get image pixels for selected image // cout << "--- Images data ---" << endl; omero::model::PixelsPtr pix = gateway->getPixels(selected_image_idx); if(!pix) {cout << "Problems in getPixels" << endl; return 0;} // // Get image characteristics // int xdim = pix->getSizeX()->getValue(); int ydim = pix->getSizeY()->getValue(); int zdim = pix->getSizeZ()->getValue(); cout << "The image " << selected_image_idx << " is: " << xdim << "x" << ydim << "x" << zdim << endl; int cdim = pix->getSizeC()->getValue(); int tdim = pix->getSizeT()->getValue(); cout << "The image " << selected_image_idx << " has: " << cdim << " colors and " << tdim << " timesteps" << endl; // // Get physical bytes // omero::model::ImagePtr img = pix->getImage(); if(!img) {cout << "Problems in getImage" << endl; return 0;} // // And now? // return 0; }