inm-icf-utilities/.appveyor/data_create_scanner_output
Christian Monch afda3f1e01 fix redirection following, factor out sudo
This commit instructs curl to follow redirections,
in order to properly download example DICOMs.

The commit also removes all sudo calls from the
scanner output creation script. Instead the
script is called via sudo from `.appveyor.yml`

In addition the commit adds a script to check
the version compatiblity of the installed
test environment against variables that hold
the versions which are used in ICF
2023-05-16 11:00:27 +02:00

37 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
set -e -u
from_scanner_dir="$1"; shift
study="$1"; shift
lower="$1"; shift
upper="$1"; shift
# We take example DICOMs from this location
url_base="https://github.com/datalad/example-dicom-structural/raw/master/dicoms/N2D_"
# The directory hierarchy in the incoming DICOM directory. This is modeled after
# an example dataset.
dicom_hierarchy=${study}_7T8088/incoming/${study}/654321_7T8088/SCANS/1/DICOM
dicom_base_name=1.3.12.2.1107.5.2.0.79109.30000021070907115904000000007-1
target_dir="$from_scanner_dir"/"$dicom_hierarchy"
mkdir -p "$target_dir"
# Copy N2D_<lower>.dcm to N2D_<upper>.dcm to $from_scanner_dir
while [ "$lower" -le "$upper" ]; do
url="$url_base"$(printf "%04d" "$lower").dcm
dicom_name=${dicom_base_name}-${lower}-$(echo $RANDOM|base64 -).dcm
target_name="$target_dir"/"$dicom_name"
echo copying "$url" "->" "$target_name"
curl -s -L -o "$target_name" "$url"
lower=$(( "$lower" + 1 ))
done
# Create a non-DICOM file to allow testing for correct mtime setting
cat <<EOF | tee "$target_dir"/info.xml > /dev/null
<xml><info>This is not a DICOM file</info></xml>
EOF