From 04e3673c171346ab2e92f0b2aa2847b55e67f9c6 Mon Sep 17 00:00:00 2001 From: Kelvin Chow Date: Fri, 5 Nov 2021 22:46:24 -0500 Subject: [PATCH 1/4] Add option to skip parsing of syncdata --- main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 8e06fb9..705221a 100644 --- a/main.cpp +++ b/main.cpp @@ -70,7 +70,7 @@ void calc_traj(double* xgrad, double* ygrad, int ngrad, int Nints, double Tgsamp std::vector readSyncdata(std::ifstream &siemens_dat, bool VBFILE, unsigned long acquisitions, uint32_t dma_length, sScanHeader scanheader, ISMRMRD::IsmrmrdHeader &header, - long scan_counter); + long scan_counter, bool skip_syncdata); std::string get_file_content(const std::string &embed_file, const std::string &user_file, const std::string &default_file, std::string &actual_file, const bool all_measurements, const unsigned int currentMeas); @@ -450,6 +450,7 @@ int main(int argc, char* argv[]) { bool append_buffers = false; bool all_measurements = false; bool multi_meas_file = false; + bool skip_syncdata = false; bool list = false; std::string to_extract; @@ -464,6 +465,7 @@ int main(int argc, char* argv[]) { ("measNum,z", po::value(&measurement_number)->default_value(1), "") ("allMeas,Z", po::value(&all_measurements)->implicit_value(true), "") ("multiMeasFile,M", po::value(&multi_meas_file)->implicit_value(true), "") + ("skipSyncData", po::value(&skip_syncdata)->implicit_value(true), "") ("pMap,m", po::value(¶mmap_file), "") ("pMapStyle,x", po::value(¶mmap_xsl), "") ("user-map", po::value(&usermap_file), "") @@ -490,6 +492,7 @@ int main(int argc, char* argv[]) { ("measNum,z", "") ("allMeas,Z", "") ("multiMeasFile,M", "") + ("skipSyncData", "") ("pMap,m", "") ("pMapStyle,x", "") ("user-map", "") @@ -830,7 +833,7 @@ int main(int argc, char* argv[]) { uint32_t last_scan_counter = acquisitions - 1; auto waveforms = readSyncdata(siemens_dat, VBFILE, acquisitions, dma_length, scanhead, header, - last_scan_counter); + last_scan_counter, skip_syncdata); for (auto &w : waveforms) ismrmrd_dataset->appendWaveform(w); sync_data_packets++; @@ -1302,7 +1305,7 @@ std::set PMU_Types = {PMU_Type::ECG1, PMU_Type::ECG2, PMU_Type::ECG3, std::vector readSyncdata(std::ifstream &siemens_dat, bool VBFILE, unsigned long acquisitions, uint32_t dma_length, sScanHeader scanheader, ISMRMRD::IsmrmrdHeader &header, - long last_scan_counter) { + long last_scan_counter, bool skip_syncdata) { size_t len = 0; if (VBFILE) { @@ -1326,7 +1329,7 @@ std::vector readSyncdata(std::ifstream &siemens_dat, bool VBF } - if (packedID.find("PMU") == packedID.npos) { //packedID indicates this isn't PMU data, so let's jump ship. + if ((skip_syncdata) || (packedID.find("PMU") == packedID.npos)) { //packedID indicates this isn't PMU data, so let's jump ship. siemens_dat.seekg(cur_pos); siemens_dat.seekg(len, siemens_dat.cur); return std::vector(); From 7ea2b50c95b12aead05df90cbd80da6ed583da82 Mon Sep 17 00:00:00 2001 From: Kelvin Chow Date: Sat, 6 Nov 2021 22:40:21 -0500 Subject: [PATCH 2/4] Change default output file name to match input file name but with h5 extension --- main.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 705221a..6752067 100644 --- a/main.cpp +++ b/main.cpp @@ -470,7 +470,7 @@ int main(int argc, char* argv[]) { ("pMapStyle,x", po::value(¶mmap_xsl), "") ("user-map", po::value(&usermap_file), "") ("user-stylesheet", po::value(&usermap_xsl), "") - ("output,o", po::value(&ismrmrd_file)->default_value("output.h5"), "") + ("output,o", po::value(&ismrmrd_file)->default_value(""), "") ("outputGroup,g", po::value(&ismrmrd_group)->default_value("dataset"), "") ("list,l", po::value(&list)->implicit_value(true), "") @@ -579,6 +579,27 @@ int main(int argc, char* argv[]) { } std::cout << "Siemens file is: " << siemens_dat_filename << std::endl; + if (ismrmrd_file.empty()) + { + // Use the intput filename, but with an h5 extension + std::vector v; + boost::algorithm::split(v, siemens_dat_filename, boost::is_any_of(".")); + + if ((v.size() > 1) && (v.back().compare("h5") != 0)) + { + v.back() = std::string("h5"); + ismrmrd_file = boost::algorithm::join(v, "."); + } + else + { + // No file extension found + std::stringstream ss; + ss << siemens_dat_filename << "_ismrmrd"; + ismrmrd_file = ss.str(); + } + std::cout << "Output file not specified -- using " << ismrmrd_file << std::endl; + } + std::string schema_file_name_content = load_embedded("ismrmrd.xsd"); std::ifstream siemens_dat(siemens_dat_filename.c_str(), std::ios::binary); From 5265832c8dd9ca26f4d17cbf2146caa1fe56f75b Mon Sep 17 00:00:00 2001 From: David C Hansen Date: Sun, 7 Nov 2021 10:51:56 +0100 Subject: [PATCH 3/4] Fixed default filename implementation to be human readable and use the correct extension --- main.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/main.cpp b/main.cpp index 6752067..1e321a7 100644 --- a/main.cpp +++ b/main.cpp @@ -26,6 +26,7 @@ #include namespace po = boost::program_options; +#include #include using boost::locale::conv::utf_to_utf; @@ -581,22 +582,8 @@ int main(int argc, char* argv[]) { if (ismrmrd_file.empty()) { - // Use the intput filename, but with an h5 extension - std::vector v; - boost::algorithm::split(v, siemens_dat_filename, boost::is_any_of(".")); - - if ((v.size() > 1) && (v.back().compare("h5") != 0)) - { - v.back() = std::string("h5"); - ismrmrd_file = boost::algorithm::join(v, "."); - } - else - { - // No file extension found - std::stringstream ss; - ss << siemens_dat_filename << "_ismrmrd"; - ismrmrd_file = ss.str(); - } + boost::filesystem::path siemens_dat_path(siemens_dat_filename); + ismrmrd_file = siemens_dat_path.replace_extension(".mrd").string(); std::cout << "Output file not specified -- using " << ismrmrd_file << std::endl; } From ec51eb51d5b71a7dc5834249ea6c88a5f5e39a01 Mon Sep 17 00:00:00 2001 From: David Christoffer Hansen Date: Mon, 15 Nov 2021 20:22:58 +0100 Subject: [PATCH 4/4] Made the default output name explicit --- main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 726da76..d4a4497 100644 --- a/main.cpp +++ b/main.cpp @@ -441,7 +441,6 @@ int main(int argc, char* argv[]) { std::string schema_file_name; - std::string ismrmrd_file; std::string ismrmrd_group; std::string date_time = get_date_time_string(); @@ -473,7 +472,7 @@ int main(int argc, char* argv[]) { ("pMapStyle,x", po::value(¶mmap_xsl), "") ("user-map", po::value(&usermap_file), "") ("user-stylesheet", po::value(&usermap_xsl), "") - ("output,o", po::value(&ismrmrd_file)->default_value(""), "") + ("output,o", po::value(), "") ("outputGroup,g", po::value(&ismrmrd_group)->default_value("dataset"), "") ("list,l", po::value(&list)->implicit_value(true), "") @@ -594,11 +593,14 @@ int main(int argc, char* argv[]) { } std::cout << "Siemens file is: " << siemens_dat_filename << std::endl; - if (ismrmrd_file.empty()) + std::string ismrmrd_file; + if (!vm.count("output")) { boost::filesystem::path siemens_dat_path(siemens_dat_filename); ismrmrd_file = siemens_dat_path.replace_extension(".mrd").string(); std::cout << "Output file not specified -- using " << ismrmrd_file << std::endl; + } else { + ismrmrd_file = vm["output"].as(); } std::string schema_file_name_content = load_embedded("ismrmrd.xsd");