diff --git a/.gitignore b/.gitignore index 1bbd191..4fe15de 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,4 @@ htmlcov .idea/ .vscode/ -in/ out/ diff --git a/README.rst b/README.rst index 7aa52e9..175aa03 100644 --- a/README.rst +++ b/README.rst @@ -53,3 +53,12 @@ Examples -v $PWD/covidnet-out:/incoming:ro -v $PWD/pdfgeneration-out:/outgoing:rw \ fnndsc/pl-covidnet-pdfgeneration:0.2.0 pdfgeneration \ --imagefile chest-scan.jpg --patientId 12345678 /incoming /outgoing + + docker run --rm -v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing \ + jonocameron/pl-pdfgeneration pdfgeneration --imagefile "ex-covid.jpeg" --patientId "77812345" \ + /incoming /outgoing + + docker run --rm -u $(id -u) \ + -v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing \ + jonocameron/pl-tpdf tpdf --dir "41" \ + --imagefile "ex-covid.jpeg" --patientId 12345678 /incoming /outgoing diff --git a/in/41/ex-covid.jpeg b/in/41/ex-covid.jpeg new file mode 100644 index 0000000..abaa8fb Binary files /dev/null and b/in/41/ex-covid.jpeg differ diff --git a/in/41/prediction-default.json b/in/41/prediction-default.json new file mode 100644 index 0000000..378d273 --- /dev/null +++ b/in/41/prediction-default.json @@ -0,0 +1,7 @@ +{ + "**DISCLAIMER**": "Do not use this prediction for self-diagnosis. You should check with your local authorities for the latest advice on seeking medical assistance.", + "prediction": "COVID-19", + "Normal": "0.00052875147", + "Pneumonia": "0.010959083", + "COVID-19": "0.98851216" +} \ No newline at end of file diff --git a/in/41/severity.json b/in/41/severity.json new file mode 100644 index 0000000..97709a9 --- /dev/null +++ b/in/41/severity.json @@ -0,0 +1,8 @@ +{ + "Geographic severity": "52", + "Geographic extent score": "4.2", + "GeoInfo": "For each lung: 0 = no involvement; 1 = <25%; 2 = 25-50%; 3 = 50-75%; 4 = >75% involvement.", + "Opacity severity": "52", + "Opacity extent score": "3.1", + "OpcInfo": "For each lung: 0 = no opacity; 1 = ground glass opacity; 2 =consolidation; 3 = white-out." +} \ No newline at end of file diff --git a/in/ex-covid.jpeg b/in/ex-covid.jpeg new file mode 100644 index 0000000..abaa8fb Binary files /dev/null and b/in/ex-covid.jpeg differ diff --git a/in/prediction-default.json b/in/prediction-default.json new file mode 100644 index 0000000..378d273 --- /dev/null +++ b/in/prediction-default.json @@ -0,0 +1,7 @@ +{ + "**DISCLAIMER**": "Do not use this prediction for self-diagnosis. You should check with your local authorities for the latest advice on seeking medical assistance.", + "prediction": "COVID-19", + "Normal": "0.00052875147", + "Pneumonia": "0.010959083", + "COVID-19": "0.98851216" +} \ No newline at end of file diff --git a/in/severity.json b/in/severity.json new file mode 100644 index 0000000..97709a9 --- /dev/null +++ b/in/severity.json @@ -0,0 +1,8 @@ +{ + "Geographic severity": "52", + "Geographic extent score": "4.2", + "GeoInfo": "For each lung: 0 = no involvement; 1 = <25%; 2 = 25-50%; 3 = 50-75%; 4 = >75% involvement.", + "Opacity severity": "52", + "Opacity extent score": "3.1", + "OpcInfo": "For each lung: 0 = no opacity; 1 = ground glass opacity; 2 =consolidation; 3 = white-out." +} \ No newline at end of file diff --git a/pdfgeneration/pdfgeneration.py b/pdfgeneration/pdfgeneration.py index 0f4730a..83a95e9 100755 --- a/pdfgeneration/pdfgeneration.py +++ b/pdfgeneration/pdfgeneration.py @@ -66,6 +66,12 @@ def define_parameters(self): Define the CLI arguments accepted by this plugin app. Use self.add_argument to specify a new app argument. """ + self.add_argument('--dir', + dest = 'dir', + type = str, + optional = True, + default = '', + help = 'directory') self.add_argument('--imagefile', dest = 'imagefile', type = str, @@ -84,11 +90,17 @@ def run(self, options): """ print(Gstr_title) print('Version: %s' % self.get_version()) + + + directory = options.dir + parent_dir = options.inputdir + nPath = os.path.join(parent_dir , directory) + # fetch input data - with open('{}/prediction-default.json'.format(options.inputdir)) as f: + with open('{}/prediction-default.json'.format(nPath)) as f: classification_data = json.load(f) try: - with open('{}/severity.json'.format(options.inputdir)) as f: + with open('{}/severity.json'.format(nPath)) as f: severityScores = json.load(f) except: severityScores = None @@ -120,9 +132,11 @@ def run(self, options): # when input is a string for asset_file in files('pdfgeneration').joinpath('template/assets').iterdir(): os.symlink(asset_file, path.join('/tmp', asset_file.name)) - os.symlink(path.join(options.inputdir, options.imagefile), path.join('/tmp', options.imagefile)) + os.symlink(path.join(nPath, options.imagefile), path.join('/tmp', options.imagefile)) pdfkit.from_string(txt, path.join(options.outputdir, 'patient_analysis.pdf')) - def show_man_page(self): - self.print_help() + """ + Print the app's man page. + """ + print(Gstr_synopsis) diff --git a/setup.py b/setup.py index 5772095..ce3c113 100755 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name = 'pdfgeneration', - version = '0.2.0', + version = '0.3.0', description = 'An app that takes in COVID-Net prediction results and generates PDF', long_description = readme, author = 'DarwinAI',