int IsmrmrdDumpGadget::process_config(ACE_Message_Block* mb)
    {
        file_prefix_ = file_prefix.value();
        if ( file_prefix_.empty() )
        {
            file_prefix_ = "ISMRMRD_DUMP";
        }

        append_timestamp_ = append_timestamp.value();

        //Generate filename
        if (append_timestamp_)
        {
            ismrmrd_file_name_ = file_prefix_ + std::string("_") + get_date_time_string() + std::string(".h5");
        }
        else
        {
            ismrmrd_file_name_ = file_prefix_ + std::string(".h5");
        }

        ismrmrd_dataset_ = boost::shared_ptr<ISMRMRD::Dataset>(new ISMRMRD::Dataset(ismrmrd_file_name_.c_str(), "dataset"));

        std::string xml_config(mb->rd_ptr());

        try {
            ismrmrd_dataset_->writeHeader(xml_config);
        }
        catch (...)
        {
            GDEBUG("Failed to write XML header to HDF file\n");
            return GADGET_FAIL;
        }

        return GADGET_OK;
    }
Exemplo n.º 2
0
YBORM_DECL void
load_schema(const String &name, Schema &reg, bool check)
{
    string xml;
    if (!load_xml_file(name, xml))
        throw XMLConfigError(_T("Can't read file: ") + name);
    MetaDataConfig xml_config(xml);
    xml_config.parse(reg);
    reg.fill_fkeys();
    if (check)
        reg.check_cycles();
}
Exemplo n.º 3
0
    int IsmrmrdDumpGadget::process_config(ACE_Message_Block* mb)
    {
        
        ISMRMRD::IsmrmrdHeader ismrmrd_header;
        ISMRMRD::deserialize(mb->rd_ptr(), ismrmrd_header);

        std::string measurement_id = "";
        std::string ismrmrd_filename = "";
        
        if ( ismrmrd_header.measurementInformation ) {
            if ( ismrmrd_header.measurementInformation->measurementID ) {
                measurement_id = *ismrmrd_header.measurementInformation->measurementID;
            }
        }

        GDEBUG("Measurement ID: %s\n", measurement_id.c_str());
        
        bf::path p(folder.value());

        if (!exists(p)) {
            try {
                bf::create_directory(p);
            } catch(...) {
                GERROR("Error caught trying to create folder %s\n", folder.value().c_str());
                return GADGET_FAIL;
            }
        } else {
            if (!is_directory(p)) {
                GERROR("Specified path is not a directory\n");
                return GADGET_FAIL;
            }
        }
        
        if ( file_prefix.value().empty() )
        {
            ismrmrd_filename = "ISMRMRD_DUMP";
        } else {
            ismrmrd_filename = file_prefix.value();
        }

        if (append_id.value() && measurement_id.size()) {
            ismrmrd_filename.append("_");
            ismrmrd_filename.append(measurement_id);
        }
        
        //Generate filename
        if (append_timestamp.value())
        {
            ismrmrd_filename.append("_");
            ismrmrd_filename.append(get_date_time_string());
        }

        ismrmrd_filename.append(".h5");

        p /= ismrmrd_filename;

        ismrmrd_filename = p.string();
        ismrmrd_dataset_ = boost::shared_ptr<ISMRMRD::Dataset>(new ISMRMRD::Dataset(ismrmrd_filename.c_str(), "dataset"));

        std::string xml_config(mb->rd_ptr());

        try {
            ismrmrd_dataset_->writeHeader(xml_config);
        }
        catch (...)
        {
            GDEBUG("Failed to write XML header to HDF file\n");
            return GADGET_FAIL;
        }

        return GADGET_OK;
    }