Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 437086a

Browse files
authored
Merge pull request #2 from flywheel-apps/GEAR-1498-custom-classification
[GEAR-1498] custom classification
2 parents 378010f + de44992 commit 437086a

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This repo is now hosted in [flywheel-apps](https://github.com/flywheel-apps/dicom-mr-classifer)
2+
13
[![Docker Pulls](https://img.shields.io/docker/pulls/scitran/dicom-mr-classifier.svg)](https://hub.docker.com/r/scitran/dicom-mr-classifier/)
24
[![Docker Stars](https://img.shields.io/docker/stars/scitran/dicom-mr-classifier.svg)](https://hub.docker.com/r/scitran/dicom-mr-classifier/)
35
[![CircleCI](https://circleci.com/gh/scitran-apps/dicom-mr-classifier.svg?style=svg)](https://circleci.com/gh/scitran-apps/dicom-mr-classifier)

dicom-mr-classifier.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def get_custom_classification(label, config=None):
408408
for k in classifications.keys():
409409
val = classifications[k]
410410

411-
if not isinstance(val, basestring):
411+
if not isinstance(val, str):
412412
log.warn("Expected string value for classification key %s", k)
413413
continue
414414

@@ -587,18 +587,27 @@ def dicom_classify(zip_file_path, outbase, timezone, config=None):
587587
classification = {'Custom': ['N/A']}
588588
elif dcm.get("Modality") != "MR":
589589
classification = {}
590-
dicom_file["classification"] = classification
590+
dicom_file["classification"].update(classification)
591591

592592
# If no pixel data present, make classification intent "Non-Image"
593593
if not hasattr(dcm, "PixelData"):
594-
nonimage_intent = {"Intent": ["Non-Image"]}
594+
nonimage_intent = "Non-Image"
595595
# If classification is a dict, update dict with intent
596596
if isinstance(dicom_file["classification"], dict):
597-
dicom_file["classification"].update(nonimage_intent)
597+
classification = dicom_file['classification']
598+
# If intent not present, add it with nonimage_intent
599+
if 'Intent' not in classification:
600+
classification['Intent'] = nonimage_intent
601+
else:
602+
# Otherwise append non-image if not in Intent
603+
if nonimage_intent not in classification['Intent']:
604+
classification['Intent'].append(nonimage_intent)
598605
# Else classification is a list, assign dict with intent
599606
else:
600607
dicom_file["classification"] = nonimage_intent
601608

609+
610+
602611
# File info from dicom header
603612
dicom_file["info"] = get_dicom_header(dcm)
604613

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
"source": "https://github.com/flywheel-apps/dicom-mr-classifier/releases",
99
"license": "Apache-2.0",
1010
"flywheel": "0",
11-
"version": "1.4.4",
11+
"version": "1.4.5",
1212
"custom": {
1313
"gear-builder": {
14-
"image": "flywheel/dicom-mr-classifier:1.4.4",
14+
"image": "flywheel/dicom-mr-classifier:1.4.5",
1515
"category": "converter"
1616
},
1717
"flywheel": {

0 commit comments

Comments
 (0)