Skip to content

Commit

Permalink
Fix mrd_phantom named pipe bug (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
naegelejd authored Oct 23, 2024
1 parent 466bd9a commit 134b338
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 49 deletions.
5 changes: 2 additions & 3 deletions .github/actions/configure-mrd-build-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Configure MRD Build Environment
description: Configures the conda development environment

# The following inputs are currently expected environment variables:
# YARDL_VERSION, e.g. 0.5.0
# CONDA_CACHE_NUMBER, e.g. 0
# YARDL_VERSION
# CONDA_CACHE_NUMBER

runs:
using: composite
Expand All @@ -20,7 +20,6 @@ runs:
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Miniforge3
miniforge-version: latest
# Do not specify environment file - see Cache step below
activate-environment: mrd
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/mrd_conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Download MacOSX SDK
if: startsWith(matrix.os, 'macos')
run: |
curl -o MacOSX10.13.sdk.tar.xz -L https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.13.sdk.tar.xz && \
tar xf MacOSX10.13.sdk.tar.xz && \
sudo mv -v MacOSX10.13.sdk /opt/ && \
ls /opt/
- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: true
activate-environment: ""
miniforge-variant: Miniforge3
miniforge-version: latest

- name: Set up just command runner
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.0.1
14 changes: 6 additions & 8 deletions cpp/conda/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ set -euo pipefail
mkdir -p build-conda
cd build-conda

if [[ $(uname) == Darwin ]]; then
export CFLAGS="${CFLAGS:-} -isysroot ${CONDA_BUILD_SYSROOT} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
export CXXFLAGS="${CXXFLAGS:-} -isysroot ${CONDA_BUILD_SYSROOT} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
# export SDKROOT="${CONDA_BUILD_SYSROOT}"
fi

echo 'Building mrd conda package using CMake...'

cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${PREFIX} \
../
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_OSX_SYSROOT=${CONDA_BUILD_SYSROOT} \
../

ninja install
6 changes: 2 additions & 4 deletions cpp/conda/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
c_compiler_version:
- 11.2.0 # [linux]
- 14 # [osx]
- 14.0.6 # [osx]
cxx_compiler_version:
- 11.2.0 # [linux]
- 14 # [osx]
- 14.0.6 # [osx]

MACOSX_DEPLOYMENT_TARGET: # [osx]
- 10.13 # [osx]
CONDA_BUILD_SYSROOT: # [osx]
- /opt/MacOSX10.13.sdk # [osx]
1 change: 0 additions & 1 deletion cpp/conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ build:

requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake
- ninja
Expand Down
8 changes: 4 additions & 4 deletions cpp/mrd-tools/ismrmrd_to_mrd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,8 @@ mrd::Image<T> convert(ISMRMRD::Image<T>& im) {

void print_usage(std::string program_name) {
std::cerr << "Usage: " << program_name << std::endl;
std::cerr << " -i|--input-file <input ISMRMRD stream> (default: stdin)" << std::endl;
std::cerr << " -o|--output-file <output MRD stream> (default: stdout)" << std::endl;
std::cerr << " -i|--input <input ISMRMRD stream> (default: stdin)" << std::endl;
std::cerr << " -o|--output <output MRD stream> (default: stdout)" << std::endl;
std::cerr << " -h|--help" << std::endl;
}

Expand All @@ -1006,7 +1006,7 @@ int main(int argc, char** argv) {
if (*current_arg == "--help" || *current_arg == "-h") {
print_usage(args[0]);
return 0;
} else if (*current_arg == "--input-file" || *current_arg == "-i") {
} else if (*current_arg == "--input" || *current_arg == "-i") {
current_arg++;
if (current_arg == args.end()) {
std::cerr << "Missing input file" << std::endl;
Expand All @@ -1015,7 +1015,7 @@ int main(int argc, char** argv) {
}
input_path = *current_arg;
current_arg++;
} else if (*current_arg == "--output-file" || *current_arg == "-o") {
} else if (*current_arg == "--output" || *current_arg == "-o") {
current_arg++;
if (current_arg == args.end()) {
std::cerr << "Missing output file" << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions cpp/mrd-tools/mrd_image_stream_to_png.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

void print_usage(std::string program_name) {
std::cerr << "Usage: " << program_name << std::endl;
std::cerr << " -i|--input-file <input MRD stream> (default: stdin)" << std::endl;
std::cerr << " -i|--input <input MRD stream> (default: stdin)" << std::endl;
std::cerr << " -o|--output-prefix <output file prefix> (default: image_)" << std::endl;
std::cerr << " -h|--help" << std::endl;
}
Expand All @@ -21,7 +21,7 @@ int main(int argc, char** argv) {
if (*current_arg == "--help" || *current_arg == "-h") {
print_usage(args[0]);
return 0;
} else if (*current_arg == "--input-file" || *current_arg == "-i") {
} else if (*current_arg == "--input" || *current_arg == "-i") {
current_arg++;
if (current_arg == args.end()) {
std::cerr << "Missing input file" << std::endl;
Expand Down
11 changes: 5 additions & 6 deletions cpp/mrd-tools/mrd_phantom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ mrd::ImageData<std::complex<float>> generate_coil_kspace(size_t matrix, size_t n

void print_usage(std::string program_name) {
std::cerr << "Usage: " << program_name << std::endl;
std::cerr << " -o|--output-file <output MRD stream> (default: stdout)" << std::endl;
std::cerr << " -c|--coils <number of coils>" << std::endl;
std::cerr << " -m|--matrix <matrix size>" << std::endl;
std::cerr << " -r|--repetitions <number of repetitions>" << std::endl;
std::cerr << " -o|--output <output MRD stream> (default: stdout)" << std::endl;
std::cerr << " -c|--coils <number of coils>" << std::endl;
std::cerr << " -m|--matrix <matrix size>" << std::endl;
std::cerr << " -r|--repetitions <number of repetitions>" << std::endl;
std::cerr << " -s|--oversampling <oversampling>" << std::endl;
std::cerr << " -h|--help" << std::endl;
}
Expand All @@ -68,7 +68,7 @@ int main(int argc, char** argv) {
if (*current_arg == "--help" || *current_arg == "-h") {
print_usage(args[0]);
return 0;
} else if (*current_arg == "--output-file" || *current_arg == "-o") {
} else if (*current_arg == "--output" || *current_arg == "-o") {
current_arg++;
if (current_arg == args.end()) {
std::cerr << "Missing output file" << std::endl;
Expand Down Expand Up @@ -134,7 +134,6 @@ int main(int argc, char** argv) {
if (filename.empty()) {
w = std::make_unique<mrd::binary::MrdWriter>(std::cout);
} else {
std::remove(filename.c_str());
w = std::make_unique<mrd::binary::MrdWriter>(filename);
}

Expand Down
8 changes: 4 additions & 4 deletions cpp/mrd-tools/mrd_stream_recon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ void remove_oversampling(mrd::Acquisition& acq, const mrd::EncodingType& enc) {

void print_usage(std::string program_name) {
std::cerr << "Usage: " << program_name << std::endl;
std::cerr << " -i|--input-file <input MRD stream> (default: stdin)" << std::endl;
std::cerr << " -o|--output-file <output MRD stream> (default: stdout)" << std::endl;
std::cerr << " -i|--input <input MRD stream> (default: stdin)" << std::endl;
std::cerr << " -o|--output <output MRD stream> (default: stdout)" << std::endl;
std::cerr << " -h|--help" << std::endl;
}

Expand All @@ -48,7 +48,7 @@ int main(int argc, char** argv) {
if (*current_arg == "--help" || *current_arg == "-h") {
print_usage(args[0]);
return 0;
} else if (*current_arg == "--input-file" || *current_arg == "-i") {
} else if (*current_arg == "--input" || *current_arg == "-i") {
current_arg++;
if (current_arg == args.end()) {
std::cerr << "Missing input file" << std::endl;
Expand All @@ -57,7 +57,7 @@ int main(int argc, char** argv) {
}
input_path = *current_arg;
current_arg++;
} else if (*current_arg == "--output-file" || *current_arg == "-o") {
} else if (*current_arg == "--output" || *current_arg == "-o") {
current_arg++;
if (current_arg == args.end()) {
std::cerr << "Missing output file" << std::endl;
Expand Down
8 changes: 4 additions & 4 deletions cpp/mrd-tools/mrd_to_ismrmrd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,8 @@ ISMRMRD::Image<T> convert(mrd::Image<T>& image) {

void print_usage(std::string program_name) {
std::cerr << "Usage: " << program_name << std::endl;
std::cerr << " -i|--input-file <input MRD stream> (default: stdin)" << std::endl;
std::cerr << " -o|--output-file <output ISMRMRD stream> (default: stdout)" << std::endl;
std::cerr << " -i|--input <input MRD stream> (default: stdin)" << std::endl;
std::cerr << " -o|--output <output ISMRMRD stream> (default: stdout)" << std::endl;
std::cerr << " -h|--help" << std::endl;
}

Expand All @@ -1063,7 +1063,7 @@ int main(int argc, char** argv) {
if (*current_arg == "--help" || *current_arg == "-h") {
print_usage(args[0]);
return 0;
} else if (*current_arg == "--input-file" || *current_arg == "-i") {
} else if (*current_arg == "--input" || *current_arg == "-i") {
current_arg++;
if (current_arg == args.end()) {
std::cerr << "Missing input file" << std::endl;
Expand All @@ -1072,7 +1072,7 @@ int main(int argc, char** argv) {
}
input_path = *current_arg;
current_arg++;
} else if (*current_arg == "--output-file" || *current_arg == "-o") {
} else if (*current_arg == "--output" || *current_arg == "-o") {
current_arg++;
if (current_arg == args.end()) {
std::cerr << "Missing output file" << std::endl;
Expand Down
15 changes: 14 additions & 1 deletion test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,18 @@ cat py2py_images.bin | python -m mrd.tools.export_png_images -o py2py
ifmatlab && cat mat2mat_images.bin | ./matlab_export_png_images.sh mat2mat


echo Testing again using named pipes
test -e recon_in.pipe || mkfifo recon_in.pipe
test -e recon_out.pipe || mkfifo recon_out.pipe

mrd_phantom --output recon_in.pipe &
mrd_stream_recon --input recon_in.pipe --output recon_out.pipe &
mrd_image_stream_to_png --input recon_out.pipe

python -m mrd.tools.phantom --output recon_in.pipe &
python -m mrd.tools.stream_recon --input recon_in.pipe --output recon_out.pipe &
python -m mrd.tools.export_png_images --input recon_out.pipe


echo Cleaning up
rm -f ./*.bin ./*.png
rm -f ./*.bin ./*.png ./*.pipe
2 changes: 1 addition & 1 deletion utils/conda/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ channels=(
channel_directives=$(printf -- "-c %s " "${channels[@]}")

mkdir -p "$output_path"
bash -c "conda mambabuild --no-anaconda-upload --output-folder $output_path $channel_directives $(pwd)"
bash -c "conda build --no-anaconda-upload --output-folder $output_path $channel_directives $(pwd)"
2 changes: 1 addition & 1 deletion utils/conda/setup-conda-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
set -e

# conda deactivate
mamba install -y -n base conda-build conda-verify anaconda-client boa
conda install -y -n base conda-build anaconda-client
conda activate base

0 comments on commit 134b338

Please sign in to comment.