Skip to content

Commit

Permalink
Merge pull request #55 from neuronflow/54-feature-request-we-want-for…
Browse files Browse the repository at this point in the history
…matted-code

blacked and formatted
  • Loading branch information
neuronflow committed Dec 23, 2023
2 parents ecb3ea6 + ef13af5 commit ce981df
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 161 deletions.
1 change: 0 additions & 1 deletion brats_toolkit/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

14 changes: 8 additions & 6 deletions brats_toolkit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
# Please refer to README.md and LICENSE.md for further documentation
# This software is not certified for clinical use.

import sys
import subprocess
import pprint
import argparse
import pprint
import subprocess
import sys


from . import segmentor, fusionator, preprocessor
from . import fusionator, preprocessor, segmentor


def list_dockers():
Expand Down Expand Up @@ -42,7 +41,7 @@ def list_docker_cpu():
if seg.config[id]["runtime"] == "runc":
print(id)


def fusion():
parser = argparse.ArgumentParser(
description="Runs the Docker orchestra to fuse segmentations. All inputs have to have equal shape and label values"
Expand Down Expand Up @@ -84,6 +83,7 @@ def fusion():
except Exception as e:
print("ERROR DETAIL: ", e)


def segmentation():
parser = argparse.ArgumentParser(
description="Runs the Docker orchestra to segment and fuse segmentations based on the"
Expand Down Expand Up @@ -179,6 +179,7 @@ def segmentation():
except Exception as e:
print("ERROR DETAIL: ", e)


def batchpreprocess():
parser = argparse.ArgumentParser(
description="Runs the preprocessing for MRI scans on a folder of images."
Expand Down Expand Up @@ -242,6 +243,7 @@ def batchpreprocess():
except Exception as e:
print("ERROR DETAIL: ", e)


def singlepreprocess():
parser = argparse.ArgumentParser(
description="Runs the preprocessing for MRI scans on a single set of images."
Expand Down
10 changes: 5 additions & 5 deletions brats_toolkit/fusionator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
#
# Please refer to README.md and LICENSE.md for further documentation
# This software is not certified for clinical use.
import os
import logging
import itertools
import logging
import math
import os
import os.path as op

import numpy as np
import os.path as op
from .util import own_itk as oitk

from .util import filemanager as fm
from .util import own_itk as oitk
from .util.citation_reminder import citation_reminder


class Fusionator(object):

@citation_reminder
def __init__(self, verbose=True):
self.verbose = verbose
Expand Down
45 changes: 27 additions & 18 deletions brats_toolkit/util/docker_functions.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import shlex
import platform
import os
import pathlib
import platform
import shlex
import subprocess
import os


def start_docker(exam_import_folder=None,
exam_export_folder=None, dicom_import_folder=None, nifti_export_folder=None, mode="cpu", gpuid='0'):
def start_docker(
exam_import_folder=None,
exam_export_folder=None,
dicom_import_folder=None,
nifti_export_folder=None,
mode="cpu",
gpuid="0",
):
# deal with missing arguments
if dicom_import_folder is None:
dicom_import_folder = exam_import_folder
Expand Down Expand Up @@ -38,28 +44,31 @@ def start_docker(exam_import_folder=None,

operatingSystem = platform.system()
if operatingSystem == "Windows":
bashscript = os.path.join(cwd, os.path.normpath(
'./backend_scripts/win_docker.cmd'))
bashscript = os.path.join(
cwd, os.path.normpath("./backend_scripts/win_docker.cmd")
)
else:
if mode == "cpu":
bashscript = os.path.normpath(
'./backend_scripts/unix_docker.sh')
bashscript = os.path.normpath("./backend_scripts/unix_docker.sh")
elif mode == "robex":
bashscript = os.path.normpath(
'./backend_scripts/unix_docker.sh')
bashscript = os.path.normpath("./backend_scripts/unix_docker.sh")
elif mode == "gpu":
bashscript = os.path.normpath(
'./backend_scripts/unix_docker_gpu.sh')
bashscript = os.path.normpath("./backend_scripts/unix_docker_gpu.sh")
elif mode == "gpu_hdbet":
bashscript = os.path.normpath(
'./backend_scripts/unix_docker_gpu.sh')
bashscript = os.path.normpath("./backend_scripts/unix_docker_gpu.sh")

# generate subprocess call
command = [bashscript, "3", dicom_import_folder,
nifti_export_folder, exam_import_folder, exam_export_folder, gpuid]
command = [
bashscript,
"3",
dicom_import_folder,
nifti_export_folder,
exam_import_folder,
exam_export_folder,
gpuid,
]
print(*command)


print("starting docker!")
subprocess.run(command, cwd=cwd)
print("docker started!")
Expand Down
Loading

0 comments on commit ce981df

Please sign in to comment.