Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update error messages #282

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions pypet2bids/pypet2bids/dcm2niix4pet.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def __init__(self, image_folder, destination_path=None, metadata_path=None,

self.dcm2niix_path = self.check_for_dcm2niix()
if not self.dcm2niix_path:
raise FileNotFoundError("dcm2niix not found, this module depends on it for conversions, exiting.")
logger.error("dcm2niix not found, this module depends on it for conversions, exiting.")
sys.exit(1)

# check for the version of dcm2niix
minimum_version = 'v1.0.20220720'
Expand Down Expand Up @@ -286,11 +287,26 @@ def check_posix():
dcm2niix_path = subprocess.run('which dcm2niix',
shell=True,
capture_output=True).stdout.decode('utf-8').strip()
# check to see if dcm2niix is set in the config file, default to that if it's the case and alert user
set_in_config = helper_functions.check_pet2bids_config()
if set_in_config:
logger.warning(f"dcm2niix found on system path, but dcm2niix path is also set in ~/.pet2bidsconfig."
f" Defaulting to dcm2niix path set in config at {set_in_config}")
dcm2niix_path = set_in_config

else:
dcm2niix_path = helper_functions.check_pet2bids_config()

if not dcm2niix_path:
pkged = "https://github.com/rordenlab/dcm2niix/releases"
instructions = "https://github.com/rordenlab/dcm2niix#install"
no_dcm2niix = f"""Dcm2niix does not appear to be installed. Installation instructions can be found here
{instructions} and packaged versions can be found at {pkged}"""
no_dcm2niix = f"""Unable to locate Dcm2niix on your system $PATH or using the path specified in
$HOME/.pypet2bidsconfig. Installation instructions for dcm2niix can be found here
{instructions}
and packaged versions can be found at
{pkged}
Alternatively, you can set the path to dcm2niix in the config file at $HOME/.pet2bidsconfig
using the command dcm2niix4pet --set-dcm2niix-path."""
logger.error(no_dcm2niix)
dcm2niix_path = None

Expand Down
Loading