Skip to content

Commit

Permalink
Merge pull request #3 from ismrmrd/master
Browse files Browse the repository at this point in the history
Merge from master
  • Loading branch information
kspaceKelvin authored Nov 23, 2022
2 parents 33686d2 + 60aefa5 commit c83c2b9
Show file tree
Hide file tree
Showing 14 changed files with 262 additions and 9 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/siemens_to_ismrmrd_conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on:
pull_request:
branches:
- master
release:
types:
- created

jobs:
build-conda-packages:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- uses: conda-incubator/setup-miniconda@e81abac10ce2c37423b54eae5af93aa3b4d3475c
with:
activate-environment: siemens-to-ismrmrd-build
environment-file: conda/environment.yml
python-version: 3.9
auto-activate-base: false
- name: Build conda package
shell: bash -l {0}
working-directory: conda
run: |
./package.sh
echo "Packages built: $(find build_pkg -name siemens_to_ismrmrd*.tar.bz2)"
- name: Push conda package
shell: bash -l {0}
if: ${{ github.event_name == 'release' }}
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
working-directory: conda
run: |
./publish_package.sh -u ismrmrd -t "$ANACONDA_TOKEN" -p `find build_pkg -name siemens_to_ismrmrd*.tar.bz2`
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ message(STATUS "Looking for packages in : ${CMAKE_PREFIX_PATH}")
#VERSIONING
set(SIEMENS_TO_ISMRMRD_VERSION_MAJOR 1)
set(SIEMENS_TO_ISMRMRD_VERSION_MINOR 2)
set(SIEMENS_TO_ISMRMRD_VERSION_PATCH 2)
set(SIEMENS_TO_ISMRMRD_VERSION_PATCH 6)
set(SIEMENS_TO_ISMRMRD_VERSION_STRING ${SIEMENS_TO_ISMRMRD_VERSION_MAJOR}.${SIEMENS_TO_ISMRMRD_VERSION_MINOR}.${SIEMENS_TO_ISMRMRD_VERSION_PATCH})

# Generate the converter_version.h header file
Expand Down Expand Up @@ -67,7 +67,7 @@ set(Boost_USE_STATIC_RUNTIME OFF)


find_package(Boost COMPONENTS system thread program_options filesystem timer REQUIRED)
find_package(ISMRMRD 1.7.0 REQUIRED)
find_package(ISMRMRD 1.8.0 REQUIRED)
find_package(HDF5 REQUIRED COMPONENTS C)

include_directories( ${ISMRMRD_INCLUDE_DIR} ${HDF5_C_INCLUDE_DIR} )
Expand Down
3 changes: 3 additions & 0 deletions conda/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build_pkg/
.pytest_cache/
__pycache__/
9 changes: 9 additions & 0 deletions conda/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -euo pipefail

mkdir -p build
cd build
cmake -G Ninja -DBUILD_DYNAMIC=ON -DCMAKE_PREFIX_PATH=${PREFIX} -DCMAKE_INSTALL_PREFIX=${PREFIX} ../
ninja
ninja install
7 changes: 7 additions & 0 deletions conda/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: siemens-to-ismrmrd-build
channels:
- conda-forge
dependencies:
- conda-build
- anaconda-client

39 changes: 39 additions & 0 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% set major = load_file_regex(load_file='CMakeLists.txt', regex_pattern='(?<=set\(SIEMENS_TO_ISMRMRD_VERSION_MAJOR )([^\)]+)') %}
{% set minor = load_file_regex(load_file='CMakeLists.txt', regex_pattern='(?<=set\(SIEMENS_TO_ISMRMRD_VERSION_MINOR )([^\)]+)') %}
{% set patch = load_file_regex(load_file='CMakeLists.txt', regex_pattern='(?<=set\(SIEMENS_TO_ISMRMRD_VERSION_PATCH )([^\)]+)') %}

package:
name: siemens_to_ismrmrd
version: {{ major.group(1) }}.{{ minor.group(1) }}.{{ patch.group(1) }}

source:
path: ../

requirements:
build:
- boost=1.76.0
- clang>=13.0.1 # [osx]
- clangxx>=13.0.1 # [osx]
- cmake>=3.20.0
- gcc_linux-64>=9.0.0 # [linux64]
- gxx_linux-64>=9.0.0 # [linux64]
- ismrmrd=1.12.0
- libxml2=2.9.12
- libxslt=1.1.33
- ninja=1.10.*

run:
- ismrmrd=1.12.0
- boost=1.76.0
- libxml2=2.9.12
- libxslt=1.1.33

about:
home: https://github.com/ismrmrd/siemens_to_ismrmrd
license: MIT
summary: 'Siemens to ISMRM Raw Data (ISMRMRD) converter'
description: |
Command line tool for converting Siemens raw data (*.dat) files to ISMRMRD files.
dev_url: https://github.com/ismrmrd/siemens_to_ismrmrd
doc_url: https://github.com/ismrmrd/siemens_to_ismrmrd
doc_source_url: https://github.com/ismrmrd/siemens_to_ismrmrd/blob/master/README.md
25 changes: 25 additions & 0 deletions conda/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -euo pipefail

