Skip to content

Commit

Permalink
Feature #15 (#16)
Browse files Browse the repository at this point in the history
* Formatting and C++20 support
* Update to Yardl v0.6.1 for C++20 fixes
* Update Yardl version in Github CI too
* Fix Docker test script and std::remove for OS X
* Remove std::filesystem altogether for OS X
  • Loading branch information
naegelejd authored Jul 9, 2024
1 parent 1f8496d commit 466bd9a
Show file tree
Hide file tree
Showing 25 changed files with 2,121 additions and 2,491 deletions.
12 changes: 12 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
BasedOnStyle: LLVM
UseTab: Never
IndentWidth: 2
TabWidth: 2
AllowShortIfStatementsOnASingleLine: false
ColumnLimit: 0
AccessModifierOffset: -4
FixNamespaceComments: false
PointerAlignment: Left
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
NamespaceIndentation: None
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ RUN . /opt/conda/etc/profile.d/conda.sh \


# Install the yardl tool
ARG YARDL_VERSION=0.6.0
ARG YARDL_VERSION=0.6.1
RUN wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" \
&& tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" \
&& mv yardl "/opt/conda/envs/${CONDA_ENVIRONMENT_NAME}/bin/" \
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/mrd_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
env:
# Increase this to manually reset the conda environment cache
CONDA_CACHE_NUMBER: 0
YARDL_VERSION: 0.6.0
YARDL_VERSION: 0.6.1

defaults:
run:
Expand All @@ -20,11 +20,11 @@ defaults:

jobs:
build:
name: Build and Test C++17, Python, MATLAB SDKs
name: Build and Test C++, Python, MATLAB SDKs
runs-on: ubuntu-latest
strategy:
matrix:
cppVersion: [17]
cppVersion: [17, 20]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -68,8 +68,7 @@ jobs:
publishDocs:
name: Publish Documentation
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'ismrmrd/mrd'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'ismrmrd/mrd'
needs: [build, docker]
runs-on: ubuntu-latest
environment:
Expand Down
27 changes: 14 additions & 13 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ add_compile_options(-Wall -Wextra -pedantic -Werror)
add_subdirectory(mrd)
add_subdirectory(mrd-tools)

# Minimal example
add_executable(mrd_minimal_example minimal_example.cc)
target_link_libraries(mrd_minimal_example mrd_generated)

install(DIRECTORY mrd DESTINATION include COMPONENT Devel)
install(TARGETS mrd_generated DESTINATION lib)
install(TARGETS
ismrmrd_to_mrd
mrd_hdf5_to_stream
mrd_image_stream_to_png
mrd_phantom
mrd_stream_recon
mrd_stream_to_hdf5
mrd_to_ismrmrd
mrd_minimal_example
DESTINATION bin)
install(TARGETS mrd_minimal_example DESTINATION bin)

# MRD Library (libmrd)
add_library(mrd SHARED $<TARGET_OBJECTS:mrd_generated>)
target_link_libraries(mrd mrd_generated)
install(TARGETS mrd DESTINATION lib)

# MRD Library Headers
install(DIRECTORY mrd
DESTINATION include
COMPONENT Devel
FILES_MATCHING PATTERN "*.h"
)
2 changes: 1 addition & 1 deletion cpp/conda/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mrd_minimal_example

# Smoketest A
rm -f mrd_testdata.h5 mrd_testdata_recon.h5
mrd_phantom -o mrd_testdata.h5
mrd_phantom | mrd_stream_to_hdf5 mrd_testdata.h5
mrd_hdf5_to_stream mrd_testdata.h5 | mrd_stream_recon | mrd_stream_to_hdf5 mrd_testdata_recon.h5

# Smoketest B
Expand Down
62 changes: 29 additions & 33 deletions cpp/minimal_example.cc
Original file line number Diff line number Diff line change
@@ -1,45 +1,41 @@
#include "mrd/binary/protocols.h"

int main(void)
{
mrd::binary::MrdWriter w("test.bin");
int main(void) {
mrd::binary::MrdWriter w("test.bin");

mrd::Header header;
// Populate Header
// ...

w.WriteHeader(header);
mrd::Header header;
// Populate Header
// ...

unsigned int nreps = 2;
for (unsigned int r = 0; r < nreps; r++)
{
mrd::Acquisition acq;
// Populate Acquisition
// ...
w.WriteHeader(header);

w.WriteData(acq);
}
w.EndData();
w.Close();
unsigned int nreps = 2;
for (unsigned int r = 0; r < nreps; r++) {
mrd::Acquisition acq;
// Populate Acquisition
// ...

mrd::binary::MrdReader r("test.bin");
w.WriteData(acq);
}
w.EndData();
w.Close();

std::optional<mrd::Header> header_in;
r.ReadHeader(header_in);
mrd::binary::MrdReader r("test.bin");

mrd::StreamItem v;
while (r.ReadData(v))
{
if (!std::holds_alternative<mrd::Acquisition>(v))
{
continue;
}
std::optional<mrd::Header> header_in;
r.ReadHeader(header_in);

auto acq = std::get<mrd::Acquisition>(v);
// Process Acquisition
// ...
mrd::StreamItem v;
while (r.ReadData(v)) {
if (!std::holds_alternative<mrd::Acquisition>(v)) {
continue;
}
r.Close();

return 0;
auto acq = std::get<mrd::Acquisition>(v);
// Process Acquisition
// ...
}
r.Close();

return 0;
}
10 changes: 10 additions & 0 deletions cpp/mrd-tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,13 @@ target_link_libraries(
${ImageMagick_LIBRARIES}
fmt::fmt
)

install(TARGETS
ismrmrd_to_mrd
mrd_hdf5_to_stream
mrd_image_stream_to_png
mrd_phantom
mrd_stream_recon
mrd_stream_to_hdf5
mrd_to_ismrmrd
DESTINATION bin)
Loading

0 comments on commit 466bd9a

Please sign in to comment.