Skip to content

Commit

Permalink
Add sync option to keep classifications definitions up-to-date.
Browse files Browse the repository at this point in the history
  • Loading branch information
lmperry committed Jun 4, 2018
1 parent 0427741 commit 78a1ec6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ RUN apt-get update && apt-get -y install \
jq \
git \
unzip \
tzdata
tzdata \
wget

# Install Pip libs
RUN pip install \
Expand Down
13 changes: 9 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
{
"name": "pfile-mr-classifier",
"label": "CNI: GE P-File Classifier",
"description": "Extracts GE P-File headers and generates JSON metadata (.metadata.json) which is saved in Flywheel on the P-File's info object. This gear also attempts to determine the P-Files classification.",
"description": "Extracts GE P-File header and generates JSON metadata (.metadata.json) which is saved in Flywheel on the P-File's info object. This gear also attempts to determine the P-File's classification (measurement, intent, etc.).",
"maintainer": "Michael Perry <[email protected]>",
"author": "Michael Perry <[email protected]>",
"url": "https://cni.stanford.edu",
"source": "https://github.com/cni/pfile-mr-classifier",
"cite": "pfile-tools: GE P-File Utilities (https://github.com/njvack/pfile-tools)",
"license": "BSD-2-Clause",
"flywheel": "0",
"version": "1.0.0",
"version": "1.1.0",
"custom": {
"docker-image": "stanfordcni/pfile-mr-classifier:1.0.0"
"docker-image": "stanfordcni/pfile-mr-classifier:1.1.0"
},
"config": {
"timezone": {
"description": "Time Zone to which all timestamps should be localized. This will set the default time zone in the Gear and thus localize the timestamps to that time zone. Examples: 'America/Los_Angeles', 'America/New_York'. [default = 'America/Los_Angeles'].",
"description": "Time Zone to which all timestamps should be localized. This will set the default time zone in the Gear and thus localize the timestamps to that time zone. Examples: 'UTC', 'America/Los_Angeles', 'America/New_York'. [default = 'America/Los_Angeles'].",
"type": "string",
"default": "America/Los_Angeles"
},
"sync": {
"description": "Synchronize classification definitions with the latest known updates found at scitran-apps/dicom-mr-classifier [default = true].",
"type": "boolean",
"default": true
}
},
"inputs": {
Expand Down
14 changes: 12 additions & 2 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ echo "$TZ" > /etc/timezone && ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime
dpkg-reconfigure -f noninteractive tzdata


if [[ ${config_sync} == "true" ]]; then
echo -e "$CONTAINER Syncing classification code from scitran-apps/dicom-mr-classifier/master..."
wget --quiet -O ${FLYWHEEL_BASE}/classification_from_label.py \
https://raw.githubusercontent.com/scitran-apps/dicom-mr-classifier/master/classification_from_label.py
chmod +x ${FLYWHEEL_BASE}/classification_from_label.py
else
echo -e "$CONTAINER Not syncing classification code. Using built-in version..."
fi


##############################################################################
# Check I/O directories and Generate metadata

Expand All @@ -57,7 +67,7 @@ if [[ -f $input_file ]]; then
# Generate the header from the zip file and export to csv
echo -e "${CONTAINER} Extracting header from $input_file"
header_file=/tmp/pfile_header
unzip -p "$input_file" "*/P*.7.gz" | head -c 1000000 | gunzip > $header_file
unzip -p "$input_file" "*/P*.7.gz" | head -c 1000000 | gunzip > $header_file 2>/dev/null
/opt/pfile-tools/pfile_tools/scripts/dump_pfile_header.py $header_file --separator=, > $header_file.csv

if [[ ! -f "$header_file".csv ]]; then
Expand All @@ -66,7 +76,7 @@ if [[ -f $input_file ]]; then
fi

# Generate the metadata
echo -e "${CONTAINER} Generating metadata"
echo -e "${CONTAINER} Generating metadata..."
PYHONPATH=$PYTHONPATH:/flywheel/v0/ python $FLYWHEEL_BASE/pfile-mr-classifier.py \
"${input_file}" \
"${header_file}" \
Expand Down

0 comments on commit 78a1ec6

Please sign in to comment.