Skip to content

Commit

Permalink
Merge pull request #36 from neuronflow/cli-citation-reminder
Browse files Browse the repository at this point in the history
Cli citation reminder
  • Loading branch information
neuronflow authored Oct 24, 2023
2 parents ac71445 + e7462c2 commit 856f93f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
6 changes: 2 additions & 4 deletions brats_toolkit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pprint
import argparse


from . import segmentor, fusionator, preprocessor


Expand Down Expand Up @@ -41,7 +42,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 @@ -83,7 +84,6 @@ 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,7 +179,6 @@ 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 @@ -243,7 +242,6 @@ 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
3 changes: 3 additions & 0 deletions brats_toolkit/fusionator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
import os.path as op
from .util import own_itk as oitk
from .util import filemanager as fm
from .util.citation_reminder import citation_reminder


class Fusionator(object):

@citation_reminder
def __init__(self, verbose=True):
self.verbose = verbose

Expand Down
9 changes: 6 additions & 3 deletions brats_toolkit/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
from pathlib import Path

from brats_toolkit.util.prep_utils import tempFiler
from brats_toolkit.util.citation_reminder import citation_reminder
import sys


class Preprocessor(object):

@citation_reminder
def __init__(self, noDocker=False):
# settings
self.clientVersion = "0.0.1"
Expand Down Expand Up @@ -45,7 +48,7 @@ def message(data):

@self.sio.on("status")
def on_status(data):
print("status reveived: ", data)
print("status received: ", data)
if data["message"] == "client ID json generation finished!":
self._inspect_input()
elif data["message"] == "input inspection finished!":
Expand Down Expand Up @@ -85,7 +88,7 @@ def outdated(data):

@self.sio.on("ipstatus")
def on_ipstatus(data):
print("image processing status reveived:")
print("image processing status received:")
print(data["examid"], ": ", data["ipstatus"])

def single_preprocess(
Expand Down Expand Up @@ -161,7 +164,7 @@ def batch_preprocess(

# setup connection
# TODO do this in a more elegant way and somehow check whether docker is up and running before connect
self.sio.sleep(5) # wait 5 secs for docker to start
self.sio.sleep(8) # wait 8 secs for docker to start
self._connect_client()
self.sio.wait()

Expand Down
2 changes: 2 additions & 0 deletions brats_toolkit/segmentor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
from . import fusionator
from .util import filemanager as fm
from .util import own_itk as oitk
from .util.citation_reminder import citation_reminder


class Segmentor(object):
"""
Now does it all!
"""

@citation_reminder
def __init__(
self,
config=None,
Expand Down
14 changes: 14 additions & 0 deletions brats_toolkit/util/citation_reminder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from rich.console import Console

def citation_reminder(func):

def wrapper(*args, **kwargs):
console = Console()
console.rule("[bold red]Friendly citation reminder[/bold red]")
console.print("If you use this software in your research, please [bold cyan]cite[/bold cyan] BraTS Toolkit and the original authors of the algorithms who make this repository and tool possible.", justify="center")
console.print("Details can be found at https://github.com/neuronflow/BraTS-Toolkit#citation", justify="center")
console.print("Thank you!", justify="center")
console.rule()
console.line()
func(*args, **kwargs)
return wrapper
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ dependencies = [
'numpy==1.22.0',
'python-engineio==3.14.2',
'python-socketio==4.6.1',
'requests==2.24.0'
'requests==2.24.0',
'rich==13.6.0'
]

[project.optional-dependencies]
Expand Down

0 comments on commit 856f93f

Please sign in to comment.