Skip to content

Commit

Permalink
feat(python): support python command without conda
Browse files Browse the repository at this point in the history
- add new package `python-gdcm` to support GDCM
- remove unused environment variable
`DCM2JPEG_PYTHONAPI_HOST`
- fix the error of frameNumber argument, it should be convert to integer
  • Loading branch information
Chinlinlee committed Mar 10, 2022
1 parent f173ff7 commit dea2e48
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
7 changes: 3 additions & 4 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@ MONGODB_PASSWORD="password"
MONGODB_SLAVEMODE=false

SERVER_HOST="localhost"
SERVER_PORT=80
SERVER_PORT=8081

DICOM_STORE_ROOTPATH='C:/'
DICOMWEB_HOST="localhost"
DICOMWEB_PORT=80
DICOMWEB_PORT=8081
DICOMWEB_API="dicom-web"

FHIRSERVER_HTTP="http"
FHIRSERVER_APIPATH="api/fhir"
FHIRSERVER_HOST="localhost"
FHIRSERVER_PORT=80
FHIRSERVER_PORT=8081
FHIR_NEED_PARSE_PATIENT=true

CONDA_PATH="path/conda.exe"
CONDA_GDCM_ENV_NAME ="gdcm"

USE_DCM2JPEG_PYTHONAPI=true
DCM2JPEG_PYTHONAPI_HOST=localhost
DCM2JPEG_PYTHONAPI_PORT=5000

ENABLE_LOGIN_ACCESS=false
3 changes: 2 additions & 1 deletion DICOM2JPEGFrame.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#coding:utf-8
import pydicom
import matplotlib.pyplot as plt
from PIL import Image, ImageOps
Expand Down Expand Up @@ -101,7 +102,7 @@ def DICOM2JPEGFrame(filename, frameNumber=0):
frameNumber = 1

try:
frameNumber = sys.argv[2]
frameNumber = int(sys.argv[2])
except:
frameNumber = 1
pass
Expand Down
8 changes: 3 additions & 5 deletions build_raccoon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ CONDA_PATH="path/conda.exe"
CONDA_GDCM_ENV_NAME ="gdcm"
USE_DCM2JPEG_PYTHONAPI=true
DCM2JPEG_PYTHONAPI_HOST=localhost
DCM2JPEG_PYTHONAPI_PORT=5000
ENABLE_LOGIN_ACCESS=false
Expand Down Expand Up @@ -98,25 +97,24 @@ MONGODB_PASSWORD="password"
MONGODB_SLAVEMODE=false
SERVER_HOST="localhost"
SERVER_PORT=80
SERVER_PORT=8081
DICOM_STORE_ROOTPATH='/dicomFiles'
DICOMWEB_HOST="localhost"
DICOMWEB_PORT=80
DICOMWEB_PORT=8081
DICOMWEB_API="dicom-web"
DCMTK_ROOT_PATH="${(path.resolve(path.dirname(files[0]))).replace(/\\/g , '/')}"
FHIRSERVER_APIPATH="api/fhir"
FHIRSERVER_HOST="localhost"
FHIRSERVER_PORT=80
FHIRSERVER_PORT=8081
FHIR_NEED_PARSE_PATIENT = true
CONDA_PATH="path/conda.exe"
CONDA_GDCM_ENV_NAME="gdcm"
USE_DCM2JPEG_PYTHONAPI=true
DCM2JPEG_PYTHONAPI_HOST=localhost
DCM2JPEG_PYTHONAPI_PORT=5000
ENABLE_LOGIN_ACCESS=true
Expand Down
4 changes: 3 additions & 1 deletion models/python/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ const getJpeg = {
return resolve(true);
}
} else {
exec(`${condaPath} run -n ${condaEnvName} python DICOM2JPEG.py ${store_Path}`, {
let cmd = `python DICOM2JPEG.py ${store_Path}`;
if(process.env.USE_CONDA === "true") cmd = `${condaPath} run -n ${condaEnvName} python DICOM2JPEG.py ${store_Path}`;
exec(`${cmd}`, {
cwd: process.cwd()
}, function (err, stdout, stderr) {
if (err) {
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Pillow==9.0.0
Flask==2.0.2
matplotlib==3.5.1
highdicom==0.14.0
numpy==1.22.1
numpy>=1.21
python-gdcm
4 changes: 3 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ let condaEnvName = process.env.CONDA_GDCM_ENV_NAME;
}
if (!isflaskRunning) {
if (process.env.ENV == "windows") {
exec(`${condaPath} run -n ${condaEnvName} python DICOM2JPEGAPI.py ${process.env.DCM2JPEG_PYTHONAPI_PORT}`, {
let cmd = `python DICOM2JPEGAPI.py ${process.env.DCM2JPEG_PYTHONAPI_PORT}`;
if (process.env.USE_CONDA === "true") cmd = `${condaPath} run -n ${condaEnvName} python DICOM2JPEGAPI.py ${process.env.DCM2JPEG_PYTHONAPI_PORT}`;
exec(`${cmd}`, {
cwd: process.cwd()
}, function (err, stdout, stderr) {
if (err) {
Expand Down

0 comments on commit dea2e48

Please sign in to comment.