usage()
{
cat << EOF
Builds the siemens_to_ismrmrd conda package.
Usage: $0
EOF
}

output_path="$(dirname "$0")/build_pkg"

# Build up channel directives
channels=(
ismrmrd
conda-forge
)

channel_directives=$(printf -- "-c %s " "${channels[@]}")

mkdir -p "$output_path"
bash -c "conda build --no-anaconda-upload --output-folder $output_path $channel_directives $(dirname "$0")"
77 changes: 77 additions & 0 deletions conda/publish_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash
set -euo pipefail

usage()
{
cat << EOF
Publishes a conda package.
Usage: $0 [options]
Options:
-p|--package_path <path> Path to the package (tar.gz) to push
-u|--user <user> Anaconda.org channeluser or organization
-t|--token <token> Token for uploading to anaconda.org
-f|--force Force push even if package exists
-h| --help Brings up this menu
EOF
}

while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-p|--package_path)
package_path="$2"
shift
shift
;;
-u|--user)
user="$2"
shift
shift
;;
-t|--token)
token="$2"
shift
shift
;;
--force)
force=1
shift
;;
-h|--help)
usage
exit
;;
*)
echo "ERROR: unknown option \"$key\""
usage
exit 1
;;
esac
done

if [[ -z "${package_path:-}" ]]; then
echo "You cannot push to anaconda without a package"
echo "Please supply a package path with the --package_path argument"
exit 1
fi
if [[ -z "${token:-}" ]]; then
echo "You cannot push to anaconda without a token"
echo "Please supply a token with the --token argument"
exit 1
fi
if [[ -z "${user:-}" ]]; then
echo "You cannot push to anaconda without a user"
echo "Please supply a user with the --user argument"
exit 1
fi

force_directive="--skip-existing"
if [[ -n ${force:-} ]]; then
force_directive="--force"
fi

anaconda -t "$token" upload -u "$user" $force_directive "$package_path"
10 changes: 10 additions & 0 deletions conda/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -euo pipefail

# We are just printing help text, which will fail if dependencies are missing
siemens_to_ismrmrd -h
siemens_to_ismrmrd -v



2 changes: 1 addition & 1 deletion dependencies/ismrmrd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5672c474292f0b87e9c0aedcb5f1bc87ef0544f8
f9e38ed8cda6428839005c060579d3dfdb043515
10 changes: 5 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,15 +515,15 @@ int main(int argc, char* argv[]) {

if (vm.count("help")) {
std::cout << display_options << "\n";
return 1;
return 0;
}

if (vm.count("version")) {
std::cout << "Converter version is: " << SIEMENS_TO_ISMRMRD_VERSION_MAJOR << "."
<< SIEMENS_TO_ISMRMRD_VERSION_MINOR << "." << SIEMENS_TO_ISMRMRD_VERSION_PATCH << "\n";
std::cout << "Built against ISMRMRD version: " << ISMRMRD_VERSION_MAJOR << "." << ISMRMRD_VERSION_MINOR
<< "." << ISMRMRD_VERSION_PATCH << "\n";
return 1;
return 0;
}
}

Expand Down Expand Up @@ -1105,9 +1105,9 @@ getAcquisition(bool flash_pat_ref_scan, const Trajectory &trajectory, long dwell
}
// std::cout << "ismrmrd_acq.sample_time_us(): " << ismrmrd_acq.sample_time_us() << std::endl;

ismrmrd_acq.position()[0] = scanhead.sSliceData.sSlicePosVec.flSag + (float) (global_table_pos[0]);
ismrmrd_acq.position()[1] = scanhead.sSliceData.sSlicePosVec.flCor + (float) (global_table_pos[1]);
ismrmrd_acq.position()[2] = scanhead.sSliceData.sSlicePosVec.flTra + (float) (global_table_pos[2]);
ismrmrd_acq.position()[0] = scanhead.sSliceData.sSlicePosVec.flSag;// + (float) (global_table_pos[0]);
ismrmrd_acq.position()[1] = scanhead.sSliceData.sSlicePosVec.flCor;// + (float) (global_table_pos[1]);
ismrmrd_acq.position()[2] = scanhead.sSliceData.sSlicePosVec.flTra;// + (float) (global_table_pos[2]);

