Skip to content

Commit

Permalink
Fix for Windows dvp.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbouget committed May 7, 2022
1 parent cfc5922 commit 98aa5cd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ The module can either be used as a Python library, as CLI, or as Docker containe
pip install git+https://github.com/dbouget/raidionics-seg-lib.git
```

No GPU support for TensorFlow on macOS.
No GPU support for TensorFlow by default. A manual installation of CUDA and of
the following Python package is necessary.

```
pip install tensorflow-gpu==1.14.0
```

# Usage
## CLI
Expand Down
8 changes: 4 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def main(argv):
elif opt in ("-c", "--Config"):
config_filename = arg
elif opt in ("-v", "--Verbose"):
if opt.lower() == 'debug':
if arg.lower() == 'debug':
logging.getLogger().setLevel(logging.DEBUG)
elif opt.lower() == 'info':
elif arg.lower() == 'info':
logging.getLogger().setLevel(logging.INFO)
elif opt.lower() == 'warning':
elif arg.lower() == 'warning':
logging.getLogger().setLevel(logging.WARNING)
elif opt.lower() == 'error':
elif arg.lower() == 'error':
logging.getLogger().setLevel(logging.ERROR)

if not config_filename or not os.path.exists(config_filename):
Expand Down
16 changes: 13 additions & 3 deletions raidionicsseg/PreProcessing/brain_clipping.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import configparser
import sys
from typing import Tuple, List
import numpy as np
from copy import deepcopy
Expand All @@ -10,6 +11,7 @@
import shutil
import os
import logging
from pathlib import PurePath
from raidionicsseg.Utils.io import load_nifti_volume, convert_and_export_to_nifti
from raidionicsseg.Utils.configuration_parser import generate_runtime_config
from raidionicsseg.Utils.configuration_parser import ConfigResources
Expand Down Expand Up @@ -116,9 +118,17 @@ def skull_stripping_tf(filepath, volume: np.ndarray, new_spacing: Tuple[float],
new_parameters.set('Runtime', 'reconstruction_order', 'resample_first')
with open(brain_config_filename, 'w') as cf:
new_parameters.write(cf)
script_path = '/'.join(os.path.dirname(os.path.realpath(__file__)).split('/')[:-1]) + '/__main__.py'
subprocess.call(['python3', '{script}'.format(script=script_path),
'{config}'.format(config=brain_config_filename)])
if os.name == 'nt':
script_path_parts = list(PurePath(os.path.realpath(__file__)).parts[:-2] + ('__main__.py',))
script_path = PurePath()
for x in script_path_parts:
script_path = script_path.joinpath(x)
subprocess.call([sys.executable, '{script}'.format(script=script_path),
'{config}'.format(config=brain_config_filename)])
else:
script_path = '/'.join(os.path.dirname(os.path.realpath(__file__)).split('/')[:-1]) + '/__main__.py'
subprocess.call(['python3', '{script}'.format(script=script_path),
'{config}'.format(config=brain_config_filename)])
brain_mask_filename = os.path.join(storage_path, 'labels_Brain.nii.gz')
os.remove(brain_config_filename)
else:
Expand Down
1 change: 1 addition & 0 deletions raidionicsseg/Utils/configuration_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def __setup(self):
self.runtime_lungs_mask_filepath = ''
self.runtime_brain_mask_filepath = ''


def init_environment(self, config_filename):
self.config_filename = config_filename
self.config = configparser.ConfigParser()
Expand Down

0 comments on commit 98aa5cd

Please sign in to comment.