Skip to content

Commit

Permalink
Add Intermediate Data Types (#17)
Browse files Browse the repository at this point in the history
* Add initial Kspace and NoiseCovariance types
* Move Gadgetron types into MRD v2 model
* Source VERSION from file in CMakeLists.txt
* Clean up CMake target exports
* Add intermediate types for image reconstruction
* Document intermediate types
* Update YARDL_VERSION in Github CI
* Pin Python version for Github CI conda build
* Pin Miniforge version in CI conda build
* Fix version string to work in conda build
* Fix version string to work in docker build
* Change CI docker build to use `just`
* Fix Mac OS X conda build
* Make ISMRMRD an optional dependency
* Simplify C++ build in CI workflow
* Improve intermediate type names
  • Loading branch information
naegelejd authored Nov 12, 2024
1 parent 134b338 commit 5cc5997
Show file tree
Hide file tree
Showing 92 changed files with 8,078 additions and 3,214 deletions.
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.1
ARG YARDL_VERSION=0.6.2
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
5 changes: 5 additions & 0 deletions .devcontainer/devcontainer.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

source /opt/conda/etc/profile.d/conda.sh
conda activate mrd

source <(yardl completion bash)
source <(just --completions bash)

export MRD_VERSION_STRING=$(cat "${CONTAINER_WORKSPACE_DIR}/VERSION")


if [[ "${BASH_ENV:-}" == "$(readlink -f "${BASH_SOURCE[0]:-}")" ]]; then
# We don't want subshells to unnecessarily source this again.
Expand Down
22 changes: 12 additions & 10 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.1
YARDL_VERSION: 0.6.2

defaults:
run:
Expand All @@ -22,18 +22,18 @@ jobs:
build:
name: Build and Test C++, Python, MATLAB SDKs
runs-on: ubuntu-latest
strategy:
matrix:
cppVersion: [17, 20]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure Build Environment
uses: ./.github/actions/configure-mrd-build-environment

- name: Build and Test
run: just cpp_version=${{ matrix.cppVersion }} matlab=enabled validate-with-no-changes
- name: Build and Test with C++17
run: just cpp_version=17 matlab=enabled validate-with-no-changes

- name: Build and Test with C++20
run: just cpp_version=20 matlab=enabled validate-with-no-changes

- name: Package MATLAB toolbox
run: just build-matlab-toolbox
Expand Down Expand Up @@ -61,10 +61,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up just command runner
uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6
- name: Build and test Docker images
run: |
./docker/build-images.sh
./docker/test-docker-images.sh
run: just build-docker-images && just test-docker-images

publishDocs:
name: Publish Documentation
Expand Down Expand Up @@ -162,5 +162,7 @@ jobs:

- name: Checkout
uses: actions/checkout@v4
- name: Set up just command runner
uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6
- name: Push Docker images
run: ./docker/build-images.sh --tag "${GITHUB_REF_NAME}" --push
run: just build-docker-images --tag "${GITHUB_REF_NAME}" --push
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.1.0
65 changes: 59 additions & 6 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
cmake_minimum_required(VERSION 3.19)
project(mrd)

set(MRD_VERSION_STRING $ENV{MRD_VERSION_STRING})
if (DEFINED ENV{MRD_VERSION_STRING})
# Get the current version of MRD from the environment if possible
set(MRD_VERSION_STRING $ENV{MRD_VERSION_STRING})
else ()
# Otherwise, try to read it from the VERSION file at the top of this repo
if (IS_READABLE "${CMAKE_SOURCE_DIR}/../VERSION")
file(STRINGS "${CMAKE_SOURCE_DIR}/../VERSION" MRD_VERSION_STRING)
endif ()
endif ()

project(mrd VERSION ${MRD_VERSION_STRING})

message(STATUS "MRD_VERSION_STRING: ${MRD_VERSION_STRING}")

SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
Expand All @@ -13,10 +23,12 @@ if (NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif ()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
Expand All @@ -31,14 +43,55 @@ add_executable(mrd_minimal_example minimal_example.cc)
target_link_libraries(mrd_minimal_example mrd_generated)
install(TARGETS mrd_minimal_example DESTINATION bin)


string(REGEX MATCH "[0-9]+" MRD_SOVERSION ${MRD_VERSION_STRING})
message(STATUS "MRD_SOVERSION: ${MRD_SOVERSION}")

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

target_include_directories(mrd PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>")

target_link_libraries(mrd PRIVATE mrd_generated)
set_target_properties(mrd PROPERTIES
VERSION ${MRD_VERSION_STRING}
SOVERSION ${MRD_SOVERSION}
)

# Installation (libmrd)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

# MRD Library Headers
install(TARGETS mrd EXPORT mrd-targets
COMPONENT Devel
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(DIRECTORY mrd
DESTINATION include
TYPE INCLUDE
COMPONENT Devel
FILES_MATCHING PATTERN "*.h"
)

set(MRD_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/mrd" CACHE STRING "Path to MRD CMake files")

install(EXPORT mrd-targets
FILE mrd-targets.cmake
DESTINATION "${MRD_INSTALL_CMAKEDIR}"
NAMESPACE mrd::
COMPONENT Devel
)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/mrd-config-version.cmake"
VERSION ${MRD_VERSION_STRING}
COMPATIBILITY SameMajorVersion
)

install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/mrd-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/mrd-config-version.cmake"
DESTINATION "${MRD_INSTALL_CMAKEDIR}"
COMPONENT Devel
)
15 changes: 15 additions & 0 deletions cpp/cmake/mrd-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include(CMakeFindDependencyMacro)

set(HOWARD_HINNANT_DATE_MINIMUM_VERSION "3.0.0")
find_dependency(date ${HOWARD_HINNANT_DATE_MINIMUM_VERSION} REQUIRED)

set(HDF5_MINIMUM_VERSION "1.10.5")
find_dependency(HDF5 ${HDF5_MINIMUM_VERSION} REQUIRED COMPONENTS C CXX)

set(XTENSOR_MINIMUM_VERSION "0.21.10")
find_dependency(xtensor ${XTENSOR_MINIMUM_VERSION} REQUIRED)

set(NLOHMANN_JSON_MINIMUM_VERSION "3.11.1")
find_dependency(nlohmann_json ${NLOHMANN_JSON_MINIMUM_VERSION} REQUIRED)

include("${CMAKE_CURRENT_LIST_DIR}/MRDTargets.cmake")
129 changes: 44 additions & 85 deletions cpp/mrd-tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,95 +1,54 @@
include_directories(../)

find_package(ISMRMRD 1.13.4 REQUIRED)
add_executable(mrd_phantom mrd_phantom.cc shepp_logan_phantom.cc)
target_link_libraries(mrd_phantom mrd_generated fftw3f)

add_executable(mrd_hdf5_to_stream mrd_hdf5_to_stream.cc)
target_link_libraries(mrd_hdf5_to_stream mrd_generated)

add_executable(
mrd_phantom
mrd_phantom.cc
shepp_logan_phantom.cc
)

target_link_libraries(
mrd_phantom
mrd_generated
fftw3f
)

add_executable(
mrd_hdf5_to_stream
mrd_hdf5_to_stream.cc
)

target_link_libraries(
mrd_hdf5_to_stream
mrd_generated
)

add_executable(
mrd_stream_to_hdf5
mrd_stream_to_hdf5.cc
)

target_link_libraries(
mrd_stream_to_hdf5
mrd_generated
)

add_executable(
mrd_stream_recon
mrd_stream_recon.cc
)

target_link_libraries(
mrd_stream_recon
fftw3f
mrd_generated
)

add_executable(
ismrmrd_to_mrd
ismrmrd_to_mrd.cc
)

target_link_libraries(
ismrmrd_to_mrd
mrd_generated
ISMRMRD::ISMRMRD
)

add_executable(
mrd_to_ismrmrd
mrd_to_ismrmrd.cc
)

target_link_libraries(
mrd_to_ismrmrd
mrd_generated
ISMRMRD::ISMRMRD
)

find_package(ImageMagick COMPONENTS Magick++ REQUIRED)
find_package(fmt REQUIRED)
include_directories(${ImageMagick_INCLUDE_DIRS})

add_executable(
mrd_image_stream_to_png
mrd_image_stream_to_png.cc
)

target_compile_options(mrd_image_stream_to_png PRIVATE "-DMAGICKCORE_QUANTUM_DEPTH=8" "-DMAGICKCORE_HDRI_ENABLE=0")
target_link_libraries(
mrd_image_stream_to_png
mrd_generated
${ImageMagick_LIBRARIES}
fmt::fmt
)
add_executable(mrd_stream_to_hdf5 mrd_stream_to_hdf5.cc)
target_link_libraries(mrd_stream_to_hdf5 mrd_generated)

add_executable(mrd_stream_recon mrd_stream_recon.cc)
target_link_libraries(mrd_stream_recon fftw3f mrd_generated)

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)


find_package(ISMRMRD 1.13.4 REQUIRED)

if (ISMRMRD_FOUND)
message(STATUS "ISMRMRD found: ${ISMRMRD_INCLUDE_DIR}")

add_executable(ismrmrd_to_mrd ismrmrd_to_mrd.cc converters.cc)
target_link_libraries(ismrmrd_to_mrd mrd_generated ISMRMRD::ISMRMRD)

add_executable(mrd_to_ismrmrd mrd_to_ismrmrd.cc converters.cc)
target_link_libraries(mrd_to_ismrmrd mrd_generated ISMRMRD::ISMRMRD)

install(TARGETS ismrmrd_to_mrd mrd_to_ismrmrd DESTINATION bin)
else()
message(STATUS "ISMRMRD not found. Skipping conversion tools.")
endif()


find_package(ImageMagick COMPONENTS Magick++)
find_package(fmt)

if (ImageMagick_FOUND AND fmt_FOUND)
message(STATUS "ImageMagick and fmt found.")
include_directories(${ImageMagick_INCLUDE_DIRS})

add_executable(mrd_image_stream_to_png mrd_image_stream_to_png.cc)
target_compile_options(mrd_image_stream_to_png PRIVATE "-DMAGICKCORE_QUANTUM_DEPTH=8" "-DMAGICKCORE_HDRI_ENABLE=0")
target_link_libraries(mrd_image_stream_to_png mrd_generated ${ImageMagick_LIBRARIES} fmt::fmt)

install(TARGETS mrd_image_stream_to_png DESTINATION bin)
else()
message(STATUS "ImageMagick or fmt not found. Skipping mrd_image_stream_to_png.")
endif()
Loading

0 comments on commit 5cc5997

Please sign in to comment.