// Convert Siemens quaternions to direction cosines.
// In the Siemens convention the quaternion corresponds to a rotation matrix with columns P R S
Expand Down
4 changes: 4 additions & 0 deletions parameter_maps/IsmrmrdParameterMap_Siemens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<p><s>MEAS.sSliceArray.asSlice.0.dReadoutFOV</s> <d>siemens.MEAS.sSliceArray.asSlice.s0.dReadoutFOV</d></p>
<p><s>MEAS.sSliceArray.asSlice.0.dPhaseFOV</s> <d>siemens.MEAS.sSliceArray.asSlice.s0.dPhaseFOV</d></p>
<p><s>MEAS.sSliceArray.asSlice.0.dThickness</s> <d>siemens.MEAS.sSliceArray.asSlice.s0.dThickness</d></p>
<p><s>MEAS.sSliceArray.asSlice.0.dInPlaneRot</s> <d>siemens.MEAS.sSliceArray.asSlice.s0.dInPlaneRot</d></p>
<p><s>MEAS.sAngio.sFlowArray.lSize</s> <d>siemens.MEAS.sAngio.sFlowArray.lSize</d></p>
<p><s>MEAS.sAngio.sFlowArray.asElm.0.nVelocity</s> <d>siemens.MEAS.sAngio.sFlowArray.asElm.s0.nVelocity</d></p>
<p><s>YAPS.aflMaxwellCoefficients</s> <d>siemens.YAPS.aflMaxwellCoefficients</d></p>
Expand Down Expand Up @@ -84,6 +85,9 @@
<!-- measurementInformationType -->
<p><s>HEADER.MeasUID</s> <d>siemens.HEADER.MeasUID</d></p>
<p><s>YAPS.tPatientPosition</s> <d>siemens.YAPS.tPatientPosition</d></p>
<p><s>DICOM.lGlobalTablePosSag</s> <d>siemens.DICOM.lGlobalTablePosSag</d></p>
<p><s>DICOM.lGlobalTablePosCor</s> <d>siemens.DICOM.lGlobalTablePosCor</d></p>
<p><s>DICOM.lGlobalTablePosTra</s> <d>siemens.DICOM.lGlobalTablePosTra</d></p>
<p><s>MEAS.tProtocolName</s> <d>siemens.MEAS.tProtocolName</d></p>
<p><s>YAPS.ReconMeasDependencies.0</s> <d>siemens.YAPS.ReconMeasDependencies.RFMap</d></p>
<p><s>YAPS.ReconMeasDependencies.1</s> <d>siemens.YAPS.ReconMeasDependencies.SenMap</d></p>
Expand Down
38 changes: 38 additions & 0 deletions parameter_maps/IsmrmrdParameterMap_Siemens.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,38 @@
<xsl:value-of
select="concat(string(siemens/DICOM/DeviceSerialNumber), $strSeperator, $patientID, $strSeperator, $studyID, $strSeperator, string(siemens/HEADER/MeasUID))"/>
</measurementID>

<patientPosition>
<xsl:value-of select="siemens/YAPS/tPatientPosition"/>
</patientPosition>

<relativeTablePosition>
<x>
<xsl:choose>
<xsl:when test="siemens/DICOM/lGlobalTablePosSag">
<xsl:value-of select="siemens/DICOM/lGlobalTablePosSag"/>
</xsl:when>
<xsl:otherwise>0.0</xsl:otherwise>
</xsl:choose>
</x>
<y>
<xsl:choose>
<xsl:when test="siemens/DICOM/lGlobalTablePosCor">
<xsl:value-of select="siemens/DICOM/lGlobalTablePosCor"/>
</xsl:when>
<xsl:otherwise>0.0</xsl:otherwise>
</xsl:choose>
</y>
<z>
<xsl:choose>
<xsl:when test="siemens/DICOM/lGlobalTablePosTra">
<xsl:value-of select="siemens/DICOM/lGlobalTablePosTra"/>
</xsl:when>
<xsl:otherwise>0.0</xsl:otherwise>
</xsl:choose>
</z>
</relativeTablePosition>

<protocolName>
<xsl:value-of select="siemens/MEAS/tProtocolName"/>
</protocolName>
Expand Down Expand Up @@ -1016,6 +1045,15 @@
</userParameterDouble>
</xsl:if>

<xsl:if test="siemens/MEAS/sSliceArray/asSlice/s0/dInPlaneRot">
<userParameterDouble>
<name>InPlaneRot</name>
<value>
<xsl:value-of select="siemens/MEAS/sSliceArray/asSlice/s0/dInPlaneRot" />
</value>
</userParameterDouble>
</xsl:if>

<xsl:if test="siemens/YAPS/flContrastBolusVolume">
<userParameterDouble>
<name>ContrastBolusVolume</name>
Expand Down
7 changes: 6 additions & 1 deletion parameter_maps/IsmrmrdParameterMap_Siemens_EPI_FLASHREF.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,12 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:value-of select="siemens/MEAS/sKSpace/lPhaseEncodingLines"/>
</y>
<z>
<xsl:value-of select="siemens/MEAS/sPAT/lRefLines3D"/>
<xsl:choose>
<xsl:when test="not(siemens/MEAS/sPAT/lRefLines3D)">1</xsl:when>
<xsl:otherwise>
<xsl:value-of select="(siemens/MEAS/sPAT/lRefLines3D)"/>
</xsl:otherwise>
</xsl:choose>
</z>
</matrixSize>
<fieldOfView_mm>
Expand Down

0 comments on commit c83c2b9

Please sign in to comment.